Skip to content

Commit

Permalink
java: ITClient: name background threads
Browse files Browse the repository at this point in the history
The ITClient test has several background threads that perform tasks
while the test is running. Naming these threads makes it easier to
understand what happened when wading through the test log.

This patch also squelches an unrelated warning from TempDirUtils due to
not specifying @OverRide on a Thread's run() method.

Change-Id: I9874b088cc8e77707fc913df3de1d1592c1de6c3
Reviewed-on: http://gerrit.cloudera.org:8080/12677
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <[email protected]>
  • Loading branch information
mpercy committed Mar 6, 2019
1 parent 5953357 commit cd66342
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,13 @@ public void setUp() throws Exception {

@Test(timeout = TEST_TIMEOUT_SECONDS)
public void test() throws Exception {

UncaughtExceptionHandler uncaughtExceptionHandler = new UncaughtExceptionHandler();

ArrayList<Thread> threads = new ArrayList<>();
Thread chaosThread = new Thread(new ChaosThread());
Thread writerThread = new Thread(new WriterThread());
Thread scannerThread = new Thread(new ScannerThread());

threads.add(chaosThread);
threads.add(writerThread);
threads.add(scannerThread);
List<Thread> threads = new ArrayList<>();
threads.add(new Thread(new ChaosThread(), "chaos-test-thread"));
threads.add(new Thread(new WriterThread(), "writer-test-thread"));
threads.add(new Thread(new ScannerThread(), "scanner-test-thread"));

for (Thread thread : threads) {
thread.setUncaughtExceptionHandler(uncaughtExceptionHandler);
thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler());
thread.start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public static File makeTempDirectory(String prefix, DeleteOnExit deleteRecursive
private static void registerToRecursivelyDeleteOnShutdown(Path path) {
final Path absPath = path.toAbsolutePath();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
File dir = absPath.toFile();
if (!dir.exists()) return;
Expand Down

0 comments on commit cd66342

Please sign in to comment.