From 722f39080072328301279dceb1c74b4c83b5035f Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 15 Nov 2011 11:22:35 +1100 Subject: [PATCH] numerous findbugs inspired cleanups --- .../jetty/http/HttpGeneratorClientTest.java | 2 +- .../eclipse/jetty/http/HttpGeneratorTest.java | 2 +- .../org/eclipse/jetty/io/BufferDateCache.java | 1 - .../jetty/io/nio/SelectChannelEndPoint.java | 7 +++++-- .../eclipse/jetty/io/nio/SslConnection.java | 15 +++++++++++---- .../jetty/server/AbstractConnector.java | 6 +++++- .../eclipse/jetty/server/NCSARequestLog.java | 2 +- .../jetty/server/handler/ContextHandler.java | 15 ++++++++++++--- .../jetty/server/handler/DefaultHandler.java | 4 ---- .../jetty/server/handler/GzipHandler.java | 6 +++--- .../server/handler/MovedContextHandler.java | 10 +++------- .../jetty/server/handler/ResourceHandler.java | 1 - .../server/nio/BlockingChannelConnector.java | 12 ++++++++---- .../server/nio/SelectChannelConnector.java | 19 ++++++++++++++----- .../jetty/server/session/AbstractSession.java | 5 ++++- .../session/AbstractSessionIdManager.java | 2 +- .../jetty/server/ConnectorTimeoutTest.java | 6 ++---- .../org/eclipse/jetty/server/DumpHandler.java | 3 +-- .../jetty/server/EncodedHttpURITest.java | 2 +- .../jetty/server/HttpConnectionTest.java | 12 ++++++------ .../jetty/server/HttpServerTestBase.java | 10 +++++----- .../jetty/server/HttpServerTestFixture.java | 4 ++-- .../eclipse/jetty/server/ResponseTest.java | 1 - .../org/eclipse/jetty/server/StressTest.java | 2 -- .../jetty/server/ssl/SslRenegotiateTest.java | 2 +- .../jetty/server/ssl/SslUploadTest.java | 3 +++ .../org/eclipse/jetty/util/DateCache.java | 4 ++-- .../org/eclipse/jetty/util/StringUtil.java | 2 +- .../org/eclipse/jetty/util/UrlEncoded.java | 2 +- .../org/eclipse/jetty/util/ajax/JSON.java | 2 +- .../jetty/util/resource/JarResource.java | 1 - .../ajax/JSONPojoConvertorFactoryTest.java | 2 +- .../org/eclipse/jetty/util/ajax/JSONTest.java | 2 +- .../util/component/LifeCycleListenerTest.java | 2 +- 34 files changed, 98 insertions(+), 73 deletions(-) diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorClientTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorClientTest.java index 725983cf438..18012e950f5 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorClientTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorClientTest.java @@ -193,7 +193,7 @@ public class HttpGeneratorClientTest } private static final String[] headers= { "Content-Type","Content-Length","Connection","Transfer-Encoding","Other"}; - private class TR + private static class TR { private String[] values=new String[headers.length]; private String body; diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorTest.java index f8ed28fa545..bceb1541e9d 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorTest.java @@ -138,7 +138,7 @@ public class HttpGeneratorTest } private static final String[] headers= { "Content-Type","Content-Length","Connection","Transfer-Encoding","Other"}; - private class TR + private static class TR { private int _code; private String _body; diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/BufferDateCache.java b/jetty-io/src/main/java/org/eclipse/jetty/io/BufferDateCache.java index c1aebb88829..275d2f3b77d 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/BufferDateCache.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/BufferDateCache.java @@ -46,7 +46,6 @@ public class BufferDateCache extends DateCache public synchronized Buffer formatBuffer(long date) { String d = super.format(date); - //noinspection StringEquality if (d==_last) return _buffer; _last=d; diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 5cdf8e25358..ee06f0c5f3f 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -462,13 +462,15 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo */ private void updateKey() { - int current_ops=-1; + final boolean changed; synchronized (this) { + int current_ops=-1; if (getChannel().isOpen()) { boolean read_interest = _readBlocked || (!_dispatched && !_connection.isSuspended()); boolean write_interest= _writeBlocked || (!_dispatched && !_writable); + _interestOps = ((!_socket.isInputShutdown() && read_interest ) ? SelectionKey.OP_READ : 0) | ((!_socket.isOutputShutdown()&& write_interest) ? SelectionKey.OP_WRITE : 0); @@ -482,9 +484,10 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo LOG.ignore(e); } } + changed=_interestOps!=current_ops; } - if(_interestOps != current_ops) + if(changed) { _selectSet.addChange(this); _selectSet.wakeup(); diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index 771db4e5bb5..7dfc5b6fe1e 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -658,7 +658,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection while (now",">"); writer.write("\n\nError 404 - Not Found"); writer.write("\n\n

Error 404 - Not Found.

\n"); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/GzipHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/GzipHandler.java index 29a9a833932..81198f5299d 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/GzipHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/GzipHandler.java @@ -281,9 +281,9 @@ public class GzipHandler extends HandlerWrapper return new GzipResponseWrapper(request, response) { { - setMimeTypes(GzipHandler.this._mimeTypes); - setBufferSize(GzipHandler.this._bufferSize); - setMinGzipSize(GzipHandler.this._minGzipSize); + super.setMimeTypes(GzipHandler.this._mimeTypes); + super.setBufferSize(GzipHandler.this._bufferSize); + super.setMinGzipSize(GzipHandler.this._minGzipSize); } @Override diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/MovedContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/MovedContextHandler.java index 8650b80c9a1..6ff990c9c04 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/MovedContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/MovedContextHandler.java @@ -100,12 +100,6 @@ public class MovedContextHandler extends ContextHandler { if (_newContextURL==null) return; - - String url = _newContextURL; - if (!_discardPathInfo && request.getPathInfo()!=null) - url=URIUtil.addPaths(url, request.getPathInfo()); - if (!_discardQuery && request.getQueryString()!=null) - url+="?"+request.getQueryString(); String path=_newContextURL; if (!_discardPathInfo && request.getPathInfo()!=null) @@ -117,7 +111,9 @@ public class MovedContextHandler extends ContextHandler if (!_discardQuery && request.getQueryString()!=null) { location.append('?'); - location.append(request.getQueryString()); + String q=request.getQueryString(); + q=q.replaceAll("\r\n?&=","!"); + location.append(q); } response.setHeader(HttpHeaders.LOCATION,location.toString()); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java index 44ad95b29e6..2615ab8448f 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java @@ -309,7 +309,6 @@ public class ResourceHandler extends AbstractHandler } else { - included = Boolean.FALSE; servletPath = request.getServletPath(); pathInfo = request.getPathInfo(); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/BlockingChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/BlockingChannelConnector.java index a2b0e4d53f5..ebe605aec5e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/BlockingChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/BlockingChannelConnector.java @@ -207,7 +207,7 @@ public class BlockingChannelConnector extends AbstractNIOConnector { try { - close(); + super.close(); } catch (IOException e) { @@ -221,7 +221,7 @@ public class BlockingChannelConnector extends AbstractNIOConnector if (!getThreadPool().dispatch(this)) { LOG.warn("dispatch failed for {}",_connection); - BlockingChannelEndPoint.this.close(); + super.close(); } } @@ -302,13 +302,17 @@ public class BlockingChannelConnector extends AbstractNIOConnector catch (HttpException e) { LOG.debug("BAD", e); - try{BlockingChannelEndPoint.this.close();} + try{super.close();} catch(IOException e2){LOG.ignore(e2);} } + catch(ThreadDeath e) + { + throw e; + } catch(Throwable e) { LOG.warn("handle failed",e); - try{BlockingChannelEndPoint.this.close();} + try{super.close();} catch(IOException e2){LOG.ignore(e2);} } finally diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java index 9d9867a4122..f59e3135538 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java @@ -92,10 +92,15 @@ public class SelectChannelConnector extends AbstractNIOConnector @Override public void accept(int acceptorID) throws IOException { - ServerSocketChannel server = _acceptChannel; + ServerSocketChannel server; + synchronized(this) + { + server = _acceptChannel; + } + if (server!=null && server.isOpen() && _manager.isStarted()) { - SocketChannel channel = _acceptChannel.accept(); + SocketChannel channel = server.accept(); channel.configureBlocking(false); Socket socket = channel.socket(); configure(socket); @@ -141,7 +146,7 @@ public class SelectChannelConnector extends AbstractNIOConnector } /* ------------------------------------------------------------ */ - public Object getConnection() + public synchronized Object getConnection() { return _acceptChannel; } @@ -299,11 +304,15 @@ public class SelectChannelConnector extends AbstractNIOConnector public void dump(Appendable out, String indent) throws IOException { out.append(String.valueOf(this)).append("\n"); - ServerSocketChannel channel=_acceptChannel; + ServerSocketChannel channel; + synchronized (this) + { + channel=_acceptChannel; + } if (channel==null) AggregateLifeCycle.dump(out,indent,Arrays.asList(new Object[]{null,"CLOSED",_manager})); else - AggregateLifeCycle.dump(out,indent,Arrays.asList(new Object[]{_acceptChannel,_acceptChannel.isOpen()?"OPEN":"CLOSED",_manager})); + AggregateLifeCycle.dump(out,indent,Arrays.asList(new Object[]{channel,channel.isOpen()?"OPEN":"CLOSED",_manager})); } /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java index f231f8bea10..73a4b6f81b8 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSession.java @@ -457,7 +457,10 @@ public abstract class AbstractSession implements AbstractSessionManager.SessionI /* ------------------------------------------------------------- */ protected void cookieSet() { - _cookieSet=_accessed; + synchronized (this) + { + _cookieSet=_accessed; + } } /* ------------------------------------------------------------ */ diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java index d0c53610c5b..d93fc79c694 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/AbstractSessionIdManager.java @@ -78,7 +78,7 @@ public abstract class AbstractSessionIdManager extends AbstractLifeCycle impleme } /* ------------------------------------------------------------ */ - public void setRandom(Random random) + public synchronized void setRandom(Random random) { _random=random; _weakRandom=false; diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java index 26caaa934b5..7b2e2b5650e 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ConnectorTimeoutTest.java @@ -54,8 +54,6 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture OutputStream os=client.getOutputStream(); InputStream is=client.getInputStream(); - String content="Wibble"; - byte[] contentB=content.getBytes("utf-8"); os.write(( "GET / HTTP/1.0\r\n"+ "host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+ @@ -64,7 +62,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture os.flush(); long start = System.currentTimeMillis(); - String in = IO.toString(is); + IO.toString(is); Thread.sleep(300); assertEquals(-1, is.read()); @@ -97,7 +95,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture os.flush(); long start = System.currentTimeMillis(); - String in = IO.toString(is); + IO.toString(is); Thread.sleep(300); assertEquals(-1, is.read()); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java b/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java index adaf8751b28..301c352899a 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/DumpHandler.java @@ -151,8 +151,7 @@ public class DumpHandler extends AbstractHandler String val=request.getParameter("CookieVal"); val=val.replaceAll("[ \n\r=<>]","?"); Cookie cookie= - new Cookie(cookie_name.trim(), - request.getParameter("CookieVal")); + new Cookie(cookie_name.trim(),val); if ("Clear Cookie".equals(cookie_action)) cookie.setMaxAge(0); response.addCookie(cookie); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/EncodedHttpURITest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/EncodedHttpURITest.java index f5afdb662be..b73c3fdbc5c 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/EncodedHttpURITest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/EncodedHttpURITest.java @@ -28,7 +28,7 @@ public class EncodedHttpURITest { String url = "http://www.foo.com/ma\u00F1ana"; byte[] asISO = url.getBytes("ISO-8859-1"); - String str = new String(asISO, "ISO-8859-1"); + new String(asISO, "ISO-8859-1"); //use a non UTF-8 charset as the encoding and url-escape as per //http://www.w3.org/TR/html40/appendix/notes.html#non-ascii-chars diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java index cdaac741412..67207366582 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java @@ -123,7 +123,7 @@ public class HttpConnectionTest int offset=0; offset = checkContains(response,offset,"HTTP/1.1 200"); - offset = checkContains(response,offset,"/R1"); + checkContains(response,offset,"/R1"); } @Test @@ -365,7 +365,7 @@ public class HttpConnectionTest "5;\015\012"+ "12345\015\012"+ "0;\015\012\015\012"); - offset = checkContains(response,offset,"Connection: close"); + checkContains(response,offset,"Connection: close"); } catch (Exception e) { @@ -394,7 +394,7 @@ public class HttpConnectionTest "Cookie: "+cookie+"\n"+ "\015\012" ); - offset = checkContains(response, offset, "HTTP/1.1 413"); + checkContains(response, offset, "HTTP/1.1 413"); } catch(Exception e) { @@ -423,7 +423,7 @@ public class HttpConnectionTest request.append("\015\012"); response = connector.getResponses(request.toString()); - offset = checkContains(response, offset, "HTTP/1.1 413"); + checkContains(response, offset, "HTTP/1.1 413"); } @Test @@ -469,7 +469,7 @@ public class HttpConnectionTest "\015\012" ); - offset = checkContains(response, offset, "HTTP/1.1 500"); + checkContains(response, offset, "HTTP/1.1 500"); } catch(Exception e) { @@ -548,7 +548,7 @@ public class HttpConnectionTest response=connector.getResponses("CONNECT www.webtide.com:8080 HTTP/1.1\n"+ "Host: myproxy:8888\015\012"+ "\015\012"); - offset = checkContains(response,offset,"HTTP/1.1 200"); + checkContains(response,offset,"HTTP/1.1 200"); } catch (Exception e) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java index bd0fd091e9f..0e6d953c275 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java @@ -160,7 +160,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture // Read the response. String response=readResponse(client); - assertTrue(true); // nothing checked yet. + assertTrue (response.indexOf("200")>0); } finally { @@ -556,8 +556,8 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture // read and check the times are < 999ms String[] times=in.readLine().split(","); - - // Assert.assertTrue(Integer.valueOf(t).intValue()<999); + for (String t: times) + Assert.assertTrue(Integer.valueOf(t).intValue()<999); // read the EOF chunk @@ -587,7 +587,8 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture // read and check the times are < 999ms times=in.readLine().split(","); - //Assert.assertTrue(t,Integer.valueOf(t).intValue()<999); + for (String t: times) + Assert.assertTrue(t,Integer.valueOf(t).intValue()<999); // check close Assert.assertTrue(in.readLine()==null); @@ -1060,7 +1061,6 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture AvailableHandler ah=new AvailableHandler(); configureServer(ah); - long start=System.currentTimeMillis(); Socket client=newSocket(HOST,_connector.getLocalPort()); try { diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java index 4ad0d561ac8..09e1970c3e9 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestFixture.java @@ -189,7 +189,7 @@ public class HttpServerTestFixture } // Create a trust manager that does not validate certificate chains - public static TrustManager[] __trustAllCerts = new TrustManager[] { + public final static TrustManager[] __trustAllCerts = new TrustManager[] { new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; @@ -203,7 +203,7 @@ public class HttpServerTestFixture } }; - public static HostnameVerifier __hostnameverifier = new HostnameVerifier() + public final static HostnameVerifier __hostnameverifier = new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java index 12dbc80a785..4b3b4fef5cf 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java @@ -160,7 +160,6 @@ public class ResponseTest { AbstractHttpConnection connection = new TestHttpConnection(connector,new ByteArrayEndPoint(), connector.getServer()); - Request request = connection.getRequest(); Response response = connection.getResponse(); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java index 0c46f2a3615..a7c640eb1ca 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java @@ -365,7 +365,6 @@ public class StressTest if (__tests.length!=bodies) System.err.println("responses=\n"+response+"\n---"); assertEquals(name,__tests.length,bodies); - bodies = count(response,"HTTP/1.1 200 OK"); long bind=connected-start; long flush=(written-connected)/__tests.length; @@ -461,7 +460,6 @@ public class StressTest response.setStatus(200); response.getOutputStream().print("DATA "+request.getPathInfo()+"\n\n"); baseRequest.setHandled(true); - long end=System.currentTimeMillis(); _latencies[4].add(new Long(System.currentTimeMillis()-start)); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslRenegotiateTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslRenegotiateTest.java index 9508e2109e8..69a96818d45 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslRenegotiateTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslRenegotiateTest.java @@ -216,7 +216,7 @@ public class SslRenegotiateTest private void doWrap() throws Exception { - SSLEngineResult result =_engine.wrap(_outAppB,_outPacketB); + _engine.wrap(_outAppB,_outPacketB); // System.err.println("wrapped "+result.bytesConsumed()+" to "+result.bytesProduced()); _outPacketB.flip(); while (_outPacketB.hasRemaining()) diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java index e3a15e42ffa..8279f771dcc 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SslUploadTest.java @@ -15,6 +15,7 @@ package org.eclipse.jetty.server.ssl; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.FileInputStream; import java.io.IOException; @@ -37,6 +38,7 @@ import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -129,6 +131,7 @@ public class SslUploadTest InputStream in = socket.getInputStream(); String response = IO.toString(in); + assertTrue (response.indexOf("200")>0); // System.err.println(response); long end = System.nanoTime(); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/DateCache.java b/jetty-util/src/main/java/org/eclipse/jetty/util/DateCache.java index 6fbe1cebe1a..98e29502940 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/DateCache.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/DateCache.java @@ -104,7 +104,7 @@ public class DateCache /** Set the timezone. * @param tz TimeZone */ - public void setTimeZone(TimeZone tz) + public synchronized void setTimeZone(TimeZone tz) { setTzFormatString(tz); if( _locale != null ) @@ -145,7 +145,7 @@ public class DateCache } /* ------------------------------------------------------------ */ - private void setTzFormatString(final TimeZone tz ) + private synchronized void setTzFormatString(final TimeZone tz ) { int zIndex = _formatString.indexOf( "ZZZ" ); if( zIndex >= 0 ) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java b/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java index 06976d45832..91e4a03196d 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/StringUtil.java @@ -330,7 +330,7 @@ public class StringUtil /* ------------------------------------------------------------ */ public static boolean isUTF8(String charset) { - return charset==__UTF8||__UTF8.equalsIgnoreCase(charset)||__UTF8Alt.equalsIgnoreCase(charset); + return __UTF8.equalsIgnoreCase(charset)||__UTF8Alt.equalsIgnoreCase(charset); } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java b/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java index b040de5900b..e0ed56cbaf7 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java @@ -43,7 +43,7 @@ import org.eclipse.jetty.util.log.Logger; * * @see java.net.URLEncoder */ -public class UrlEncoded extends MultiMap +public class UrlEncoded extends MultiMap implements Cloneable { private static final Logger LOG = Log.getLogger(UrlEncoded.class); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSON.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSON.java index 360a836d3d5..84824567afa 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSON.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ajax/JSON.java @@ -373,7 +373,7 @@ public class JSON @Deprecated public void appendJSON(final StringBuffer buffer, Convertible converter) { - appendJSON((StringBuffer)buffer,converter); + appendJSON((Appendable)buffer,converter); } /* ------------------------------------------------------------ */ diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java index a06af65b320..670eda6b4ad 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java @@ -151,7 +151,6 @@ public class JarResource extends URLResource JarInputStream jin = new JarInputStream(is); JarEntry entry; boolean shouldExtract; - String directoryCanonicalPath = directory.getCanonicalPath()+"/"; while((entry=jin.getNextJarEntry())!=null) { String entryName = entry.getName(); diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ajax/JSONPojoConvertorFactoryTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ajax/JSONPojoConvertorFactoryTest.java index 8cffa5896f6..066d0af5d42 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ajax/JSONPojoConvertorFactoryTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ajax/JSONPojoConvertorFactoryTest.java @@ -113,7 +113,7 @@ public class JSONPojoConvertorFactoryTest Map bz = (Map)br.get("baz"); Map f = (Map)bz.get("foo"); - + assertTrue(f != null); Object[] bazs = (Object[])br.get("bazs"); assertTrue(bazs.length==2); assertEquals(((Map)bazs[0]).get("message"), "baz0"); diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/ajax/JSONTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/ajax/JSONTest.java index 4f700dd0c58..58d8257b52a 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/ajax/JSONTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/ajax/JSONTest.java @@ -203,7 +203,7 @@ public class JSONTest public void testZeroByte() { String withzero="\u0000"; - String json = JSON.toString(withzero); + JSON.toString(withzero); } /* ------------------------------------------------------------ */ diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java index f45463b5196..7a7a915ccf6 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java @@ -135,7 +135,7 @@ public class LifeCycleListenerTest lifecycle.stop(); assertFalse("The stopping event occurred", listener.stopping); } - private class TestLifeCycle extends AbstractLifeCycle + private static class TestLifeCycle extends AbstractLifeCycle { Exception cause;