From eaceca57ac83b691c70543241bcfa03d51282467 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Mon, 28 Nov 2016 11:17:18 -0600 Subject: [PATCH] feat: Allows to add sockets to a completed agent. --- .../java/org/ice4j/ice/harvest/TcpHarvester.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java b/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java index d38fc88..5a3c455 100644 --- a/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java +++ b/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java @@ -491,8 +491,18 @@ public class TcpHarvester if (!IceProcessingState.WAITING.equals(state) && !IceProcessingState.RUNNING.equals(state)) { - throw new IllegalStateException( - "The associated Agent is in state " + state); + // If we are using the VSL, we can still make use of the socket. + // Otherwise, we have no use for it, so we better close it (and + // log a warning) early. + if (!Agent.ENABLE_VIRTUAL_SOCKET_LAYER) + { + throw new IllegalStateException( + "The associated Agent is in state " + state); + } + else if (logger.isLoggable(Level.FINE)) + { + logger.fine("Adding a socket to an Agent in state " + state); + } } // Socket to add to the candidate