File tree Expand file tree Collapse file tree 3 files changed +5
-26
lines changed
main/java/org/neo4j/driver/internal/packstream
test/java/org/neo4j/driver/internal/packstream Expand file tree Collapse file tree 3 files changed +5
-26
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,11 @@ public class BufferedChannelInput implements PackInput
3030{
3131 private final ByteBuffer buffer ;
3232 private ReadableByteChannel channel ;
33+ private static final int DEFAULT_BUFFER_CAPACITY = 8192 ;
3334
34- public BufferedChannelInput ( int bufferCapacity )
35+ public BufferedChannelInput (ReadableByteChannel ch )
3536 {
36- this ( bufferCapacity , null );
37+ this ( DEFAULT_BUFFER_CAPACITY , ch );
3738 }
3839
3940 public BufferedChannelInput ( int bufferCapacity , ReadableByteChannel ch )
Original file line number Diff line number Diff line change 1919package org .neo4j .driver .internal .packstream ;
2020
2121import java .io .IOException ;
22- import java .nio .channels .ReadableByteChannel ;
2322import java .nio .channels .WritableByteChannel ;
2423import java .nio .charset .Charset ;
2524import java .util .List ;
@@ -147,8 +146,6 @@ public class PackStream
147146 private static final String EMPTY_STRING = "" ;
148147 private static final Charset UTF_8 = Charset .forName ( "UTF-8" );
149148
150- private static final int DEFAULT_BUFFER_CAPACITY = 8192 ;
151-
152149 private PackStream () {}
153150
154151 public static class Packer
@@ -428,29 +425,11 @@ public static class Unpacker
428425 {
429426 private PackInput in ;
430427
431- public Unpacker ( ReadableByteChannel channel )
432- {
433- this ( DEFAULT_BUFFER_CAPACITY );
434- reset ( channel );
435- }
436-
437- public Unpacker ( int bufferCapacity )
438- {
439- assert bufferCapacity >= 8 : "Buffer must be at least 8 bytes." ;
440- this .in = new BufferedChannelInput ( bufferCapacity );
441- }
442-
443428 public Unpacker ( PackInput in )
444429 {
445430 this .in = in ;
446431 }
447432
448- public Unpacker reset ( ReadableByteChannel ch )
449- {
450- ((BufferedChannelInput )in ).reset ( ch );
451- return this ;
452- }
453-
454433 public boolean hasNext () throws IOException
455434 {
456435 return in .hasMoreData ();
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ public PackStream.Packer packer()
112112 private PackStream .Unpacker newUnpacker ( byte [] bytes )
113113 {
114114 ByteArrayInputStream input = new ByteArrayInputStream ( bytes );
115- return new PackStream .Unpacker ( Channels .newChannel ( input ) );
115+ return new PackStream .Unpacker ( new BufferedChannelInput ( Channels .newChannel ( input ) ) );
116116 }
117117
118118 @ Test
@@ -802,8 +802,7 @@ public void handlesDataCrossingBufferBoundaries() throws Throwable
802802 packer .flush ();
803803
804804 ReadableByteChannel ch = Channels .newChannel ( new ByteArrayInputStream ( machine .output () ) );
805- PackStream .Unpacker unpacker = new PackStream .Unpacker ( 11 );
806- unpacker .reset ( ch );
805+ PackStream .Unpacker unpacker = new PackStream .Unpacker ( new BufferedChannelInput ( 11 , ch ) );
807806
808807 // Serialized ch will look like, and misalign with the 11-byte unpack buffer:
809808
You can’t perform that action at this time.
0 commit comments