Removed the DB listener when the connection is closed.

This commit is contained in:
akwizgran
2011-12-07 21:37:13 +00:00
parent e2cb1027af
commit c728377ae1

View File

@@ -184,10 +184,9 @@ abstract class StreamConnection implements DatabaseListener {
void write() {
try {
db.addListener(this);
OutputStream out = createConnectionWriter().getOutputStream();
writer = protoWriterFactory.createProtocolWriter(out);
// Start receiving database events
db.addListener(this);
// Send the initial packets: transports, subs, acks, offer
dbExecutor.execute(new GenerateTransportUpdate());
dbExecutor.execute(new GenerateSubscriptionUpdate());
@@ -215,6 +214,8 @@ abstract class StreamConnection implements DatabaseListener {
} catch(IOException e) {
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.getMessage());
transport.dispose(false);
} finally {
db.removeListener(this);
}
}