File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
src/main/java/com/maxmind/db Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -52,21 +52,21 @@ final class BufferHolder {
5252 if (null == stream ) {
5353 throw new NullPointerException ("Unable to use a NULL InputStream" );
5454 }
55- final int chunkSize = Integer .MAX_VALUE ;
55+ final int chunkSize = Integer .MAX_VALUE / 2 ;
5656 List <ByteBuffer > chunks = new ArrayList <>();
5757 long total = 0 ;
5858 byte [] tmp = new byte [chunkSize ];
5959 int read ;
6060
6161 while (-1 != (read = stream .read (tmp ))) {
62- ByteBuffer chunk = ByteBuffer .allocateDirect (read );
62+ ByteBuffer chunk = ByteBuffer .allocate (read );
6363 chunk .put (tmp , 0 , read );
6464 chunk .flip ();
6565 chunks .add (chunk );
6666 total += read ;
6767 }
6868
69- if (total <= Integer . MAX_VALUE ) {
69+ if (total <= chunkSize ) {
7070 byte [] data = new byte [(int ) total ];
7171 int pos = 0 ;
7272 for (ByteBuffer chunk : chunks ) {
Original file line number Diff line number Diff line change 2323class MultiBuffer implements Buffer {
2424
2525 /** Maximum size per underlying chunk. */
26- static final int CHUNK_SIZE = Integer .MAX_VALUE ;
26+ static final int CHUNK_SIZE = Integer .MAX_VALUE / 2 ;
2727
2828 final List <ByteBuffer > buffers = new ArrayList <>();
2929 private final long capacity ;
You can’t perform that action at this time.
0 commit comments