//
// ========================================================================
-// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
+// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
*/
public ByteBuffer getResponses(ByteBuffer requestsBuffer,long idleFor,TimeUnit units) throws Exception
{
- LOG.debug("requests {}", BufferUtil.toUTF8String(requestsBuffer));
+ if (LOG.isDebugEnabled())
+ LOG.debug("requests {}", BufferUtil.toUTF8String(requestsBuffer));
LocalEndPoint endp = executeRequest(requestsBuffer);
endp.waitUntilClosedOrIdleFor(idleFor,units);
ByteBuffer responses = endp.takeOutput();
- endp.getConnection().close();
- LOG.debug("responses {}", BufferUtil.toUTF8String(responses));
+ if (endp.isOutputShutdown())
+ endp.close();
+ if (LOG.isDebugEnabled())
+ LOG.debug("responses {}", BufferUtil.toUTF8String(responses));
return responses;
}
private LocalEndPoint executeRequest(ByteBuffer rawRequest)
{
+ if (!isStarted())
+ throw new IllegalStateException("!STARTED");
LocalEndPoint endp = new LocalEndPoint();
endp.setInput(rawRequest);
_connects.add(endp);
@Override
protected void accept(int acceptorID) throws IOException, InterruptedException
{
- LOG.debug("accepting {}", acceptorID);
+ if (LOG.isDebugEnabled())
+ LOG.debug("accepting {}", acceptorID);
LocalEndPoint endPoint = _connects.take();
endPoint.onOpen();
onEndPointOpened(endPoint);
{
if (size==getOutput().remaining())
{
- LOG.debug("idle for {} {}",idleFor,units);
+ if (LOG.isDebugEnabled())
+ LOG.debug("idle for {} {}",idleFor,units);
return;
}
size=getOutput().remaining();