Author: veithen
Date: Sun Mar 11 16:33:23 2012
New Revision: 1299392
URL: http://svn.apache.org/viewvc?rev=1299392&view=rev
Log:
Avoid hang when port is already in use.
Modified:
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/DefaultConnectionListener.java
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/SimpleHttpServer.java
Modified:
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/DefaultConnectionListener.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/DefaultConnectionListener.java?rev=1299392&r1=1299391&r2=1299392&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/DefaultConnectionListener.java
(original)
+++
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/DefaultConnectionListener.java
Sun Mar 11 16:33:23 2012
@@ -116,7 +116,7 @@ public class DefaultConnectionListener i
}
public synchronized void awaitSocketOpen() throws InterruptedException {
- while (serversocket == null) {
+ while (serversocket == null && !destroyed) {
wait();
}
}
@@ -132,7 +132,7 @@ public class DefaultConnectionListener i
}
}
- public void destroy() {
+ public synchronized void destroy() {
this.destroyed = true;
try {
close();
@@ -143,7 +143,7 @@ public class DefaultConnectionListener i
}
}
- public boolean isDestroyed() {
+ public synchronized boolean isDestroyed() {
return this.destroyed;
}
Modified:
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/SimpleHttpServer.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/SimpleHttpServer.java?rev=1299392&r1=1299391&r2=1299392&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/SimpleHttpServer.java
(original)
+++
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/SimpleHttpServer.java
Sun Mar 11 16:33:23 2012
@@ -100,7 +100,9 @@ public class SimpleHttpServer {
this.listenerExecutor.execute(listener);
try {
listener.awaitSocketOpen();
- port = listener.getPort();
+ if (!listener.isDestroyed()) {
+ port = listener.getPort();
+ }
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}