File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
main/java/com/fasterxml/jackson/dataformat/protobuf
test/java/com/fasterxml/jackson/dataformat/protobuf Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -2326,7 +2326,8 @@ private long _decodeVLong() throws IOException
2326
2326
v |= ((ch & 0x7F ) << 14 );
2327
2327
ch = buf [_inputPtr ++];
2328
2328
if (ch >= 0 ) {
2329
- return v | (ch << 21 );
2329
+ long l2 = (v | (ch << 21 ));
2330
+ return (l2 << 28 ) | l ;
2330
2331
}
2331
2332
v |= ((ch & 0x7F ) << 21 );
2332
2333
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .dataformat .protobuf ;
2
+
3
+ public class BigNumPair {
4
+ public static final String protobuf_str =
5
+ "message BigNumPair {\n "
6
+ + " required int64 long1 = 1;\n "
7
+ + " required int64 long2 = 2;\n "
8
+ + "}\n " ;
9
+
10
+ public long long1 ;
11
+ public long long2 ;
12
+ }
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .dataformat .protobuf ;
2
+
3
+ import com .fasterxml .jackson .databind .ObjectMapper ;
4
+ import com .fasterxml .jackson .dataformat .protobuf .schema .ProtobufSchema ;
5
+ import com .fasterxml .jackson .dataformat .protobuf .schema .ProtobufSchemaLoader ;
6
+ import org .junit .Test ;
7
+
8
+ import java .io .IOException ;
9
+
10
+ /**
11
+ * Created by miz on 8/10/16.
12
+ */
13
+ public class SerDeserLongTest {
14
+ @ Test
15
+ public void testWeirdLongSerDeser () throws IOException {
16
+ ObjectMapper mapper = new ObjectMapper (new ProtobufFactory ());
17
+ ProtobufSchema schema = ProtobufSchemaLoader .std .parse (BigNumPair .protobuf_str );
18
+
19
+ BigNumPair bnp = new BigNumPair ();
20
+ bnp .long1 = 72057594037927935L ;
21
+ bnp .long2 = 0 ;
22
+
23
+ byte [] encoded = mapper .writer (schema ).writeValueAsBytes (bnp );
24
+
25
+ BigNumPair parsed = mapper .readerFor (BigNumPair .class ).with (schema ).readValue (encoded );
26
+
27
+ assert parsed .long1 == bnp .long1 ;
28
+ assert parsed .long2 == bnp .long2 ;
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments