File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -505,7 +505,7 @@ private void verifyString(final String expected) {
505
505
JsonToken token = popToken ();
506
506
JsonTokenType type = token .getType ();
507
507
508
- if ((type != JsonTokenType .STRING && type != JsonTokenType .UNQUOTED_STRING ) && !expected .equals (token .getValue ())) {
508
+ if ((type != JsonTokenType .STRING && type != JsonTokenType .UNQUOTED_STRING ) || !expected .equals (token .getValue ())) {
509
509
throw new JsonParseException ("JSON reader expected '%s' but found '%s'." , expected , token .getValue ());
510
510
}
511
511
}
Original file line number Diff line number Diff line change @@ -628,6 +628,19 @@ public void testTimestampStrict() {
628
628
assertEquals (AbstractBsonReader .State .DONE , bsonReader .getState ());
629
629
}
630
630
631
+ @ Test
632
+ public void testTimestampStrictWithOutOfOrderFields () {
633
+ String json = "{ \" $timestamp\" : { \" i\" : 1, \" t\" : 1234 } }" ;
634
+ bsonReader = new JsonReader (json );
635
+
636
+ try {
637
+ bsonReader .readBsonType ();
638
+ fail ("Should have failed to read timestamp with fields not in expected order" );
639
+ } catch (JsonParseException e ) {
640
+ // all good
641
+ }
642
+ }
643
+
631
644
@ Test
632
645
public void testTimestampShell () {
633
646
String json = "Timestamp(1234, 1)" ;
You can’t perform that action at this time.
0 commit comments