Fixes #3989 - Using IO.close(Closable) instead
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
1ea4320a65
commit
669253bf6d
|
@ -38,6 +38,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
|
@ -287,7 +288,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
LOG.warn(x.toString());
|
||||
LOG.debug(x);
|
||||
}
|
||||
closeNoExceptions(selector);
|
||||
IO.close(selector);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -328,13 +329,13 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
{
|
||||
LOG.debug("Ignoring cancelled key for channel {}", key.channel());
|
||||
if (attachment instanceof EndPoint)
|
||||
closeNoExceptions((EndPoint)attachment);
|
||||
IO.close((EndPoint)attachment);
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.warn("Could not process key for channel " + key.channel(), x);
|
||||
if (attachment instanceof EndPoint)
|
||||
closeNoExceptions((EndPoint)attachment);
|
||||
IO.close((EndPoint)attachment);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -343,7 +344,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
LOG.debug("Selector loop ignoring invalid key for channel {}", key.channel());
|
||||
Object attachment = key.attachment();
|
||||
if (attachment instanceof EndPoint)
|
||||
closeNoExceptions((EndPoint)attachment);
|
||||
IO.close((EndPoint)attachment);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -434,24 +435,11 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
closeNoExceptions(channel);
|
||||
IO.close(channel);
|
||||
LOG.warn("Accept failed for channel " + channel, x);
|
||||
}
|
||||
}
|
||||
|
||||
private void closeNoExceptions(Closeable closeable)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (closeable != null)
|
||||
closeable.close();
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
LOG.ignore(x);
|
||||
}
|
||||
}
|
||||
|
||||
private EndPoint createEndPoint(SocketChannel channel, SelectionKey selectionKey) throws IOException
|
||||
{
|
||||
EndPoint endPoint = _selectorManager.newEndPoint(channel, this, selectionKey);
|
||||
|
@ -572,7 +560,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
closeNoExceptions(_channel);
|
||||
IO.close(_channel);
|
||||
LOG.warn(x);
|
||||
}
|
||||
}
|
||||
|
@ -593,7 +581,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
public void close()
|
||||
{
|
||||
LOG.debug("closed accept of {}", channel);
|
||||
closeNoExceptions(channel);
|
||||
IO.close(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -606,7 +594,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
closeNoExceptions(channel);
|
||||
IO.close(channel);
|
||||
LOG.debug(x);
|
||||
}
|
||||
}
|
||||
|
@ -641,12 +629,12 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
public void close()
|
||||
{
|
||||
LOG.debug("closed creation of {}", channel);
|
||||
closeNoExceptions(channel);
|
||||
IO.close(channel);
|
||||
}
|
||||
|
||||
protected void failed(Throwable failure)
|
||||
{
|
||||
closeNoExceptions(channel);
|
||||
IO.close(channel);
|
||||
LOG.debug(failure);
|
||||
}
|
||||
}
|
||||
|
@ -683,7 +671,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
if (failed.compareAndSet(false, true))
|
||||
{
|
||||
timeout.cancel();
|
||||
closeNoExceptions(channel);
|
||||
IO.close(channel);
|
||||
ManagedSelector.this._selectorManager.connectionFailed(channel, failure, attachment);
|
||||
}
|
||||
}
|
||||
|
@ -772,7 +760,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
closeNoExceptions(_endPoint.getConnection());
|
||||
IO.close(_endPoint.getConnection());
|
||||
_latch.countDown();
|
||||
}
|
||||
}
|
||||
|
@ -786,7 +774,7 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump
|
|||
{
|
||||
Selector selector = _selector;
|
||||
_selector = null;
|
||||
closeNoExceptions(selector);
|
||||
IO.close(selector);
|
||||
_latch.countDown();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue