Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8239022

Error in SSLEngine Javadoc sample code

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      This is a documentation issue

      A DESCRIPTION OF THE PROBLEM :
      The sample code for handling buffer underflow during SSLEngine.wrap references the wrong buffer. It should reference "src" instead of "dst". I have annotated the snippet below:

         BUFFER_UNDERFLOW:
             int netSize = engine.getSession().getPacketBufferSize();
             // Resize buffer if needed.
             if (netSize > dst.capacity()) { ----> this should be src.capacity()
                 ByteBuffer b = ByteBuffer.allocate(netSize);
                 src.flip();
                 b.put(src);
                 src = b;
             }
             // Obtain more inbound network data for src,
             // then retry the operation.
             break;


            wetmore Bradford Wetmore
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: