java.lang.UnsupportedOperationException

Java.net JIRA | joakimerdfelt | 3 years ago
  1. 0

    performance testing of MMS

    Google Groups | 4 years ago | thangtq
    java.lang.UnsupportedOperationException
  2. 0

    [TYRUS-216] Incorrect use of ByteBuffer.array() in sendBinary(ByteBuffer) - Java.net JIRA

    java.net | 1 year ago
    java.lang.UnsupportedOperationException
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    In org.glassfish.tyrus.core.TyrusRemoteEndpoint#sendBinary(ByteBuffer byteBuffer) The use of ByteBuffer.array() is incorrect use of a ByteBuffer. That will obtain the entire underlying array for the byte buffer, regardless of the position and limit that the ByteBuffer currently has. Example: final Charset UTF8 = Charset.forName("UTF-8"); ByteBuffer buf = ByteBuffer.allocate(100); buf.put("Hello World".getBytes(UTF8)); The ByteBuffer at this point has the following structure ... HeapByteBuffer@29578426[p=11,l=100,c=100,r=89]={Hello World<<<�����������������...���������������>>>} The key to read this: p = position l = limit c = capacity r = remaining <<<_>>> what is in the brackets is what is active and visible from the point of view of the ByteBuffer at this moment. Which means that there is 89 bytes of remaining content to write in this buffer. This ByteBuffer hasn't been flipped yet and been made available for writing. If we change the example to be: final Charset UTF8 = Charset.forName("UTF-8"); ByteBuffer buf = ByteBuffer.allocate(100); buf.put("Hello World".getBytes(UTF8)); buf.flip(); We can see that this ByteBuffer has been flipped, and at this point has the following structure ... HeapByteBuffer@29578426[p=0,l=11,c=100,r=11]={<<<Hello World>>>�����������������...���������������} This has 11 bytes to write, with the position and limit set to only include the "Hello World" bytes. With the use of ByteBuffer.array() you will *ALWAYS* get the 100 bytes of the allocated buffer, even though only 11 bytes should be written.

    Java.net JIRA | 3 years ago | joakimerdfelt
    java.lang.UnsupportedOperationException
  5. 0

    In org.glassfish.tyrus.core.TyrusRemoteEndpoint#sendBinary(ByteBuffer byteBuffer) The use of ByteBuffer.array() is incorrect use of a ByteBuffer. That will obtain the entire underlying array for the byte buffer, regardless of the position and limit that the ByteBuffer currently has. Example: final Charset UTF8 = Charset.forName("UTF-8"); ByteBuffer buf = ByteBuffer.allocate(100); buf.put("Hello World".getBytes(UTF8)); The ByteBuffer at this point has the following structure ... HeapByteBuffer@29578426[p=11,l=100,c=100,r=89]={Hello World<<<�����������������...���������������>>>} The key to read this: p = position l = limit c = capacity r = remaining <<<_>>> what is in the brackets is what is active and visible from the point of view of the ByteBuffer at this moment. Which means that there is 89 bytes of remaining content to write in this buffer. This ByteBuffer hasn't been flipped yet and been made available for writing. If we change the example to be: final Charset UTF8 = Charset.forName("UTF-8"); ByteBuffer buf = ByteBuffer.allocate(100); buf.put("Hello World".getBytes(UTF8)); buf.flip(); We can see that this ByteBuffer has been flipped, and at this point has the following structure ... HeapByteBuffer@29578426[p=0,l=11,c=100,r=11]={<<<Hello World>>>�����������������...���������������} This has 11 bytes to write, with the position and limit set to only include the "Hello World" bytes. With the use of ByteBuffer.array() you will *ALWAYS* get the 100 bytes of the allocated buffer, even though only 11 bytes should be written.

    Java.net JIRA | 3 years ago | joakimerdfelt
    java.lang.UnsupportedOperationException

    1 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.UnsupportedOperationException

      No message provided

      at java.nio.ByteBuffer.array()
    2. Java RT
      ByteBuffer.array
      1. java.nio.ByteBuffer.array(ByteBuffer.java:959)
      1 frame