Mercurial Hosting > luan
changeset 1031:921c25a05eaa
remove Buffer.asReadOnlyBuffer()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 03 Nov 2016 02:04:40 -0600 |
parents | 80cad9086593 |
children | eca26899c4bc |
files | src/org/eclipse/jetty/http/AbstractGenerator.java src/org/eclipse/jetty/io/AbstractBuffer.java src/org/eclipse/jetty/io/Buffer.java src/org/eclipse/jetty/io/View.java src/org/eclipse/jetty/io/nio/ChannelEndPoint.java src/org/eclipse/jetty/server/handler/ResourceHandler.java |
diffstat | 6 files changed, 6 insertions(+), 105 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/AbstractGenerator.java Thu Nov 03 01:10:09 2016 -0600 +++ b/src/org/eclipse/jetty/http/AbstractGenerator.java Thu Nov 03 02:04:40 2016 -0600 @@ -25,7 +25,6 @@ import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EofException; -import org.eclipse.jetty.io.View; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -245,7 +244,7 @@ // TODO don't hard code if (len>1024) len=1024; - _reason=new ByteArrayBuffer(len); + _reason = new ByteArrayBuffer(len); for (int i=0;i<len;i++) { char ch = reason.charAt(i); @@ -365,12 +364,12 @@ if (content != null) { completeHeader(null, false); - addContent(new View(new ByteArrayBuffer(content)), LAST); + addContent(new ByteArrayBuffer(content), LAST); } else if (code>=400) { completeHeader(null, false); - addContent(new View(new ByteArrayBuffer("Error: "+(reason==null?(""+code):reason))), LAST); + addContent(new ByteArrayBuffer("Error: "+(reason==null?(""+code):reason)), LAST); } else {
--- a/src/org/eclipse/jetty/io/AbstractBuffer.java Thu Nov 03 01:10:09 2016 -0600 +++ b/src/org/eclipse/jetty/io/AbstractBuffer.java Thu Nov 03 02:04:40 2016 -0600 @@ -37,11 +37,7 @@ private final static boolean __boundsChecking = Boolean.getBoolean("org.eclipse.jetty.io.AbstractBuffer.boundsChecking"); - protected final static String - __IMMUTABLE = "IMMUTABLE", - __READONLY = "READONLY", - __READWRITE = "READWRITE", - __VOLATILE = "VOLATILE"; + protected final static String __READONLY = "READONLY"; protected int _access; @@ -61,15 +57,10 @@ */ protected AbstractBuffer(int access) { -// if (access == IMMUTABLE && isVolatile) -// throw new IllegalArgumentException("IMMUTABLE && VOLATILE"); setMarkIndex(-1); _access = access; } - /* - * @see org.eclipse.io.Buffer#toArray() - */ public byte[] asArray() { byte[] bytes = new byte[length()]; @@ -81,20 +72,6 @@ return bytes; } - private ByteArrayBuffer duplicate(int access) - { - return new ByteArrayBuffer(asArray(), 0, length(), access); - } - - /* - * @see org.eclipse.util.Buffer#asReadOnlyBuffer() - */ - public Buffer asReadOnlyBuffer() - { - if (isReadOnly()) return this; - return new View(this, markIndex(), getIndex(), putIndex(), READONLY); - } - public Buffer buffer() { return this; @@ -292,12 +269,6 @@ public int poke(int index, Buffer src) { _hash=0; - /* - if (isReadOnly()) - throw new IllegalStateException(__READONLY); - if (index < 0) - throw new IllegalArgumentException("index<0: " + index + "<0"); - */ int length=src.length(); if (index + length > capacity()) @@ -339,12 +310,6 @@ public int poke(int index, byte[] b, int offset, int length) { _hash=0; - /* - if (isReadOnly()) - throw new IllegalStateException(__READONLY); - if (index < 0) - throw new IllegalArgumentException("index<0: " + index + "<0"); - */ if (index + length > capacity()) { length=capacity()-index; @@ -414,37 +379,17 @@ public void setGetIndex(int getIndex) { - /* bounds checking - if (isImmutable()) - throw new IllegalStateException(__IMMUTABLE); - if (getIndex < 0) - throw new IllegalArgumentException("getIndex<0: " + getIndex + "<0"); - if (getIndex > putIndex()) - throw new IllegalArgumentException("getIndex>putIndex: " + getIndex + ">" + putIndex()); - */ _get = getIndex; _hash=0; } public void setMarkIndex(int index) { - /* - if (index>=0 && isImmutable()) - throw new IllegalStateException(__IMMUTABLE); - */ _mark = index; } public void setPutIndex(int putIndex) { - /* bounds checking - if (isImmutable()) - throw new IllegalStateException(__IMMUTABLE); - if (putIndex > capacity()) - throw new IllegalArgumentException("putIndex>capacity: " + putIndex + ">" + capacity()); - if (getIndex() > putIndex) - throw new IllegalArgumentException("getIndex>putIndex: " + getIndex() + ">" + putIndex); - */ _put = putIndex; _hash=0; }
--- a/src/org/eclipse/jetty/io/Buffer.java Thu Nov 03 01:10:09 2016 -0600 +++ b/src/org/eclipse/jetty/io/Buffer.java Thu Nov 03 02:04:40 2016 -0600 @@ -66,12 +66,6 @@ Buffer buffer(); /** - * - * @return a readonly version of this <code>Buffer</code>. - */ - Buffer asReadOnlyBuffer(); - - /** * * The capacity of the buffer. This is the maximum putIndex that may be set. * @return an <code>int</code> value
--- a/src/org/eclipse/jetty/io/View.java Thu Nov 03 01:10:09 2016 -0600 +++ b/src/org/eclipse/jetty/io/View.java Thu Nov 03 02:04:40 2016 -0600 @@ -46,16 +46,6 @@ _access=access; } - public View(Buffer buffer) - { - super(READWRITE); - _buffer=buffer.buffer(); - setPutIndex(buffer.putIndex()); - setGetIndex(buffer.getIndex()); - setMarkIndex(buffer.markIndex()); - _access=buffer.isReadOnly()?READONLY:READWRITE; - } - public View() { super(READWRITE); @@ -142,7 +132,7 @@ { return _buffer.peek(index, length); } - + @Override public int poke(int index, Buffer src) {
--- a/src/org/eclipse/jetty/io/nio/ChannelEndPoint.java Thu Nov 03 01:10:09 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/ChannelEndPoint.java Thu Nov 03 02:04:40 2016 -0600 @@ -234,7 +234,7 @@ if (buf instanceof NIOBuffer) { final NIOBuffer nbuf = (NIOBuffer)buf; - final ByteBuffer bbuf=nbuf.getByteBuffer().asReadOnlyBuffer(); + final ByteBuffer bbuf = nbuf.getByteBuffer().asReadOnlyBuffer(); try { bbuf.position(buffer.getIndex());
--- a/src/org/eclipse/jetty/server/handler/ResourceHandler.java Thu Nov 03 01:10:09 2016 -0600 +++ b/src/org/eclipse/jetty/server/handler/ResourceHandler.java Thu Nov 03 02:04:40 2016 -0600 @@ -30,8 +30,6 @@ import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.MimeTypes; -import org.eclipse.jetty.io.Buffer; -import org.eclipse.jetty.io.ByteArrayBuffer; import org.eclipse.jetty.io.WriterOutputStream; import org.eclipse.jetty.server.AbstractHttpConnection; import javax.servlet.RequestDispatcher; @@ -63,7 +61,6 @@ Resource _stylesheet; String[] _welcomeFiles={"index.html"}; MimeTypes _mimeTypes = new MimeTypes(); - ByteArrayBuffer _cacheControl; boolean _aliases; boolean _directory; @@ -233,24 +230,6 @@ } } - /* ------------------------------------------------------------ */ - /** - * @return the cacheControl header to set on all static content. - */ - public String getCacheControl() - { - return _cacheControl.toString(); - } - - /* ------------------------------------------------------------ */ - /** - * @param cacheControl the cacheControl header to set on all static content. - */ - public void setCacheControl(String cacheControl) - { - _cacheControl=cacheControl==null?null:new ByteArrayBuffer(cacheControl); - } - private Resource getResource(Request request) throws MalformedURLException { String path = request.getPathInfo(); @@ -448,17 +427,11 @@ if (length>0) fields.putLongField(HttpHeaders.CONTENT_LENGTH,length); - - if (_cacheControl!=null) - fields.put(HttpHeaders.CACHE_CONTROL,_cacheControl.toString()); } else { if (length>0) response.setHeader(HttpHeaders.CONTENT_LENGTH,Long.toString(length)); - - if (_cacheControl!=null) - response.setHeader(HttpHeaders.CACHE_CONTROL,_cacheControl.toString()); } }