Skip to content

Commit b756991

Browse files
authored
Merge branch '2.18' into textbuffer-double-float-parse
2 parents cb7248f + b8a132e commit b756991

File tree

202 files changed

+3489
-2243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+3489
-2243
lines changed

.github/workflows/main.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ on:
44
branches:
55
- master
66
- "3.0"
7-
- "2.17"
7+
- "2.18"
88
paths-ignore:
99
- "README.md"
1010
- "release-notes/*"
1111
pull_request:
1212
branches:
1313
- master
1414
- "3.0"
15-
- "2.17"
15+
- "2.18"
1616
paths-ignore:
1717
- "README.md"
1818
- "release-notes/*"
@@ -30,9 +30,9 @@ jobs:
3030
env:
3131
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
3232
steps:
33-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
33+
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
3434
- name: Set up JDK
35-
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
35+
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
3636
with:
3737
distribution: 'temurin'
3838
java-version: ${{ matrix.java_version }}
@@ -63,7 +63,7 @@ jobs:
6363
run: ./mvnw -B -q -ff -ntp test
6464
- name: Publish code coverage
6565
if: github.event_name != 'pull_request' && matrix.java_version == '8'
66-
uses: codecov/codecov-action@0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1 # v4.0.2
66+
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
6767
with:
6868
token: ${{ secrets.CODECOV_TOKEN }}
6969
file: ./target/site/jacoco/jacoco.xml

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ jobs:
2828
- name: Validate version name
2929
run: |
3030
[[ "$TAG" =~ jackson-core-[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)? ]] || exit 1
31-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
31+
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
3232
- name: Set up JDK
33-
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
33+
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
3434
with:
3535
distribution: "temurin"
3636
java-version: "8"
@@ -75,7 +75,7 @@ jobs:
7575
actions: read # To read the workflow path.
7676
id-token: write # To sign the provenance.
7777
contents: write # To add assets to a release.
78-
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.9.0
78+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.10.0
7979
with:
8080
base64-subjects: "${{ needs.release.outputs.hash }}"
8181
provenance-name: "${{ needs.release.outputs.artifact_name }}.jar.intoto.jsonl"

.github/workflows/scorecard.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
steps:
3131
- name: "Checkout code"
32-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
32+
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
3333
with:
3434
persist-credentials: false
3535

@@ -60,6 +60,6 @@ jobs:
6060

6161
# Upload the results to GitHub's code scanning dashboard.
6262
- name: "Upload to code-scanning"
63-
uses: github/codeql-action/upload-sarif@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
63+
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
6464
with:
6565
sarif_file: results.sarif

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
<parent>
99
<groupId>com.fasterxml.jackson</groupId>
1010
<artifactId>jackson-base</artifactId>
11-
<version>2.17.0-SNAPSHOT</version>
11+
<version>2.18.0-SNAPSHOT</version>
1212
</parent>
1313
<groupId>com.fasterxml.jackson.core</groupId>
1414
<artifactId>jackson-core</artifactId>
1515
<name>Jackson-core</name>
16-
<version>2.17.0-SNAPSHOT</version>
16+
<version>2.18.0-SNAPSHOT</version>
1717
<packaging>jar</packaging>
1818
<description>Core Jackson processing abstractions (aka Streaming API), implementation for JSON</description>
1919
<licenses>

release-notes/VERSION-2.x

+12-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ a pure JSON library.
1414
=== Releases ===
1515
------------------------------------------------------------------------
1616

17-
2.17.0-rc1 (26-Feb-2024)
17+
2.18.0 (not yet released)
18+
19+
-
20+
21+
2.17.1 (not yet released)
22+
23+
#1241: Fix `NumberInput.looksLikeValidNumber()` implementation
24+
(contributed by @pjfanning)
25+
26+
2.17.0 (12-Mar-2024)
1827

1928
#507: Add `JsonWriteFeature.ESCAPE_FORWARD_SLASHES` to allow escaping of '/' for
2029
String values
@@ -51,9 +60,9 @@ a pure JSON library.
5160
#1218: Simplify Unicode surrogate pair conversion for generation
5261
(contributed by @xtonik)
5362

54-
2.16.2 (not yet released)
63+
2.16.2 (09-Mar-2024)
5564

56-
-
65+
No changes since 2.16.1
5766

5867
2.16.1 (24-Dec-2023)
5968

src/main/java/com/fasterxml/jackson/core/JsonParser.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -1769,15 +1769,30 @@ public Object getNumberValueDeferred() throws IOException {
17691769
* {@link JsonToken#VALUE_NUMBER_FLOAT}, returns
17701770
* one of {@link NumberTypeFP} constants; otherwise returns
17711771
* {@link NumberTypeFP#UNKNOWN}.
1772+
*<p>
1773+
* Default implementation as of Jackson 2.x will call {@link #getNumberType()}
1774+
* and translate types -- this needs to be overriden actual implementations
1775+
* if this is not sufficient (which it usually is not for textual formats).
17721776
*
1773-
* @return Type of current number, if parser points to numeric token; {@code null} otherwise
1777+
* @return Type of current floating-point number, if parser points to numeric token;
1778+
* {@link NumberTypeFP#UNKNOWN} otherwise.
17741779
*
17751780
* @throws IOException for low-level read issues, or
17761781
* {@link JsonParseException} for decoding problems
17771782
*
17781783
* @since 2.17
17791784
*/
17801785
public NumberTypeFP getNumberTypeFP() throws IOException {
1786+
NumberType nt = getNumberType();
1787+
if (nt == NumberType.BIG_DECIMAL) {
1788+
return NumberTypeFP.BIG_DECIMAL;
1789+
}
1790+
if (nt == NumberType.DOUBLE) {
1791+
return NumberTypeFP.DOUBLE64;
1792+
}
1793+
if (nt == NumberType.FLOAT) {
1794+
return NumberTypeFP.FLOAT32;
1795+
}
17811796
return NumberTypeFP.UNKNOWN;
17821797
}
17831798

src/main/java/com/fasterxml/jackson/core/io/NumberInput.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public final class NumberInput
3939
* @since 2.17
4040
*/
4141
private final static Pattern PATTERN_FLOAT = Pattern.compile(
42-
"[+-]?[0-9]+(\\.[0-9]+)?([eE][+-]?[0-9]+)?");
42+
"[+-]?[0-9]*[\\.]?[0-9]+([eE][+-]?[0-9]+)?");
4343

4444
/**
4545
* Fast method for parsing unsigned integers that are known to fit into
@@ -622,6 +622,9 @@ public static BigInteger parseBigIntegerWithRadix(final String s, final int radi
622622
*<p>
623623
* Note: no trimming ({@code String.trim()}) nor null checks are performed
624624
* on String passed.
625+
*<p>
626+
* Note: this method returning {@code true} DOES NOT GUARANTEE String is valid
627+
* number but just that it looks close enough.
625628
*
626629
* @param s String to validate
627630
*
@@ -630,6 +633,14 @@ public static BigInteger parseBigIntegerWithRadix(final String s, final int radi
630633
* @since 2.17
631634
*/
632635
public static boolean looksLikeValidNumber(final String s) {
633-
return (s != null) && PATTERN_FLOAT.matcher(s).matches();
636+
// While PATTERN_FLOAT handles most cases we can optimize some simple ones:
637+
if (s == null || s.isEmpty()) {
638+
return false;
639+
}
640+
if (s.length() == 1) {
641+
char c = s.charAt(0);
642+
return (c <= '9') && (c >= '0');
643+
}
644+
return PATTERN_FLOAT.matcher(s).matches();
634645
}
635646
}

src/main/java/com/fasterxml/jackson/core/json/JsonParserBase.java

+22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.fasterxml.jackson.core.json;
22

3+
import java.io.IOException;
4+
35
import com.fasterxml.jackson.core.*;
6+
import com.fasterxml.jackson.core.JsonParser.NumberTypeFP;
47
import com.fasterxml.jackson.core.base.ParserBase;
58
import com.fasterxml.jackson.core.io.CharTypes;
69
import com.fasterxml.jackson.core.io.IOContext;
@@ -80,6 +83,25 @@ public final JacksonFeatureSet<StreamReadCapability> getReadCapabilities() {
8083
return JSON_READ_CAPABILITIES;
8184
}
8285

86+
/*
87+
/**********************************************************************
88+
/* Overrides
89+
/**********************************************************************
90+
*/
91+
92+
/**
93+
* JSON format does not have native information on "correct" floating-point
94+
* type to use, unlike some formats (most binary formats), so it needs to
95+
* indicate this as {@link NumberTypeFP#UNKNOWN}.
96+
*
97+
* @return Natural floating-point type if known; {@link NumberTypeFP#UNKNOWN} for
98+
* all JSON-backed parsers.
99+
*/
100+
@Override // added in 2.17
101+
public NumberTypeFP getNumberTypeFP() throws IOException {
102+
return NumberTypeFP.UNKNOWN;
103+
}
104+
83105
/*
84106
/**********************************************************************
85107
/* Location handling

0 commit comments

Comments
 (0)