Close and reopen the socket if necessary when the properties change.

This commit is contained in:
akwizgran
2011-10-06 17:39:51 +01:00
parent f23e89c80e
commit bb9f03f1e8
2 changed files with 73 additions and 1 deletions

View File

@@ -130,6 +130,18 @@ abstract class SocketPlugin implements StreamTransportPlugin {
throws InvalidPropertiesException {
if(!started) throw new IllegalStateException();
localProperties = properties;
// Close and reopen the socket if its address has changed
if(socket != null) {
SocketAddress addr = socket.getLocalSocketAddress();
if(!getLocalSocketAddress().equals(addr)) {
try {
socket.close();
} catch(IOException e) {
// FIXME: Logging
}
executor.execute(createBinder());
}
}
}
public synchronized void setRemoteProperties(ContactId c,