jakartaee / jakartaee/jsonb-api

Float Encoding

Open
#229 0 comments 0 reactions 0 assignees View on GitHub

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+38 and E++38, but not E38 like the comment mentions.
  • testValue is never assigned a value, i.e. it's always null, which means that !(testValue instanceof Number) is always true. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.