Author: rgoers
Date: Thu Mar 21 04:47:52 2013
New Revision: 1459152
URL: http://svn.apache.org/r1459152
Log:
Test fails periodically
Modified:
logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
Modified:
logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java?rev=1459152&r1=1459151&r2=1459152&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
(original)
+++
logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/net/SocketReconnectTest.java
Thu Mar 21 04:47:52 2013
@@ -33,6 +33,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -71,6 +72,21 @@ public class SocketReconnectTest {
assertEquals(message, reader.readLine());
closeQuietly(testServer);
+ executor.shutdown();
+ try {
+ // Wait a while for existing tasks to terminate
+ if (!executor.awaitTermination(100, TimeUnit.MILLISECONDS)) {
+ executor.shutdownNow();
+ if (!executor.awaitTermination(100,
TimeUnit.MILLISECONDS)) {
+ System.err.println("Pool did not terminate");
+ }
+ }
+ } catch (InterruptedException ie) {
+ // (Re-)Cancel if current thread also interrupted
+ executor.shutdownNow();
+ // Preserve interrupt status
+ Thread.currentThread().interrupt();
+ }
message = "Log #2";
logger.error(message);
@@ -83,6 +99,7 @@ public class SocketReconnectTest {
}
//System.err.println("Re-initializing server");
+ executor = Executors.newSingleThreadExecutor();
testServer = new TestSocketServer();
futureIn = executor.submit(testServer);
Thread.sleep(500);