@@ -611,22 +611,29 @@ private void appendSQLTimestamp(final Timestamp value) {
611
611
}
612
612
613
613
private void appendString (final String value ) throws VPackBuilderException {
614
- final int length = value .getBytes ().length ;
615
- if (length <= 126 ) {
616
- // short string
617
- add ((byte ) (0x40 + length ));
618
- } else {
619
- // long string
620
- add ((byte ) 0xbf );
621
- appendLength (length );
622
- }
623
614
try {
624
- append (value );
615
+ final byte [] bytes = value .getBytes ("UTF-8" );
616
+ final int length = bytes .length ;
617
+ if (length <= 126 ) {
618
+ // short string
619
+ add ((byte ) (0x40 + length ));
620
+ } else {
621
+ // long string
622
+ add ((byte ) 0xbf );
623
+ appendLength (length );
624
+ }
625
+ appendString (bytes );
625
626
} catch (final UnsupportedEncodingException e ) {
626
627
throw new VPackBuilderException (e );
627
628
}
628
629
}
629
630
631
+ private void appendString (final byte [] bytes ) {
632
+ ensureCapacity (size + bytes .length );
633
+ System .arraycopy (bytes , 0 , buffer , size , bytes .length );
634
+ size += bytes .length ;
635
+ }
636
+
630
637
private void appendBinary (final byte [] value ) {
631
638
add ((byte ) 0xc3 );
632
639
append (value .length , INTEGER_BYTES );
@@ -642,13 +649,6 @@ private void appendVPack(final VPackSlice value) {
642
649
size += vpack .length ;
643
650
}
644
651
645
- private void append (final String value ) throws UnsupportedEncodingException {
646
- final byte [] bytes = value .getBytes ("UTF-8" );
647
- ensureCapacity (size + bytes .length );
648
- System .arraycopy (bytes , 0 , buffer , size , bytes .length );
649
- size += bytes .length ;
650
- }
651
-
652
652
private void addArray (final boolean unindexed ) {
653
653
addCompoundValue ((byte ) (unindexed ? 0x13 : 0x06 ));
654
654
}
0 commit comments