Skip to content

Commit cd36b6b

Browse files
committed
Fixed BufferUnderflowException - now using ByteBuf in ReadingByteBuffer as well.
1 parent e59465f commit cd36b6b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/de/javasocketapi/core/ReadingByteBuffer.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package de.javasocketapi.core;
22

3-
import java.nio.ByteBuffer;
3+
import org.boon.primitive.ByteBuf;
4+
45
import java.util.UUID;
56

67
public class ReadingByteBuffer {
7-
private final ByteBuffer byteBuffer;
8+
private final ByteBuf byteBuffer;
89

910
ReadingByteBuffer(final byte... bytes) {
10-
this.byteBuffer = ByteBuffer.wrap(bytes);
11+
this.byteBuffer = ByteBuf.create(bytes);
1112
}
1213

1314
public boolean readBoolean() {
@@ -17,32 +18,32 @@ public boolean readBoolean() {
1718

1819
public byte readByte() {
1920
//read byte
20-
return this.byteBuffer.get();
21+
return this.byteBuffer.input().readByte();
2122
}
2223

2324
public short readShort() {
2425
//read short
25-
return this.byteBuffer.getShort();
26+
return this.byteBuffer.input().readShort();
2627
}
2728

2829
public int readInt() {
2930
//read int
30-
return this.byteBuffer.getInt();
31+
return this.byteBuffer.input().readInt();
3132
}
3233

3334
public long readLong() {
3435
//read long
35-
return this.byteBuffer.getLong();
36+
return this.byteBuffer.input().readLong();
3637
}
3738

3839
public float readFloat() {
3940
//read float
40-
return this.byteBuffer.getFloat();
41+
return this.byteBuffer.input().readFloat();
4142
}
4243

4344
public double readDouble() {
4445
//read double
45-
return this.byteBuffer.getDouble();
46+
return this.byteBuffer.input().readDouble();
4647
}
4748

4849
public char readChar() {

0 commit comments

Comments
 (0)