summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2005-04-21 23:00:16 +0000
committerMark Spruiell <mes@zeroc.com>2005-04-21 23:00:16 +0000
commit8115142f10944efc984c618bca553c8182bf4d56 (patch)
tree0e9deb17bd895b52714b34954a73d43654c0e4d0
parentfile CertificateF.ice was initially added on branch transport_info. (diff)
downloadice-8115142f10944efc984c618bca553c8182bf4d56.tar.bz2
ice-8115142f10944efc984c618bca553c8182bf4d56.tar.xz
ice-8115142f10944efc984c618bca553c8182bf4d56.zip
fix for bug 245
-rw-r--r--java/src/IceInternal/EventHandler.java9
-rw-r--r--java/src/IceInternal/IncomingConnectionFactory.java24
2 files changed, 24 insertions, 9 deletions
diff --git a/java/src/IceInternal/EventHandler.java b/java/src/IceInternal/EventHandler.java
index ffe3bd7d3ab..43389373380 100644
--- a/java/src/IceInternal/EventHandler.java
+++ b/java/src/IceInternal/EventHandler.java
@@ -55,6 +55,13 @@ public abstract class EventHandler
return _instance;
}
+ public void
+ destroy()
+ {
+ _stream.destroy();
+ _stream = null;
+ }
+
protected
EventHandler(Instance instance)
{
@@ -66,7 +73,7 @@ public abstract class EventHandler
finalize()
throws Throwable
{
- _stream.destroy();
+ assert(_stream == null);
}
protected Instance _instance;
diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java
index 2b0b88711e0..117de308cbc 100644
--- a/java/src/IceInternal/IncomingConnectionFactory.java
+++ b/java/src/IceInternal/IncomingConnectionFactory.java
@@ -99,8 +99,12 @@ public final class IncomingConnectionFactory extends EventHandler
// We want to wait until all connections are finished outside the
// thread synchronization.
//
+ // For consistency with C#, we set _connections to null rather than to a
+ // new empty list so that our finalizer does not try to invoke any
+ // methods on member objects.
+ //
connections = _connections;
- _connections = new java.util.LinkedList();
+ _connections = null;
}
if(threadPerIncomingConnectionFactory != null)
@@ -124,6 +128,16 @@ public final class IncomingConnectionFactory extends EventHandler
Ice.ConnectionI connection = (Ice.ConnectionI)p.next();
connection.waitUntilFinished();
}
+
+ //
+ // At this point we know that this factory is no longer used, so it is
+ // safe to invoke destroy() on the EventHandler base class to reclaim
+ // resources.
+ //
+ // We call this here instead of in the finalizer because a C# finalizer
+ // cannot invoke methods on other types of objects.
+ //
+ super.destroy();
}
public Endpoint
@@ -445,15 +459,9 @@ public final class IncomingConnectionFactory extends EventHandler
{
assert(_state == StateClosed);
assert(_acceptor == null);
- assert(_connections.size() == 0);
+ assert(_connections == null);
assert(_threadPerIncomingConnectionFactory == null);
- //
- // Destroy the EventHandler's stream, so that its buffer
- // can be reclaimed.
- //
- super._stream.destroy();
-
super.finalize();
}