jakartaee / jakartaee/jsonb-api
Float Encoding
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 96
- Forks
- 42
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 35
Description
BasicJavaTypesMappingTest#testFloatMapping tests the serialization of Float.MAX_VALUE. The testing harness contains the following lines. The comments with "mtd" are mine and explain the problem:
// value Float.MAX_VALUE can have E38 or E+38, depending on impl
representation = representation.replace("E38", "E[\\+]?\\+38");
if (!(testValue instanceof Number)) {
representation = Pattern.quote(representation);
// quote numbers that do not fit into double decimal precision
} else {
...
}
There are several problems:
- After the replacement, the regex matches
E+38andE++38, but notE38like the comment mentions. testValueis never assigned a value, i.e. it's alwaysnull, which means that!(testValue instanceof Number)is alwaystrue. This in itself is weird.- Becuase the condition is always true, the regex is always quoted. That means that the replacement (which adds regex control characters like
[,+,]) become literal. This is also wrong.
Due to these issues, the TCK test does not accept a value of ...E38.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with BasicJavaTypesMappingTest#testFloatMapping and the shown testing-harness code. Reproduce the Float.MAX_VALUE case, inspect how testValue is initialized, and verify regex behavior for E38 and E+38. Done means the TCK accepts valid Float.MAX_VALUE representations without quoting regex controls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 62/100