File tree 8 files changed +14
-41
lines changed
main/java/org/neo4j/driver
test/java/org/neo4j/driver
8 files changed +14
-41
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ public void updateProtocol( String serverVersion )
143
143
{
144
144
if ( version ( serverVersion ).lessThan ( v3_2_0 ) )
145
145
{
146
- setProtocol ( SocketProtocolV1 .create ( channel , false ) );
146
+ setProtocol ( SocketProtocolV1 .createWithoutByteArraySupport ( channel ) );
147
147
}
148
148
}
149
149
Original file line number Diff line number Diff line change @@ -34,15 +34,15 @@ public class SocketProtocolV1 implements SocketProtocol
34
34
public static SocketProtocol create ( ByteChannel channel )
35
35
{
36
36
/*by default the byte array support is enabled*/
37
- return create ( channel , true );
37
+ return new SocketProtocolV1 ( channel , true );
38
38
}
39
39
40
- public static SocketProtocol create ( ByteChannel channel , boolean byteArraySupportEnabled )
40
+ public static SocketProtocol createWithoutByteArraySupport ( ByteChannel channel )
41
41
{
42
- return new SocketProtocolV1 ( channel , byteArraySupportEnabled );
42
+ return new SocketProtocolV1 ( channel , false );
43
43
}
44
44
45
- public SocketProtocolV1 ( ByteChannel channel , boolean byteArraySupportEnabled )
45
+ private SocketProtocolV1 ( ByteChannel channel , boolean byteArraySupportEnabled )
46
46
{
47
47
messageFormat = new PackStreamMessageFormatV1 ();
48
48
this .writer = messageFormat .newWriter ( channel , byteArraySupportEnabled );
Original file line number Diff line number Diff line change @@ -535,30 +535,6 @@ public String unpackString() throws IOException
535
535
return new String (unpackUtf8 (markerByte ), UTF_8 );
536
536
}
537
537
538
- public byte [] unpackRawBytes () throws IOException
539
- {
540
- final byte markerByte = in .readByte ();
541
-
542
- switch (markerByte )
543
- {
544
- case BYTES_8 : return unpackRawBytes ( unpackUINT8 () );
545
- case BYTES_16 : return unpackRawBytes ( unpackUINT16 () );
546
- case BYTES_32 :
547
- {
548
- long size = unpackUINT32 ();
549
- if ( size <= Integer .MAX_VALUE )
550
- {
551
- return unpackRawBytes ( (int ) size );
552
- }
553
- else
554
- {
555
- throw new Overflow ( "BYTES_32 too long for Java" );
556
- }
557
- }
558
- default : throw new Unexpected ( "Expected binary data, but got: 0x" + toHexString ( markerByte & 0xFF ));
559
- }
560
- }
561
-
562
538
/**
563
539
* This may seem confusing. This method exists to move forward the internal pointer when encountering
564
540
* a null value. The idiomatic usage would be someone using {@link #peekNextType()} to detect a null type,
Original file line number Diff line number Diff line change @@ -54,12 +54,6 @@ public static ServerVersion version( Driver driver )
54
54
}
55
55
}
56
56
57
- public static ServerVersion version ( Session session )
58
- {
59
- String versionString = session .run ( "RETURN 1" ).consume ().server ().version ();
60
- return version ( versionString );
61
- }
62
-
63
57
public static ServerVersion version ( String server )
64
58
{
65
59
if ( server == null )
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ public static Value value( Object value )
85
85
if ( value instanceof Iterable <?> ) { return value ( (Iterable <Object >) value ); }
86
86
if ( value instanceof Iterator <?> ) { return value ( (Iterator <Object >) value ); }
87
87
88
- if ( value instanceof byte [] ) { return new BytesValue ( (byte []) value ); }
88
+ if ( value instanceof byte [] ) { return value ( (byte []) value ); }
89
89
if ( value instanceof boolean [] ) { return value ( (boolean []) value ); }
90
90
if ( value instanceof String [] ) { return value ( (String []) value ); }
91
91
if ( value instanceof long [] ) { return value ( (long []) value ); }
@@ -98,6 +98,7 @@ public static Value value( Object value )
98
98
throw new ClientException ( "Unable to convert " + value .getClass ().getName () + " to Neo4j Value." );
99
99
}
100
100
101
+
101
102
public static Value [] values ( final Object ... input )
102
103
{
103
104
Value [] values = new Value [input .length ];
@@ -116,7 +117,7 @@ public static Value value( Value... input )
116
117
return new ListValue ( values );
117
118
}
118
119
119
- private static Value bytesValue ( byte [] input )
120
+ public static BytesValue value ( byte ... input )
120
121
{
121
122
return new BytesValue ( input );
122
123
}
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ public PackOutput writeDouble( double value ) throws IOException
107
107
return this ;
108
108
}
109
109
110
- private void ensure (int size ) throws IOException
110
+ private void ensure ( int size ) throws IOException
111
111
{
112
112
if ( buffer .remaining () < size )
113
113
{
Original file line number Diff line number Diff line change @@ -344,7 +344,7 @@ public void testCanPackAndUnpackByteArrays() throws Throwable
344
344
345
345
// Then
346
346
assertThat ( packType , equalTo ( PackType .BYTES ) );
347
- assertArrayEquals ( array , unpacker .unpackRawBytes () );
347
+ assertArrayEquals ( array , unpacker .unpackBytes () );
348
348
}
349
349
}
350
350
@@ -391,7 +391,7 @@ public void testCanPackAndUnpackBytes() throws Throwable
391
391
392
392
// Then
393
393
assertThat ( packType , equalTo ( PackType .BYTES ) );
394
- assertArrayEquals ( "ABCDEFGHIJ" .getBytes (), unpacker .unpackRawBytes () );
394
+ assertArrayEquals ( "ABCDEFGHIJ" .getBytes (), unpacker .unpackBytes () );
395
395
396
396
}
397
397
Original file line number Diff line number Diff line change 40
40
import static org .junit .Assert .fail ;
41
41
import static org .junit .Assume .assumeFalse ;
42
42
import static org .junit .Assume .assumeTrue ;
43
+ import static org .neo4j .driver .internal .util .ServerVersion .version ;
43
44
import static org .neo4j .driver .v1 .Values .ofValue ;
44
45
import static org .neo4j .driver .v1 .Values .parameters ;
45
46
@@ -151,7 +152,8 @@ public void shouldBeAbleToSetAndReturnDoubleProperty()
151
152
152
153
private boolean supportsBytes ()
153
154
{
154
- return ServerVersion .version ( session ).greaterThanOrEqual ( ServerVersion .v3_2_0 );
155
+ String versionString = session .run ( "RETURN 1" ).consume ().server ().version ();
156
+ return version ( versionString ).greaterThanOrEqual ( ServerVersion .v3_2_0 );
155
157
}
156
158
157
159
@ Test
You can’t perform that action at this time.
0 commit comments