FasterXML / FasterXML/jackson-core

JsonParser.getCurrentLocation is not updated for `DataInput` input

Đang mở
#601 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
2.4k
Fork
928
Merge trung bình
2 ngày 18 giờ
Pull request đã merge (30 ngày)
24

Mô tả

### Issue

Using a `JsonParser` instantiated via `JsonParser.createParser(DataInput)` does not update `JsonLocation` values returned by `JsonParser.getCurrentLocation` (everything defaults to -1).

Switching to `JsonParser.createParser(InputStream)` with the same input object populates the `JsonLocation` data as expected.

### Use case

I use `JsonParser` to manually extract slices of Netty byte buffers (that contain Json). To feed Netty ByteBufs to JsonParser, I have to wrap the `ByteBuf` in a `ByteBufInputStream` which `extends InputStream` and `implements DataInput`. `JsonParser` accepts both types so explicit casting is required.

* This works and populates `JsonLocation` values:
```
ByteBuf buf = ...;
JsonParser parser = JSON_FACTORY.createParser((InputStream) new ByteBufInputStream(buf));
```
* This does not populate `JsonLocation` values:
```
ByteBuf buf = ...;
JsonParser parser = JSON_FACTORY.createParser((DataInput) new ByteBufInputStream(buf));
```

Issue affects at least versions 2.9.8 and 2.10.2.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.