Untyped read collapses a number literal that does not fit a double
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Start by tracing Java's ForyJson.fromJson handling for Object.class and compare it with the BigDecimal.class path; the issue does not name source files or tests. Reproduce with the decimal literal in the report and check how untyped reads represent fractional numbers. Done means untyped reads preserve all digits and avoid converting values such as 1e400 to infinity.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Search before asking
- I had searched in the issues and found no similar issues.
Version
1.7.7
Component(s)
Java
Minimal reproduce step
fromJson(doc, Object.class) is useful to an application that has to resolve a type after it reads the document, which is what a schemaless cache does. The read keeps a large integer, but it converts any other number to a double first, so a literal with more digits than a double holds is reduced before the application sees it.
import org.apache.fory.json.ForyJson;
import java.math.BigDecimal;
public class NumberLiteralLost {
public static void main(String[] args) {
ForyJson json = ForyJson.builder().withFieldMode(true).build();
String literal = "1.234567890123456789012345678901234567890";
byte[] doc = literal.getBytes();
Object untyped = json.fromJson(doc, Object.class);
System.out.println("read as Object : " + untyped + " (" + untyped.getClass().getName() + ")");
System.out.println("read as BigDecimal : " + json.fromJson(doc, BigDecimal.class));
System.out.println("the literal : " + literal);
}
}
What did you expect to see?
The digits kept, so that the application can build the type it later resolves. Reading the same bytes with BigDecimal.class is exact, as the second line shows, so the parser holds the whole literal at some point.
What did you see instead?
A Double with 17 significant digits. The remaining digits are gone before the application is given the value. 1e400 becomes Infinity in the same way, and 0.1000000000000000055511151231257827021181583404541015625 becomes 0.1.
A large integer is kept: 123456789012345678901234567890 is read as a BigInteger. Only a non-integer literal is reduced.
Anything Else?
No response
Are you willing to submit a PR?
- I'm willing to submit a PR!
- Ngôn ngữ chính
- Java
- Star
- 4.6k
- Fork
- 470
- Merge trung bình
- 9 giờ 28 phút
- Pull request đã merge (30 ngày)
- 33
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/fory
-
[Python] Compatible xlang read silently drops fields when the peer writes camelCase/PascalCase namesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Build] Add ASF license headers to config files that allow commentsCó thể làm lại được @Swatantra-66 đã nhận 27 ngày trước và không có pull request nào đang mở. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/fory#4124 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
xlang: the snake_case conversion of field names is not specified, and the runtimes do not agreeCó thể làm lại được @dhruv-dagar đã nhận 14 ngày trước và không có pull request nào đang mở. Đang mởbug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
apache/fory#4187 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Rust] Add an option to use Rust native enumCó thể đã có người làm @BaldDemian đã nhận 18 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
apache/fory#4177 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Registered factory cannot tell a field from the root of the callCó thể đã có người làm @mohitjoshi-hey đã nhận 17 ngày trước. Đang mởbug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 48/100
apache/fory#4169 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
BindingServiceProperties.bindings regressed to a non-thread-safe TreeMap in GH-3158: concurrent first use of binding names corrupts itCó thể đã có người làm @AkashB23 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
spring-cloud/spring-cloud-stream#3321 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] 资源包列表 与 模组/数据包/世界 列表排列顺序不一致Có thể đã có người làm @fishdry1000 đã nhận 4 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-driven-fuzzing bug claude Minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
linagora/twake-calendar-side-service#1333 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
AtlasOfLivingAustralia/species-lists#882 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Type/Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
ballerina-platform/ballerina-library#9458 ·
Maintainer thường phản hồi trong vòng 1 ngày