Remove unnecessary latches in tests

See gh-16733
This commit is contained in:
Johnny Lim 2019-05-07 20:57:25 +09:00 committed by Andy Wilkinson
parent bd5f09906e
commit 0baceb4aa4
5 changed files with 0 additions and 15 deletions

View File

@ -20,7 +20,6 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collection;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
@ -95,11 +94,9 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
protected ConfigurableApplicationContext getContext(
Supplier<ConfigurableApplicationContext> supplier) throws Exception {
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<ConfigurableApplicationContext> atomicReference = new AtomicReference<>();
Thread thread = new Thread(() -> {
ConfigurableApplicationContext context = supplier.get();
latch.countDown();
atomicReference.getAndSet(context);
});
thread.start();

View File

@ -21,7 +21,6 @@ import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
@ -253,11 +252,9 @@ public class LocalDevToolsAutoConfigurationTests {
private ConfigurableApplicationContext getContext(
Supplier<ConfigurableApplicationContext> supplier) throws Exception {
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<ConfigurableApplicationContext> atomicReference = new AtomicReference<>();
Thread thread = new Thread(() -> {
ConfigurableApplicationContext context = supplier.get();
latch.countDown();
atomicReference.getAndSet(context);
});
thread.start();

View File

@ -16,7 +16,6 @@
package org.springframework.boot.devtools.autoconfigure;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
@ -183,11 +182,9 @@ public class RemoteDevToolsAutoConfigurationTests {
private AnnotationConfigServletWebApplicationContext getContext(
Supplier<AnnotationConfigServletWebApplicationContext> supplier)
throws Exception {
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<AnnotationConfigServletWebApplicationContext> atomicReference = new AtomicReference<>();
Thread thread = new Thread(() -> {
AnnotationConfigServletWebApplicationContext context = supplier.get();
latch.countDown();
atomicReference.getAndSet(context);
});
thread.start();

View File

@ -18,7 +18,6 @@ package org.springframework.boot.devtools.env;
import java.net.URL;
import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
@ -122,11 +121,9 @@ public class DevToolPropertiesIntegrationTests {
protected ConfigurableApplicationContext getContext(
Supplier<ConfigurableApplicationContext> supplier) throws Exception {
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<ConfigurableApplicationContext> atomicReference = new AtomicReference<>();
Thread thread = new Thread(() -> {
ConfigurableApplicationContext context = supplier.get();
latch.countDown();
atomicReference.getAndSet(context);
});
thread.start();

View File

@ -21,7 +21,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
import org.junit.Before;
import org.junit.Rule;
@ -74,10 +73,8 @@ public class DevToolsHomePropertiesPostProcessorTests {
}
protected void runPostProcessor(Runnable runnable) throws Exception {
CountDownLatch latch = new CountDownLatch(1);
Thread thread = new Thread(() -> {
runnable.run();
latch.countDown();
});
thread.start();
thread.join();