Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1449

Ability to control clearing of ByteBuffers within BasicWebSocketSessionRemoteEndpoint

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Won't Do
    • Minor
    • None
    • 2.0.16.Final
    • None

    Description

      Been loving the undertow project so far.

      Background
      I’m creating this request since I spent a great deal of time last night debugging a very hard-to-pin issue that ended up being caused by the following line of code...
      https://github.com/undertow-io/undertow/blob/master/websockets-jsr/src/main/java/io/undertow/websockets/jsr/WebSocketSessionRemoteEndpoint.java#L268

      For now, my solution is just to reverse the ‘clear’ by calling a flip. I may just write a wrapper for my ByteBuffers to lock consumers from fiddling with their read/write state, but from the tone of the code comment it sounds like the author was equally at a loss for why the JSR TCK is requiring your code to do that .clear() call as well.

      In short
      I'm requesting that an additional supplemental method be provided that allows consumers to send a bytebuffer without having to deal with the .clear() call it is mandating.

      Psuedo code would be something like...

      @Override
      public void sendBinary(final ByteBuffer data) throws IOException {
      	sendBinaryNoClear(data);
      	data.clear(); //for some reason the TCK expects this, might as well just match the RI behaviour
      }
      
      public void sendBinaryNoClear(final ByteBuffer data) throws IOException {
      	if(data == null) {
      		throw JsrWebSocketMessages.MESSAGES.messageInNull();
      	}
      	assertNotInFragment();
      	WebSockets.sendBinaryBlocking(data, undertowSession.getWebSocketChannel());
      }
      

      Thank you for your time!

      Attachments

        Activity

          People

            rhn-cservice-bbaranow Bartosz Baranowski
            wsoderberg Will Soderberg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: