Other |
---|
tbd_minorResolved |
Duplicate :
|
|
Relates :
|
|
Relates :
|
After JDK-8026049, ByteBuffer.getFloat() throw BufferOverflowException while BufferUnderflowException is expected. Test to reproduce this issue: import java.nio.BufferOverflowException; import java.nio.BufferUnderflowException; import java.nio.ByteBuffer; public class Test { public static void main(String[] args) { int length = 4; float value = Float.MIN_VALUE; ByteBuffer buffer = ByteBuffer.allocate(length); buffer.putFloat(value); buffer.position(0); if (value != buffer.getFloat()) { System.out.println("Test Fail: Returned value not equal to what was entered."); } else { try { value = buffer.getFloat(); } catch (BufferUnderflowException e) { System.out.println("Test Pass: Expected Exception " + e.toString() + " thrown."); } catch (BufferOverflowException e) { System.out.println("Test Fail: Unexpected Exception " + e.toString() + " thrown."); e.printStackTrace(); } } } } Expected result: Test Pass: Expected Exception java.nio.BufferUnderflowException thrown. Real result (with build after JDK-8026049) Test Fail: Unexpected Exception java.nio.BufferOverflowException thrown. java.nio.BufferOverflowException at java.nio.Buffer.nextPutIndex(Buffer.java:527) at java.nio.HeapByteBuffer.getFloat(HeapByteBuffer.java:480) at Test.main(Test.java:18)