@@ -632,13 +632,24 @@ protected Object deserializeWithUnwrapped(JsonParser p, DeserializationContext c
632
632
handleIgnoredProperty (p , ctxt , bean , propName );
633
633
continue ;
634
634
}
635
- // but... others should be passed to unwrapped property deserializers
636
- tokens . writeFieldName ( propName );
637
- tokens . copyCurrentStructure ( p );
635
+ // 29-Nov-2016, tatu: probably should try to avoid sending content
636
+ // both to any setter AND buffer... but, for now, the only thing
637
+ // we can do.
638
638
// how about any setter? We'll get copies but...
639
- if (_anySetter != null ) {
639
+ if (_anySetter == null ) {
640
+ // but... others should be passed to unwrapped property deserializers
641
+ tokens .writeFieldName (propName );
642
+ tokens .copyCurrentStructure (p );
643
+ } else {
644
+ // Need to copy to a separate buffer first
645
+ TokenBuffer b2 = new TokenBuffer (p , ctxt );
646
+ b2 .copyCurrentStructure (p );
647
+ tokens .writeFieldName (propName );
648
+ tokens .append (b2 );
640
649
try {
641
- _anySetter .deserializeAndSet (p , ctxt , bean , propName );
650
+ JsonParser p2 = b2 .asParser (p );
651
+ p2 .nextToken ();
652
+ _anySetter .deserializeAndSet (p2 , ctxt , bean , propName );
642
653
} catch (Exception e ) {
643
654
wrapAndThrow (e , bean , propName , ctxt );
644
655
}
@@ -681,12 +692,28 @@ protected Object deserializeWithUnwrapped(JsonParser p, DeserializationContext c
681
692
handleIgnoredProperty (p , ctxt , bean , propName );
682
693
continue ;
683
694
}
684
- // but... others should be passed to unwrapped property deserializers
685
- tokens . writeFieldName ( propName );
686
- tokens . copyCurrentStructure ( p );
695
+ // 29-Nov-2016, tatu: probably should try to avoid sending content
696
+ // both to any setter AND buffer... but, for now, the only thing
697
+ // we can do.
687
698
// how about any setter? We'll get copies but...
688
- if (_anySetter != null ) {
689
- _anySetter .deserializeAndSet (p , ctxt , bean , propName );
699
+ if (_anySetter == null ) {
700
+ // but... others should be passed to unwrapped property deserializers
701
+ tokens .writeFieldName (propName );
702
+ tokens .copyCurrentStructure (p );
703
+ } else {
704
+ // Need to copy to a separate buffer first
705
+ TokenBuffer b2 = new TokenBuffer (p , ctxt );
706
+ b2 .copyCurrentStructure (p );
707
+ tokens .writeFieldName (propName );
708
+ tokens .append (b2 );
709
+ try {
710
+ JsonParser p2 = b2 .asParser (p );
711
+ p2 .nextToken ();
712
+ _anySetter .deserializeAndSet (p2 , ctxt , bean , propName );
713
+ } catch (Exception e ) {
714
+ wrapAndThrow (e , bean , propName , ctxt );
715
+ }
716
+ continue ;
690
717
}
691
718
}
692
719
tokens .writeEndObject ();
@@ -755,15 +782,29 @@ protected Object deserializeUsingPropertyBasedWithUnwrapped(JsonParser p, Deseri
755
782
handleIgnoredProperty (p , ctxt , handledType (), propName );
756
783
continue ;
757
784
}
758
- tokens .writeFieldName (propName );
759
- tokens .copyCurrentStructure (p );
760
- // "any property"?
761
- if (_anySetter != null ) {
785
+ // 29-Nov-2016, tatu: probably should try to avoid sending content
786
+ // both to any setter AND buffer... but, for now, the only thing
787
+ // we can do.
788
+ // how about any setter? We'll get copies but...
789
+ if (_anySetter == null ) {
790
+ // but... others should be passed to unwrapped property deserializers
791
+ tokens .writeFieldName (propName );
792
+ tokens .copyCurrentStructure (p );
793
+ } else {
794
+ // Need to copy to a separate buffer first
795
+ TokenBuffer b2 = new TokenBuffer (p , ctxt );
796
+ b2 .copyCurrentStructure (p );
797
+ tokens .writeFieldName (propName );
798
+ tokens .append (b2 );
762
799
try {
763
- buffer .bufferAnyProperty (_anySetter , propName , _anySetter .deserialize (p , ctxt ));
800
+ JsonParser p2 = b2 .asParser (p );
801
+ p2 .nextToken ();
802
+ buffer .bufferAnyProperty (_anySetter , propName ,
803
+ _anySetter .deserialize (p2 , ctxt ));
764
804
} catch (Exception e ) {
765
805
wrapAndThrow (e , _beanType .getRawClass (), propName , ctxt );
766
806
}
807
+ continue ;
767
808
}
768
809
}
769
810
0 commit comments