Mercurial Hosting > luan
changeset 1075:ebb0f1343ef6
remove JBuffer
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 10 Nov 2016 03:08:20 -0700 |
parents | 6b7ff30bb990 |
children | 0d884377e923 |
files | src/org/eclipse/jetty/http/HttpFields.java src/org/eclipse/jetty/http/HttpGenerator.java src/org/eclipse/jetty/http/HttpParser.java src/org/eclipse/jetty/io/BufferUtil.java src/org/eclipse/jetty/io/Buffers.java src/org/eclipse/jetty/io/EndPoint.java src/org/eclipse/jetty/io/JBuffer.java src/org/eclipse/jetty/io/nio/ChannelEndPoint.java src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java src/org/eclipse/jetty/io/nio/SslConnection.java src/org/eclipse/jetty/server/AbstractHttpConnection.java src/org/eclipse/jetty/server/Connector.java src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java |
diffstat | 14 files changed, 109 insertions(+), 258 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/HttpFields.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/http/HttpFields.java Thu Nov 10 03:08:20 2016 -0700 @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; @@ -39,7 +40,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import org.eclipse.jetty.io.JBuffer; import org.eclipse.jetty.io.BufferUtil; import org.eclipse.jetty.util.LazyList; import org.eclipse.jetty.util.QuotedStringTokenizer; @@ -943,7 +943,7 @@ _next = null; } - public void putTo(JBuffer buffer) throws IOException + public void putTo(ByteBuffer buffer) throws IOException { byte[] nameBytes = StringUtil.getBytes(_name); if (getNameOrdinal() >=0 )
--- a/src/org/eclipse/jetty/http/HttpGenerator.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/http/HttpGenerator.java Thu Nov 10 03:08:20 2016 -0700 @@ -20,9 +20,9 @@ import java.io.IOException; import java.io.InterruptedIOException; +import java.nio.ByteBuffer; import java.util.Arrays; -import org.eclipse.jetty.io.JBuffer; import org.eclipse.jetty.io.BufferUtil; import org.eclipse.jetty.io.Buffers; import org.eclipse.jetty.io.EndPoint; @@ -121,12 +121,11 @@ * * @param content * @param last - * @throws IllegalArgumentException if <code>content</code> is {@link JBuffer#isImmutable immutable}. * @throws IllegalStateException If the request is not expecting any more content, * or if the buffers are full and cannot be flushed. * @throws IOException if there is a problem flushing the buffers. */ - public void addContent(JBuffer content, boolean last) throws IOException + public void addContent(ByteBuffer content, boolean last) throws IOException { if (_noContent) throw new IllegalStateException("NO CONTENT"); @@ -149,7 +148,7 @@ { if (_bufferChunked) { - JBuffer nc = _buffers.getBuffer(_content.remaining()+CHUNK_SPACE+content.remaining()); + ByteBuffer nc = _buffers.getBuffer(_content.remaining()+CHUNK_SPACE+content.remaining()); nc.put(_content); nc.put(HttpTokens.CRLF); BufferUtil.putHexInt(nc, content.remaining()); @@ -160,7 +159,7 @@ } else { - JBuffer nc = _buffers.getBuffer(_content.remaining()+content.remaining()); + ByteBuffer nc = _buffers.getBuffer(_content.remaining()+content.remaining()); nc.put(_content); nc.put(content); nc.flip(); @@ -838,9 +837,9 @@ @Override public String toString() { - JBuffer header = _header; - JBuffer buffer = _buffer; - JBuffer content = _content; + ByteBuffer header = _header; + ByteBuffer buffer = _buffer; + ByteBuffer content = _content; return String.format("%s{s=%d,h=%d,b=%d,c=%d}", getClass().getSimpleName(), _state, @@ -880,7 +879,7 @@ private int _status = 0; private int _version = HttpVersions.HTTP_1_1_ORDINAL; - private JBuffer _reason; + private ByteBuffer _reason; private long _contentWritten = 0; private long _contentLength = HttpTokens.UNKNOWN_CONTENT; @@ -889,9 +888,9 @@ private boolean _noContent = false; private Boolean _persistent = null; - private final JBuffer _header; // JBuffer for HTTP header (and maybe small _content) - private final JBuffer _buffer; // JBuffer for copy of passed _content - private JBuffer _content; // JBuffer passed to addContent + private final ByteBuffer _header; // ByteBuffer for HTTP header (and maybe small _content) + private final ByteBuffer _buffer; // ByteBuffer for copy of passed _content + private ByteBuffer _content; // ByteBuffer passed to addContent public HttpGenerator(Buffers buffers, EndPoint io) @@ -929,7 +928,7 @@ return _buffer.capacity(); } - public final JBuffer getUncheckedBuffer() + public final ByteBuffer getUncheckedBuffer() { return _buffer; } @@ -1005,7 +1004,7 @@ // TODO don't hard code if (len>1024) len=1024; - _reason = BufferUtil.newBuffer(len); + _reason = ByteBuffer.allocate(len); for (int i=0;i<len;i++) { char ch = reason.charAt(i); @@ -1062,8 +1061,8 @@ // block until everything is flushed long now = System.currentTimeMillis(); long end = now+maxIdleTime; - JBuffer content = _content; - JBuffer buffer = _buffer; + ByteBuffer content = _content; + ByteBuffer buffer = _buffer; if (content!=null && content.remaining()>0 || buffer.position()>0 || isBufferFull()) { flushBuffer();
--- a/src/org/eclipse/jetty/http/HttpParser.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/http/HttpParser.java Thu Nov 10 03:08:20 2016 -0700 @@ -19,8 +19,8 @@ package org.eclipse.jetty.http; import java.io.IOException; +import java.nio.ByteBuffer; -import org.eclipse.jetty.io.JBuffer; import org.eclipse.jetty.io.BufferUtil; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EofException; @@ -56,9 +56,9 @@ private final EventHandler _handler; private final EndPoint _endp; - public final JBuffer _header; // JBuffer for header data (and small _content) - private final JBuffer _body; // JBuffer for large content - private JBuffer _buffer; // The current buffer in use (either _header or _content) + public final ByteBuffer _header; // ByteBuffer for header data (and small _content) + private final ByteBuffer _body; // ByteBuffer for large content + private ByteBuffer _buffer; // The current buffer in use (either _header or _content) private int _mark = -1; private String _cached; private String _tok0 = ""; // Saved token: header name, request method or response version @@ -67,7 +67,7 @@ private int _responseStatus; // If >0 then we are parsing a response private boolean _persistent; - private JBuffer _contentView = BufferUtil.EMPTY_BUFFER; // View of the content in the buffer for {@link Input} + private ByteBuffer _contentView = BufferUtil.EMPTY_BUFFER; // View of the content in the buffer for {@link Input} private int _state = STATE_START; private byte _eol; private int _length; @@ -77,7 +77,7 @@ private int _chunkPosition; private boolean _headResponse; - public HttpParser(JBuffer headerBuffer,JBuffer bodyBuffer, EndPoint endp, EventHandler handler) + public HttpParser(ByteBuffer headerBuffer,ByteBuffer bodyBuffer, EndPoint endp, EventHandler handler) { _header = headerBuffer; _header.limit(0); @@ -92,7 +92,7 @@ } private String sliceFromMark() { - JBuffer buf = _buffer.duplicate(); + ByteBuffer buf = _buffer.duplicate(); buf.position(_mark); buf.limit(_buffer.position()-1); _mark = -1; @@ -116,8 +116,8 @@ } } - private JBuffer getBuffer(int length) { - JBuffer dup = _buffer.duplicate(); + private ByteBuffer getBuffer(int length) { + ByteBuffer dup = _buffer.duplicate(); int end = _buffer.position() + length; dup.limit(end); _buffer.position(end); @@ -129,7 +129,7 @@ } private String bufferToString(int index, int length) { - JBuffer dup = _buffer.duplicate(); + ByteBuffer dup = _buffer.duplicate(); dup.limit(index+length); dup.position(index); return BufferUtil.getString(dup); @@ -258,7 +258,7 @@ { if (_buffer.remaining()>0 && !_headResponse) { - JBuffer chunk = getBuffer(_buffer.remaining()); + ByteBuffer chunk = getBuffer(_buffer.remaining()); _contentPosition += chunk.remaining(); _contentView = chunk; _handler.content(); // May recurse here @@ -803,7 +803,7 @@ { case STATE_EOF_CONTENT: { - JBuffer chunk = getBuffer(_buffer.remaining()); + ByteBuffer chunk = getBuffer(_buffer.remaining()); _contentPosition += chunk.remaining(); _contentView = chunk; _handler.content(); // May recurse here @@ -828,7 +828,7 @@ length=(int)remaining; } - JBuffer chunk = getBuffer(length); + ByteBuffer chunk = getBuffer(length); _contentPosition += chunk.remaining(); _contentView = chunk; _handler.content(); // May recurse here @@ -919,7 +919,7 @@ } else if (length > remaining) length=remaining; - JBuffer chunk = getBuffer(length); + ByteBuffer chunk = getBuffer(length); _contentPosition += chunk.remaining(); _chunkPosition += chunk.remaining(); _contentView = chunk; @@ -1027,7 +1027,7 @@ _contentLength); } - public JBuffer blockForContent(long maxIdleTime) throws IOException + public ByteBuffer blockForContent(long maxIdleTime) throws IOException { if (_contentView.remaining()>0) return _contentView;
--- a/src/org/eclipse/jetty/io/BufferUtil.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/io/BufferUtil.java Thu Nov 10 03:08:20 2016 -0700 @@ -70,7 +70,7 @@ throw new NumberFormatException(s); } - public static void putHexInt(JBuffer buffer, int n) + public static void putHexInt(ByteBuffer buffer, int n) { if (n < 0) @@ -118,7 +118,7 @@ } } - public static void putDecLong(JBuffer buffer, long n) + public static void putDecLong(ByteBuffer buffer, long n) { if (n < 0) { @@ -195,43 +195,24 @@ - public static final JBuffer EMPTY_BUFFER = new JBuffer(ByteBuffer.allocate(0)); - - public static JBuffer wrap(byte[] array,int offset,int length) { - return new JBuffer(ByteBuffer.wrap(array,offset,length)); - } + public static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate(0); - public static JBuffer wrap(byte[] array) { - return new JBuffer(ByteBuffer.wrap(array)); - } - - public static JBuffer wrap(String s) { + public static ByteBuffer wrap(String s) { byte[] bytes = StringUtil.getBytes(s); - ByteBuffer bb = ByteBuffer.wrap(bytes).asReadOnlyBuffer(); - return new JBuffer(bb); - } - - public static JBuffer newBuffer(int size) { - ByteBuffer bb = ByteBuffer.allocate(size); - return new JBuffer(bb); - } - - public static JBuffer newDirectBuffer(int size) { - ByteBuffer bb = ByteBuffer.allocateDirect(size); - return new JBuffer(bb); + return ByteBuffer.wrap(bytes).asReadOnlyBuffer(); } private static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); - public static String getString(JBuffer buffer) { + public static String getString(ByteBuffer buffer) { byte[] bytes = new byte[buffer.remaining()]; buffer.get(bytes); return new String(bytes,ISO_8859_1); } - public static void compact(JBuffer buffer) { + public static void compact(ByteBuffer buffer) { buffer.compact(); buffer.limit(buffer.position()); buffer.position(0);
--- a/src/org/eclipse/jetty/io/Buffers.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/io/Buffers.java Thu Nov 10 03:08:20 2016 -0700 @@ -18,6 +18,8 @@ package org.eclipse.jetty.io; +import java.nio.ByteBuffer; + /* ------------------------------------------------------------ */ /** BufferSource. @@ -28,7 +30,7 @@ */ public interface Buffers { - JBuffer getHeader(); - JBuffer getBuffer(); - JBuffer getBuffer(int size); + ByteBuffer getHeader(); + ByteBuffer getBuffer(); + ByteBuffer getBuffer(int size); }
--- a/src/org/eclipse/jetty/io/EndPoint.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/io/EndPoint.java Thu Nov 10 03:08:20 2016 -0700 @@ -19,6 +19,7 @@ package org.eclipse.jetty.io; import java.io.IOException; +import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; @@ -55,7 +56,7 @@ * filled or -1 if EOF is reached. * @throws EofException If input is shutdown or the endpoint is closed. */ - int fill(JBuffer buffer) throws IOException; + int fill(ByteBuffer buffer) throws IOException; /** @@ -68,7 +69,7 @@ * @return the number of bytes written * @throws EofException If the endpoint is closed or output is shutdown. */ - int flush(JBuffer buffer) throws IOException; + int flush(ByteBuffer buffer) throws IOException; /** * Flush the buffer from the current getIndex to it's putIndex using whatever byte @@ -83,7 +84,7 @@ * @param trailer A buffer to write after flushing this buffer. This buffers getIndex is updated. * @return the total number of bytes written. */ - int flush(JBuffer header, JBuffer buffer, JBuffer trailer) throws IOException; + int flush(ByteBuffer header, ByteBuffer buffer, ByteBuffer trailer) throws IOException; /* ------------------------------------------------------------ */
--- a/src/org/eclipse/jetty/io/JBuffer.java Thu Nov 10 02:37:15 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -// tmp class to implement Buffer until I can get rid of it - -package org.eclipse.jetty.io; - -import java.io.InputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.eclipse.jetty.util.TypeUtil; - - -public final class JBuffer { - private static final Logger LOG = LoggerFactory.getLogger(JBuffer.class); - - private final ByteBuffer bb; - - public JBuffer(ByteBuffer bb) { - this.bb = bb; - } - - public int position() { - return bb.position(); - } - - public void position(int i) { - bb.position(i); - } - - public int limit() { - return bb.limit(); - } - - public void limit(int i) { - bb.limit(i); - } - - public byte[] array() { - return bb.array(); - } - - public boolean hasArray() { - return bb.hasArray(); - } - - public JBuffer duplicate() { - return new JBuffer(bb.duplicate()); - } - - public int remaining() { - return bb.remaining(); - } - - public boolean isReadOnly() { - return bb.isReadOnly(); - } - - public boolean hasRemaining() { - return bb.hasRemaining(); - } - - public byte get() { - return bb.get(); - } - - public void get(byte[] bytes) { - bb.get(bytes); - } - - public void compact() { - bb.compact(); - } - - public int capacity() { - return bb.capacity(); - } - - - - public ByteBuffer getByteBuffer() { - return bb; - } - - public void clear() { - bb.clear(); - } - - - public void get(byte[] b, int offset, int length) { - bb.get(b,offset,length); - } - - - public void put(JBuffer src) { - bb.put(src.bb); - } - - public void put(byte b) { - bb.put(b); - } - - public void put(byte[] b) { - bb.put(b); - } - -/* - @Override - public String toString() { -// return toString("ISO-8859-1"); -// Thread.dumpStack(); - throw new RuntimeException("toString"); - } -*/ - - public byte get(int index) { - return bb.get(index); - } - - public void flip() { - bb.flip(); - } - -}
--- a/src/org/eclipse/jetty/io/nio/ChannelEndPoint.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/io/nio/ChannelEndPoint.java Thu Nov 10 03:08:20 2016 -0700 @@ -27,7 +27,6 @@ import java.nio.channels.GatheringByteChannel; import java.nio.channels.SocketChannel; -import org.eclipse.jetty.io.JBuffer; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.StringUtil; import org.slf4j.Logger; @@ -163,12 +162,12 @@ } @Override - public int fill(JBuffer buffer) throws IOException + public int fill(ByteBuffer buffer) throws IOException { if (_ishut) return -1; int len = 0; - final ByteBuffer bbuf = buffer.getByteBuffer().duplicate(); + final ByteBuffer bbuf = buffer.duplicate(); //noinspection SynchronizationOnLocalVariableOrMethodParameter try @@ -208,14 +207,13 @@ } @Override - public int flush(JBuffer buffer) throws IOException + public int flush(ByteBuffer buffer) throws IOException { - final ByteBuffer bbuf = buffer.getByteBuffer(); - return _channel.write(bbuf); + return _channel.write(buffer); } @Override - public int flush(JBuffer header, JBuffer buffer, JBuffer trailer) throws IOException + public int flush(ByteBuffer header, ByteBuffer buffer, ByteBuffer trailer) throws IOException { int length=0; @@ -246,11 +244,9 @@ return length; } - private synchronized int gatheringFlush(JBuffer header, JBuffer buffer) throws IOException + private synchronized int gatheringFlush(ByteBuffer header, ByteBuffer buffer) throws IOException { - ByteBuffer bbuf0 = header.getByteBuffer(); - ByteBuffer bbuf1 = buffer.getByteBuffer(); - return (int)_channel.write(new ByteBuffer[]{bbuf0,bbuf1}); + return (int)_channel.write(new ByteBuffer[]{header,buffer}); } public final SocketChannel getChannel()
--- a/src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java Thu Nov 10 03:08:20 2016 -0700 @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InterruptedIOException; +import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; @@ -28,7 +29,6 @@ import java.util.concurrent.RejectedExecutionException; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.JBuffer; import org.eclipse.jetty.io.EofException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -157,14 +157,14 @@ } @Override - public int fill(JBuffer buffer) throws IOException + public int fill(ByteBuffer buffer) throws IOException { int fill=super.fill(buffer); return fill; } @Override - public int flush(JBuffer header, JBuffer buffer, JBuffer trailer) throws IOException + public int flush(ByteBuffer header, ByteBuffer buffer, ByteBuffer trailer) throws IOException { int l = super.flush(header, buffer, trailer); @@ -186,7 +186,7 @@ } @Override - public int flush(JBuffer buffer) throws IOException + public int flush(ByteBuffer buffer) throws IOException { int l = super.flush(buffer);
--- a/src/org/eclipse/jetty/io/nio/SslConnection.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/io/nio/SslConnection.java Thu Nov 10 03:08:20 2016 -0700 @@ -30,7 +30,6 @@ import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.JBuffer; import org.eclipse.jetty.io.BufferUtil; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.server.AsyncHttpConnection; @@ -51,7 +50,7 @@ { private final Logger _logger = LoggerFactory.getLogger("org.eclipse.jetty.io.nio.ssl"); - private static final JBuffer __ZERO_BUFFER = BufferUtil.EMPTY_BUFFER; + private static final ByteBuffer __ZERO_BUFFER = BufferUtil.EMPTY_BUFFER; private static final ThreadLocal<SslBuffers> __buffers = new ThreadLocal<SslBuffers>(); private final SSLEngine _engine; @@ -60,9 +59,9 @@ private final SslEndPoint _sslEndPoint; private int _allocations; private SslBuffers _buffers; - private JBuffer _inbound; - private JBuffer _unwrapBuf; - private JBuffer _outbound; + private ByteBuffer _inbound; + private ByteBuffer _unwrapBuf; + private ByteBuffer _outbound; private final AsyncEndPoint _aEndp; private boolean _allowRenegotiate = true; private boolean _handshook; @@ -75,17 +74,17 @@ */ private static class SslBuffers { - final JBuffer _in; - final JBuffer _out; - final JBuffer _unwrap; + final ByteBuffer _in; + final ByteBuffer _out; + final ByteBuffer _unwrap; SslBuffers(int packetSize, int appSize) { - _in = BufferUtil.newBuffer(packetSize); + _in = ByteBuffer.allocate(packetSize); _in.limit(0); - _out = BufferUtil.newBuffer(packetSize); + _out = ByteBuffer.allocate(packetSize); _out.limit(0); - _unwrap = BufferUtil.newBuffer(appSize); + _unwrap = ByteBuffer.allocate(appSize); _unwrap.limit(0); } } @@ -212,15 +211,15 @@ { } - private void put_unwrapBuf(JBuffer toFill) { - JBuffer dup = toFill.duplicate(); + private void put_unwrapBuf(ByteBuffer toFill) { + ByteBuffer dup = toFill.duplicate(); dup.position(dup.limit()); dup.limit(dup.capacity()); dup.put(_unwrapBuf); toFill.limit(dup.position()); } - private synchronized boolean process(JBuffer toFill, JBuffer toFlush) throws IOException + private synchronized boolean process(ByteBuffer toFill, ByteBuffer toFlush) throws IOException { boolean some_progress=false; try @@ -389,22 +388,21 @@ } } - private synchronized boolean wrap(final JBuffer buffer) throws IOException + private synchronized boolean wrap(final ByteBuffer buffer) throws IOException { - ByteBuffer bbuf = buffer.getByteBuffer(); final SSLEngineResult result; - synchronized(bbuf) + synchronized(buffer) { BufferUtil.compact(_outbound); - ByteBuffer out_buffer = _outbound.getByteBuffer().duplicate(); + ByteBuffer out_buffer = _outbound.duplicate(); synchronized(out_buffer) { try { out_buffer.position(_outbound.limit()); out_buffer.limit(out_buffer.capacity()); - result = _engine.wrap(bbuf,out_buffer); + result = _engine.wrap(buffer,out_buffer); if (_logger.isDebugEnabled()) _logger.debug("{} wrap {} {} consumed={} produced={}", _session, @@ -451,25 +449,24 @@ return result.bytesConsumed()>0 || result.bytesProduced()>0; } - private synchronized boolean unwrap(final JBuffer buffer) throws IOException + private synchronized boolean unwrap(final ByteBuffer buffer) throws IOException { if (!_inbound.hasRemaining()) return false; - ByteBuffer bbuf = buffer.getByteBuffer().duplicate(); + ByteBuffer bbuf = buffer.duplicate(); final SSLEngineResult result; synchronized(bbuf) { - ByteBuffer in_buffer = _inbound.getByteBuffer(); - synchronized(in_buffer) + synchronized(_inbound) { try { bbuf.position(buffer.limit()); bbuf.limit(buffer.capacity()); - result=_engine.unwrap(in_buffer,bbuf); + result=_engine.unwrap(_inbound,bbuf); if (_logger.isDebugEnabled()) _logger.debug("{} unwrap {} {} consumed={} produced={}", _session, @@ -587,7 +584,7 @@ _endp.close(); } - public int fill(JBuffer buffer) throws IOException + public int fill(ByteBuffer buffer) throws IOException { int size = buffer.remaining(); process(buffer, null); @@ -599,14 +596,14 @@ return filled; } - public int flush(JBuffer buffer) throws IOException + public int flush(ByteBuffer buffer) throws IOException { int size = buffer.remaining(); process(null, buffer); return size-buffer.remaining(); } - public int flush(JBuffer header, JBuffer buffer, JBuffer trailer) throws IOException + public int flush(ByteBuffer header, ByteBuffer buffer, ByteBuffer trailer) throws IOException { if (header!=null && header.hasRemaining()) return flush(header); @@ -718,9 +715,9 @@ // Do NOT use synchronized (SslConnection.this) // because it's very easy to deadlock when debugging is enabled. // We do a best effort to print the right toString() and that's it. - JBuffer inbound = _inbound; - JBuffer outbound = _outbound; - JBuffer unwrap = _unwrapBuf; + ByteBuffer inbound = _inbound; + ByteBuffer outbound = _outbound; + ByteBuffer unwrap = _unwrapBuf; int i = inbound == null? -1 : inbound.remaining(); int o = outbound == null ? -1 : outbound.remaining(); int u = unwrap == null ? -1 : unwrap.remaining();
--- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java Thu Nov 10 03:08:20 2016 -0700 @@ -43,7 +43,6 @@ import org.eclipse.jetty.http.HttpVersions; import org.eclipse.jetty.http.MimeTypes; import org.eclipse.jetty.io.AbstractConnection; -import org.eclipse.jetty.io.JBuffer; import org.eclipse.jetty.io.Buffers; import org.eclipse.jetty.io.BufferUtil; import org.eclipse.jetty.io.EndPoint; @@ -707,7 +706,7 @@ public final class Output extends ServletOutputStream { private boolean _closed; - private JBuffer _onebyte; + private ByteBuffer _onebyte; // These are held here for reuse by Writer String _characterEncoding; @@ -723,27 +722,27 @@ @Override public final void write(byte[] b, int off, int len) throws IOException { - write(BufferUtil.wrap(b,off,len)); + write(ByteBuffer.wrap(b,off,len)); } @Override public final void write(byte[] b) throws IOException { - write(BufferUtil.wrap(b)); + write(ByteBuffer.wrap(b)); } @Override public final void write(int b) throws IOException { if (_onebyte==null) - _onebyte = BufferUtil.newBuffer(1); + _onebyte = ByteBuffer.allocate(1); else _onebyte.clear(); _onebyte.put((byte)b); write(_onebyte); } - private void write(JBuffer buffer) throws IOException + private void write(ByteBuffer buffer) throws IOException { if (_closed) throw new IOException("Closed"); @@ -837,14 +836,13 @@ try { ReadableByteChannel chan = Channels.newChannel(in); - JBuffer buffer = _generator.getUncheckedBuffer(); - ByteBuffer bb = buffer.getByteBuffer(); + ByteBuffer buffer = _generator.getUncheckedBuffer(); while (true) { _generator.prepareUncheckedAddContent(); - int n = chan.read(bb); + int n = chan.read(buffer); if( n == -1 ) break; @@ -884,7 +882,7 @@ @Override public int read(byte[] b, int off, int len) throws IOException { - JBuffer content = _parser.blockForContent(getMaxIdleTime()); + ByteBuffer content = _parser.blockForContent(getMaxIdleTime()); if (content!=null) { int remaining = content.remaining(); if( remaining == 0 )
--- a/src/org/eclipse/jetty/server/Connector.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/server/Connector.java Thu Nov 10 03:08:20 2016 -0700 @@ -22,13 +22,13 @@ import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; +import java.nio.ByteBuffer; import java.nio.channels.ServerSocketChannel; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.atomic.AtomicLong; import javax.servlet.ServletRequest; -import org.eclipse.jetty.io.JBuffer; import org.eclipse.jetty.io.Buffers; import org.eclipse.jetty.io.BufferUtil; import org.eclipse.jetty.io.EndPoint; @@ -43,7 +43,7 @@ * <ul> * <li>AbstractLifeCycle implementation</li> * <li>Implementations for connector getters and setters</li> - * <li>JBuffer management</li> + * <li>ByteBuffer management</li> * <li>Socket configuration</li> * <li>Base acceptor thread</li> * <li>Optional reverse proxy headers checking</li> @@ -251,8 +251,8 @@ // my own buffers - protected JBuffer newBuffer(int size) { - return BufferUtil.newDirectBuffer(size); + protected ByteBuffer newBuffer(int size) { + return ByteBuffer.allocateDirect(size); } private class MyBuffers implements Buffers { @@ -265,17 +265,17 @@ } @Override - public JBuffer getHeader() { - return BufferUtil.newBuffer(headerSize); + public ByteBuffer getHeader() { + return ByteBuffer.allocate(headerSize); } @Override - public JBuffer getBuffer() { + public ByteBuffer getBuffer() { return newBuffer(bufferSize); } @Override - public JBuffer getBuffer(int size) { + public ByteBuffer getBuffer(int size) { return newBuffer(size); } }
--- a/src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java Thu Nov 10 03:08:20 2016 -0700 @@ -21,6 +21,7 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; +import java.nio.ByteBuffer; import java.nio.channels.ByteChannel; import java.nio.channels.SelectionKey; import java.nio.channels.ServerSocketChannel; @@ -30,7 +31,6 @@ import java.util.concurrent.RejectedExecutionException; import org.eclipse.jetty.http.HttpException; -import org.eclipse.jetty.io.JBuffer; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.io.nio.ChannelEndPoint; @@ -171,21 +171,21 @@ } @Override - public int fill(JBuffer buffer) throws IOException + public int fill(ByteBuffer buffer) throws IOException { _idleTimestamp = System.currentTimeMillis(); return super.fill(buffer); } @Override - public int flush(JBuffer buffer) throws IOException + public int flush(ByteBuffer buffer) throws IOException { _idleTimestamp = System.currentTimeMillis(); return super.flush(buffer); } @Override - public int flush(JBuffer header, JBuffer buffer, JBuffer trailer) throws IOException + public int flush(ByteBuffer header, ByteBuffer buffer, ByteBuffer trailer) throws IOException { _idleTimestamp = System.currentTimeMillis(); return super.flush(header,buffer,trailer);
--- a/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java Thu Nov 10 02:37:15 2016 -0700 +++ b/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java Thu Nov 10 03:08:20 2016 -0700 @@ -19,6 +19,7 @@ package org.eclipse.jetty.server.ssl; import java.io.IOException; +import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; import javax.net.ssl.SSLContext; @@ -27,7 +28,6 @@ import javax.net.ssl.SSLSocket; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.JBuffer; import org.eclipse.jetty.io.Buffers; import org.eclipse.jetty.io.BufferUtil; import org.eclipse.jetty.io.EndPoint; @@ -75,8 +75,8 @@ } @Override - protected JBuffer newBuffer(int size) { - return BufferUtil.newBuffer(size); + protected ByteBuffer newBuffer(int size) { + return ByteBuffer.allocate(size); }