Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: 7.0.0pre0
-
Fix Version/s: 7.0.0pre1
-
Component/s: None
-
Labels:None
-
Patch Submitted:Yes
-
Number of attachments :
Description
I've just submitted a test-case (SSLContextTest) for http://jira.codehaus.org/browse/JETTY-554
This test case uses the same HelloWorldHandler as SSLEngineTest. As part of this, there is a call to close() in the PrintWriter created within HttpConnection. This ultimately leads to calling _socket.shutdownOutput() in SocketEndPoint.
This generates this exception:
java.lang.UnsupportedOperationException: The method shutdownOutput() is not supported in SSLSocket
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.shutdownOutput(BaseSSLSocketImpl.java:192)
at org.mortbay.io.bio.SocketEndPoint.close(SocketEndPoint.java:63)
at org.mortbay.jetty.bio.SocketConnector$Connection.close(SocketConnector.java:208)
at org.mortbay.jetty.HttpGenerator.flush(HttpGenerator.java:734)
at org.mortbay.jetty.HttpGenerator.complete(HttpGenerator.java:646)
at org.mortbay.jetty.HttpConnection.commitResponse(HttpConnection.java:622)
at org.mortbay.jetty.HttpConnection$Output.close(HttpConnection.java:925)
at org.mortbay.jetty.AbstractGenerator$OutputWriter.close(AbstractGenerator.java:726)
at org.mortbay.jetty.HttpConnection$1.close(HttpConnection.java:336)
at org.mortbay.jetty.security.SSLContextTest$HelloWorldHandler.handle(SSLContextTest.java:465)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:325)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:873)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:391)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:235)
at org.mortbay.jetty.security.SslSocketConnector$SslConnection.run(SslSocketConnector.java:631)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
I've circumvented the problem using the following patch:
— a/modules/server/jetty/src/main/java/org/mortbay/io/bio/SocketEndPoint.java
+++ b/modules/server/jetty/src/main/java/org/mortbay/io/bio/SocketEndPoint.java
@@ -20,6 +20,8 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
+import javax.net.ssl.SSLSocket;
+
import org.mortbay.io.Portable;
/**
@@ -57,7 +59,7 @@ public class SocketEndPoint extends StreamEndPoint
*/
public void close() throws IOException
{
- if (!_socket.isClosed() && !_socket.isOutputShutdown())
+ if (!_socket.isClosed() && !_socket.isOutputShutdown() && !(_socket instanceof SSLSocket))
_socket.shutdownOutput();
_socket.close();
_in=null;
It's not clear to me whether this bug only occurs because of the way HelloWorldHandler is written or if it could be more general. Perhaps a better way to fix this would be to try and catch UnsupportedOperationException when calling shutdownOutput, this would be less dependant on SSLSocket.
Issue Links
Activity
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Greg Wilkins [ gregw ] |
| Status | Open [ 1 ] | In Progress [ 3 ] |
| Fix Version/s | 7.0.0pre1 [ 14208 ] | |
| Resolution | Fixed [ 1 ] | |
| Status | In Progress [ 3 ] | Resolved [ 5 ] |
| Resolution | Fixed [ 1 ] | |
| Status | Resolved [ 5 ] | Reopened [ 4 ] |
| Resolution | Duplicate [ 3 ] | |
| Status | Reopened [ 4 ] | Resolved [ 5 ] |
Hi,
I hadn't noticed, but this seems to have been caused very recently, in revision 2766, by the fix for
JETTY-547.Looking at
JETTY-549, it might indeed be better to catch UnsupportedOperationException, which would avoid that problem (although this was related to Jetty 5.x, which was already using shutdownOutput(), but not doing it for SSLSockets).