39
39
import java .util .Map ;
40
40
import org .neo4j .driver .Value ;
41
41
import org .neo4j .driver .exceptions .ClientException ;
42
+ import org .neo4j .driver .exceptions .ProtocolException ;
42
43
import org .neo4j .driver .internal .InternalNode ;
43
44
import org .neo4j .driver .internal .InternalPath ;
44
45
import org .neo4j .driver .internal .InternalRelationship ;
@@ -188,21 +189,29 @@ protected Value unpackStruct(long size, byte type) throws IOException {
188
189
if (!dateTimeUtcEnabled ) {
189
190
ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
190
191
return unpackDateTimeWithZoneOffset ();
192
+ } else {
193
+ throw instantiateExceptionForUnknownType (type );
191
194
}
192
195
case DATE_TIME_WITH_ZONE_OFFSET_UTC :
193
196
if (dateTimeUtcEnabled ) {
194
197
ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
195
198
return unpackDateTimeUtcWithZoneOffset ();
199
+ } else {
200
+ throw instantiateExceptionForUnknownType (type );
196
201
}
197
202
case DATE_TIME_WITH_ZONE_ID :
198
203
if (!dateTimeUtcEnabled ) {
199
204
ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
200
205
return unpackDateTimeWithZoneId ();
206
+ } else {
207
+ throw instantiateExceptionForUnknownType (type );
201
208
}
202
209
case DATE_TIME_WITH_ZONE_ID_UTC :
203
210
if (dateTimeUtcEnabled ) {
204
211
ensureCorrectStructSize (TypeConstructor .DATE_TIME , DATE_TIME_STRUCT_SIZE , size );
205
212
return unpackDateTimeUtcWithZoneId ();
213
+ } else {
214
+ throw instantiateExceptionForUnknownType (type );
206
215
}
207
216
case DURATION :
208
217
ensureCorrectStructSize (TypeConstructor .DURATION , DURATION_TIME_STRUCT_SIZE , size );
@@ -224,7 +233,7 @@ protected Value unpackStruct(long size, byte type) throws IOException {
224
233
ensureCorrectStructSize (TypeConstructor .PATH , 3 , size );
225
234
return unpackPath ();
226
235
default :
227
- throw new IOException ( "Unknown struct type: " + type );
236
+ throw instantiateExceptionForUnknownType ( type );
228
237
}
229
238
}
230
239
@@ -417,4 +426,8 @@ private ZonedDateTime newZonedDateTimeUsingUtcBaseline(long epochSecondLocal, in
417
426
LocalDateTime localDateTime = LocalDateTime .ofInstant (instant , zoneId );
418
427
return ZonedDateTime .of (localDateTime , zoneId );
419
428
}
429
+
430
+ private ProtocolException instantiateExceptionForUnknownType (byte type ) {
431
+ return new ProtocolException ("Unknown struct type: " + type );
432
+ }
420
433
}
0 commit comments