/** {@inheritDoc} */ @Override public void close() { closing = true; if (pendingOutMessages.size() > 0) { if (log.isTraceEnabled()) { log.trace("Clearing pending messages out: {}", pendingOutMessages.size()); } pendingOutMessages.clear(); } // clean up buffer if (buffer != null) { buffer.free(); buffer = null; } super.close(); }
/** * Skip data sent by the client. * * @param req * Servlet request * @throws IOException * I/O exception */ protected void skipData(HttpServletRequest req) throws IOException { log.trace("skipData {}", req); int length = req.getContentLength(); log.trace("Skipping {} bytes", length); IoBuffer data = IoBuffer.allocate(length); ServletUtils.copy(req, data.asOutputStream()); data.flip(); data.free(); data = null; log.trace("Skipped {} bytes", length); }
/** * Sends response to client * * @param resp * Response * @param packet * Remoting packet * @throws Exception * General exception */ protected void sendResponse(HttpServletResponse resp, RemotingPacket packet) throws Exception { log.debug("Sending response"); IoBuffer respBuffer = codecFactory.getRemotingEncoder().encode(packet); if (respBuffer != null) { final ServletOutputStream out = resp.getOutputStream(); resp.setContentLength(respBuffer.limit()); ServletUtils.copy(respBuffer.asInputStream(), out); out.flush(); out.close(); respBuffer.free(); respBuffer = null; } else { log.info("Response buffer was null after encoding"); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) public void operationComplete(CloseFuture future) { // now connection should be closed log.debug("Close operation completed {}: {}", sessionId, future.isClosed()); future.removeListener(this); for (Object key : session.getAttributeKeys()) { Object obj = session.getAttribute(key); log.debug("{}: {}", key, obj); if (obj != null) { if (log.isTraceEnabled()) { log.trace("Attribute: {}", obj.getClass().getName()); } if (obj instanceof IoProcessor) { log.debug("Flushing session in processor"); ((IoProcessor) obj).flush(session); log.debug("Removing session from processor"); ((IoProcessor) obj).remove(session); } else if (obj instanceof IoBuffer) { log.debug("Clearing session buffer"); ((IoBuffer) obj).clear(); ((IoBuffer) obj).free(); } } } } };
conn.updateWrittenBytes(contentLength); buffer.free(); buffer = null;
reqBuffer.free(); reqBuffer = null; return packet;
message.get(plain); message.clear(); message.free();
} finally { if (buf != null) { buf.free(); buf = null;
buf.free(); buf = null;
message.get(encrypted); message.clear(); message.free(); byte[] plain = cipher.update(encrypted); IoBuffer messageDecrypted = IoBuffer.wrap(plain);
conn.updateReadBytes(length); message.clear(); message.free();
/** * {@inheritDoc} */ @Override public void free() { buf.free(); }
/** {@inheritDoc} */ @Override protected void releaseInternal() { if (data != null) { data.free(); data = null; } }
/** {@inheritDoc} */ @Override protected void releaseInternal() { if (data != null) { data.free(); data = null; } }
/** {@inheritDoc} */ @Override protected void releaseInternal() { if (data != null) { data.free(); data = null; } }
/** * Internal method that actually frees the {@link IoBuffer} that contains * the buffered data that has not been flushed. * * @param session the session we operate on */ private void free(IoSession session) { IoBuffer buf = buffersMap.remove(session); if (buf != null) { buf.free(); } }
/** * Internal method that actually frees the {@link IoBuffer} that contains * the buffered data that has not been flushed. * * @param session the session we operate on */ private void free(IoSession session) { IoBuffer buf = buffersMap.remove(session); if (buf != null) { buf.free(); } }
/** {@inheritDoc} */ @Override protected void releaseInternal() { if (data != null) { final IoBuffer localData = data; // null out the data first so we don't accidentally // return a valid reference first data = null; localData.clear(); localData.free(); } }
/** * Releases pending message body, nullifies pending message object */ private void releasePendingMessage() { if (pendingMessage != null) { IRTMPEvent body = pendingMessage.getBody(); if (body instanceof IStreamData && ((IStreamData<?>) body).getData() != null) { ((IStreamData<?>) body).getData().free(); } pendingMessage = null; } }
public CacheableImpl(Object obj) { IoBuffer tmp = IoBuffer.allocate(1024, true); tmp.setAutoExpand(true); tmp.putObject(obj); bytes = new byte[tmp.capacity()]; tmp.get(bytes); cached = true; tmp.free(); tmp = null; }