Jetty
  1. Jetty
  2. JETTY-559

The method shutdownOutput() is not supported in SSLSocket

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major 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 :
      0

      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

          Hide
          Gary Gregory added a comment -

          In my comment http://jira.codehaus.org/browse/JETTY-559?focusedCommentId=135796#action_135796 I meant to say that I see this in 6.1.10. I do not know about 6.1.9.

          Show
          Gary Gregory added a comment - In my comment http://jira.codehaus.org/browse/JETTY-559?focusedCommentId=135796#action_135796 I meant to say that I see this in 6.1.10 . I do not know about 6.1.9.
          Hide
          Gary Gregory added a comment -

          See also JETTY-580 java.lang.UnsupportedOperationException: The method shutdownOutput() is not supported in SSLSocket.

          Show
          Gary Gregory added a comment - See also JETTY-580 java.lang.UnsupportedOperationException: The method shutdownOutput() is not supported in SSLSocket.
          Hide
          Greg Wilkins added a comment -

          DOh! I thought I had fixed this.... will check to see what went wrong.

          In the mean time.... use SslSelectChannelConnector

          cheers

          Show
          Greg Wilkins added a comment - DOh! I thought I had fixed this.... will check to see what went wrong. In the mean time.... use SslSelectChannelConnector cheers
          Hide
          Greg Wilkins added a comment -

          SSL Sockets do not support shutdown

          Show
          Greg Wilkins added a comment - SSL Sockets do not support shutdown
          Hide
          Greg Wilkins added a comment -

          Reopened as duplicate of JETTY-580

          Show
          Greg Wilkins added a comment - Reopened as duplicate of JETTY-580

            People

            • Assignee:
              Greg Wilkins
              Reporter:
              Bruno Harbulot
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: