Skip to content

Commit

Permalink
Merge branch '2.19' into 4388-try-another
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder authored Feb 8, 2025
2 parents ee48c89 + 0578116 commit 2a70f63
Show file tree
Hide file tree
Showing 30 changed files with 475 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cifuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
dry-run: false
language: jvm
- name: Upload Crash
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
uses: github/codeql-action/autobuild@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
uses: github/codeql-action/analyze@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
2 changes: 1 addition & 1 deletion .github/workflows/dep_build_v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up JDK
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dep_build_v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
ref: master
- name: Set up JDK
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up JDK
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
run: ./mvnw -B -q -ff -ntp test
- name: Publish code coverage
if: ${{ matrix.release_build && github.event_name != 'pull_request' }}
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./target/site/jacoco/jacoco.xml
Expand Down
13 changes: 13 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,10 @@ wrongwrong (@k163377)
* Reported #4878: When serializing a Map via Converter(StdDelegatingSerializer),
a NullPointerException is thrown due to missing key serializer
(2.18.3)
* Contributed fix for #4444: The `KeyDeserializer` specified in the class with
`@JsonDeserialize(keyUsing = ...)` is overwritten by the `KeyDeserializer`
specified in the `ObjectMapper`.
(2.18.3)

Bernd Ahlers (@bernd)
* Reported #4742: Deserialization with Builder, External type id, `@JsonCreator` failing
Expand Down Expand Up @@ -1900,3 +1904,12 @@ Konstantin Maliuga (@badoken)
Lars Benedetto (@lbenedetto)
* Contributed #4676: Support other enum naming strategies than camelCase
(2.19.0)

Floris Westerman (@FWest98)
* Reported #4934: `DeserializationContext.readTreeAsValue()` handles null nodes
differently from `ObjectMapper.treeToValue()`
(2.19.0)

Joren Inghelbrecht (@jin-harmoney)
* Contributed #4953: Allow clearing all caches to avoid classloader leaks
(2.19.0)
12 changes: 12 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ Project: jackson-databind
#4869: Add `JsonNode.values()` to replace `elements()`
#4896: Coercion shouldn't be necessary for Enums specifying an empty string
(reported by @joaocanaverde-blue)
#4934: `DeserializationContext.readTreeAsValue()` handles null nodes
differently from `ObjectMapper.treeToValue()`
(reported by Floris W)
#4953: Allow clearing all caches to avoid classloader leaks
(contributed by Joren I)
2.18.3 (not yet released)
#4444: The `KeyDeserializer` specified in the class with `@JsonDeserialize(keyUsing = ...)`
is overwritten by the `KeyDeserializer` specified in the `ObjectMapper`.
(fix by @wrongwrong)
#4827: Subclassed Throwable deserialization fails since v2.18.0 - no creator
index for property 'cause'
(reported by @nilswieber)
Expand All @@ -64,8 +72,12 @@ Project: jackson-databind
#4908: Deserialization behavior change with @JsonCreator and
@ConstructorProperties between 2.17 and 2.18
(reported by Gustavo B)
#4917: `BigDecimal` deserialization issue when using `@JsonCreator`
(reported by @dbachdev)
#4922: Failing `@JsonMerge` with a custom Map
(reported by @nlisker)
#4932: Conversion of `MissingNode` throws `JsonProcessingException`
(reported by @ludgerb)
2.18.2 (27-Nov-2024)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,19 @@ public final KeyDeserializer findKeyDeserializer(JavaType keyType,
return kd;
}

/**
* Method that will drop all dynamically constructed deserializers (ones that
* are counted as result value for {@link DeserializerCache#cachedDeserializersCount}).
* This can be used to remove memory usage (in case some deserializers are
* only used once or so), or to force re-construction of deserializers after
* configuration changes for mapper than owns the provider.
* @since 2.19
*/
public void flushCachedDeserializers() {
_cache.flushCachedDeserializers();
}

/*
/**********************************************************
/* Public API, ObjectId handling
Expand Down Expand Up @@ -989,9 +1002,9 @@ public <T> T readValue(JsonParser p, JavaType type) throws IOException {
return reportBadDefinition(type,
"Could not find JsonDeserializer for type "+ClassUtil.getTypeDescription(type));
}
return (T) deser.deserialize(p, this);
return (T) _readValue(p, deser);
}

/**
* Convenience method that may be used by composite or container deserializers,
* for reading one-off values for the composite type, taking into account
Expand Down Expand Up @@ -1023,7 +1036,7 @@ public <T> T readPropertyValue(JsonParser p, BeanProperty prop, JavaType type) t
"Could not find JsonDeserializer for type %s (via property %s)",
ClassUtil.getTypeDescription(type), ClassUtil.nameOf(prop)));
}
return (T) deser.deserialize(p, this);
return (T) _readValue(p, deser);
}

/**
Expand Down Expand Up @@ -1074,7 +1087,7 @@ public JsonNode readTree(JsonParser p) throws IOException {
*/
public <T> T readTreeAsValue(JsonNode n, Class<T> targetType) throws IOException
{
if (n == null) {
if (n == null || n.isMissingNode()) {
return null;
}
try (TreeTraversingParser p = _treeAsTokens(n)) {
Expand All @@ -1098,7 +1111,7 @@ public <T> T readTreeAsValue(JsonNode n, Class<T> targetType) throws IOException
*/
public <T> T readTreeAsValue(JsonNode n, JavaType targetType) throws IOException
{
if (n == null) {
if (n == null || n.isMissingNode()) {
return null;
}
try (TreeTraversingParser p = _treeAsTokens(n)) {
Expand All @@ -1116,6 +1129,20 @@ private TreeTraversingParser _treeAsTokens(JsonNode n) throws IOException
return p;
}

/**
* Helper method that should handle special cases for deserialization; most
* notably handling {@code null} (and possibly absent values).
*
* @since 2.19
*/
private Object _readValue(JsonParser p, JsonDeserializer<Object> deser) throws IOException
{
if (p.hasToken(JsonToken.VALUE_NULL)) {
return deser.getNullValue(this);
}
return deser.deserialize(p, this);
}

/*
/**********************************************************
/* Methods for problem handling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,15 @@ public enum DeserializationFeature implements ConfigFeature

/**
* Feature that can be enabled to allow JSON empty String
* value ("") to be bound as `null` for POJOs and other structured
* value ({@code ""}) to be bound as {@code null} for POJOs and other structured
* values ({@link java.util.Map}s, {@link java.util.Collection}s).
* If disabled, standard POJOs can only be bound from JSON `null` or
* If disabled, standard POJOs can only be bound from JSON {@code null} or
* JSON Object (standard meaning that no custom deserializers or
* constructors are defined; both of which can add support for other
* kinds of JSON values); if enabled, empty JSON String can be taken
* to be equivalent of JSON null.
*<p>
* NOTE: this does NOT apply to scalar values such as booleans, numbers
* NOTE: this does NOT apply to scalar values such as Strings, booleans, numbers
* and date/time types;
* whether these can be coerced depends on
* {@link MapperFeature#ALLOW_COERCION_OF_SCALARS}.
Expand All @@ -390,13 +390,13 @@ public enum DeserializationFeature implements ConfigFeature

/**
* Feature that can be enabled to allow empty JSON Array
* value (that is, <code>[ ]</code>) to be bound to POJOs (and
* with 2.9, other values too) as `null`.
* If disabled, standard POJOs can only be bound from JSON `null` or
* value (that is, {@code[ ]} to be bound to POJOs (and
* with 2.9, other values too) as {@code null}.
* If disabled, standard POJOs can only be bound from JSON {@code null} or
* JSON Object (standard meaning that no custom deserializers or
* constructors are defined; both of which can add support for other
* kinds of JSON values); if enabled, empty JSON Array will be taken
* to be equivalent of JSON null.
* to be equivalent of JSON {@code null}.
*<p>
* Feature is disabled by default.
*
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4789,6 +4789,27 @@ public void acceptJsonFormatVisitor(JavaType type, JsonFormatVisitorWrapper visi
_serializerProvider(getSerializationConfig()).acceptJsonFormatVisitor(type, visitor);
}

/*
/**********************************************************
/* Extended Public API: caches
/**********************************************************
*/

/**
* Method that will clear all caches this mapper owns.
*<p>
* This method should not be needed in normal operation, but may be
* useful to avoid class-loader memory leaks when reloading applications.
*
* @since 2.19
*/
public void clearCaches() {
_rootDeserializers.clear();
_typeFactory.clearCache();
_deserializationContext.flushCachedDeserializers();
_serializerProvider.flushCachedSerializers();
}

/*
/**********************************************************
/* Internal factory methods for type ids, overridable
Expand Down Expand Up @@ -4916,6 +4937,9 @@ protected Object _readValue(DeserializationConfig cfg, JsonParser p,
result = _findRootDeserializer(ctxt, valueType).getNullValue(ctxt);
} else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) {
result = null;
} else if (t == JsonToken.NOT_AVAILABLE) {
// 28-Jan-2025, tatu: [databind#4932] Need to handle this case too
result = null;
} else { // pointing to event other than null
result = ctxt.readRootValue(p, valueType, _findRootDeserializer(ctxt, valueType), null);
}
Expand All @@ -4940,6 +4964,9 @@ protected Object _readMapAndClose(JsonParser p0, JavaType valueType)
result = _findRootDeserializer(ctxt, valueType).getNullValue(ctxt);
} else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) {
result = null;
} else if (t == JsonToken.NOT_AVAILABLE) {
// 28-Jan-2025, tatu: [databind#4932] Need to handle this case too
result = null;
} else {
result = ctxt.readRootValue(p, valueType,
_findRootDeserializer(ctxt, valueType), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2094,6 +2094,9 @@ protected Object _bind(JsonParser p, Object valueToUpdate) throws IOException
}
} else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) {
result = valueToUpdate;
} else if (t == JsonToken.NOT_AVAILABLE) {
// 28-Jan-2025, tatu: [databind#4932] Need to handle this case too
result = valueToUpdate;
} else { // pointing to event other than null
result = ctxt.readRootValue(p, _valueType, _findRootDeserializer(ctxt), _valueToUpdate);
}
Expand All @@ -2120,6 +2123,9 @@ protected Object _bindAndClose(JsonParser p0) throws IOException
}
} else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) {
result = _valueToUpdate;
} else if (t == JsonToken.NOT_AVAILABLE) {
// 28-Jan-2025, tatu: [databind#4932] Need to handle this case too
result = _valueToUpdate;
} else {
result = ctxt.readRootValue(p, _valueType, _findRootDeserializer(ctxt), _valueToUpdate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,9 @@ public enum SerializationFeature implements ConfigFeature
* representation may mean either simple number, or an array of numbers,
* depending on type.
*<p>
* Note: whether {@link java.util.Map} keys are serialized as Strings
* or not is controlled using {@link #WRITE_DATE_KEYS_AS_TIMESTAMPS}.
*<p>
* Feature is enabled by default, so that period/duration are by default
* serialized as timestamps.
* Feature is enabled by default in Jackson 2.x, so that period/duration values
* are by default serialized as timestamps.
* It will be disabled by default in Jackson 3.x.
*
* @since 2.5
*/
Expand Down
Loading

0 comments on commit 2a70f63

Please sign in to comment.