Skip to content

Commit

Permalink
Merge branch '2.17' into fix-4388
Browse files Browse the repository at this point in the history
  • Loading branch information
JooHyukKim authored Apr 8, 2024
2 parents f1fbff3 + 01f24af commit ce2a83e
Show file tree
Hide file tree
Showing 101 changed files with 1,209 additions and 198 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
uses: github/codeql-action/init@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
uses: github/codeql-action/autobuild@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
uses: github/codeql-action/analyze@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Set up JDK
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
run: ./mvnw -B -q -ff -ntp test
- name: Publish code coverage
if: github.event_name != 'pull_request' && matrix.java_version == '8'
uses: codecov/codecov-action@0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1 # v4.0.2
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./target/site/jacoco/jacoco.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Set up JDK
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
Expand Down
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<parent>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-base</artifactId>
<version>2.17.0-SNAPSHOT</version>
<version>2.17.1-SNAPSHOT</version>
</parent>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.0-SNAPSHOT</version>
<version>2.17.1-SNAPSHOT</version>
<name>jackson-databind</name>
<packaging>jar</packaging>
<description>General data-binding functionality for Jackson: works on core streaming API</description>
Expand Down Expand Up @@ -68,7 +68,7 @@
<version.powermock>2.0.9</version.powermock>

<!-- for Reproducible Builds -->
<project.build.outputTimestamp>2024-02-27T01:47:51Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2024-03-12T21:52:43Z</project.build.outputTimestamp>
</properties>

<dependencies>
Expand Down Expand Up @@ -144,6 +144,7 @@
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.14.9</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
34 changes: 29 additions & 5 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -1730,20 +1730,44 @@ Jan Pachol (janpacho@github)
(2.16.0)

Pieter Dirk Soels (Badbond@github)
* Reprted #4302: Problem deserializing some type of Enums when using
* Reported #4302: Problem deserializing some type of Enums when using
`PropertyNamingStrategy`
(2.16.2)

Stephane Bailliez (sbailliez@github)
* Reported #4409: Deserialization of enums with name defined with different cases
leads to `InvalidDefinitionException`: Multiple fields representing property
(2.16.2)

Muhammad Khalikov (mukham12@github)
* Contributed fix for #4209: Make `BeanDeserializerModifier`/`BeanSerializerModifier`
implement `java.io.Serializable`
(2.17.0)
implement `java.io.Serializable`
(2.17.0)

Eduard Dudar (edudar@github)
* Contributed #4299: Some `Collection` and `Map` fallbacks don't work in GraalVM native image
(2.17.0)
(2.17.0)
Jesper Blomquist (jebl01@github)
* Contributed #4393: Deserialize `java.util.UUID` encoded as Base64 and base64Url with or
without padding
(2.17.0)
(2.17.0)
András Péteri (apeteri@github)
* Suggested #4416: Deprecate `JsonNode.asText(String)`
(2.17.0)
Kyrylo Merzlikin (kirmerzlikin@github)
* Contributed fix for #2543: Introspection includes delegating ctor's
only parameter as a property in `BeanDescription`
(2.17.0)

Miguel Mendes Ruiz (migmruiz@github)
* Reported #4428: `ByteBuddy` scope went beyond `test` in version 2.17.0
(2.17.1)

Oddbjørn Kvalsund (oddbjornkvalsund@github)
* Reported, contributed fix for #4430: Use `ReentrantLock` instead of `synchronized`
in `DeserializerCache` to avoid deadlock on pinning
(2.17.1)

40 changes: 37 additions & 3 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,40 @@ Project: jackson-databind
=== Releases ===
------------------------------------------------------------------------

2.17.0-rc1 (26-Feb-2024)
2.18.0 (not yet released)

-

2.17.1 (not yet released)

#4428: `ByteBuddy` scope went beyond `test` in version 2.17.0
(reported by Miguel M-R)
(fix by Joo-Hyuk K)
#4430: Use `ReentrantLock` instead of `synchronized` in `DeserializerCache`
to avoid deadlock on pinning
(reported, fix contributed by Oddbjørn K)
#4435: Cannot deserialize value of type `java.math.BigDecimal` from
String ".05": not a valid representation
(reported by @EAlf91)
(fix by @pjfanning)
#4441: `@JsonSetter(nulls = Nulls.SKIP)` doesn't work in some situations
(reported by @Asapin)
(fix by Joo-Hyuk K)
#4450: Empty QName deserialized as `null`
(reported by @winfriedgerlach)
2.17.0 (12-Mar-2024)
#437: Support throwing `MismatchedInputException` when deserializing
properties that are not part of the view
(contributed by Joo-Hyuk K)
#736: `MapperFeature.REQUIRE_SETTERS_FOR_GETTERS` has no effect
(reported by @migel)
(fix contributed by Joo-Hyuk K)
#2543: Introspection includes delegating ctor's only parameter as
a property in `BeanDescription`
(reported by @nikita2206)
(fix contributed by Kyrylo M)
#4160: Deprecate `DefaultTyping.EVERYTHING` in `2.x` and remove in `3.0`
(contributed by Joo-Hyuk K)
#4194: Add `JsonNodeFeature.FAIL_ON_NAN_TO_BIG_DECIMAL_COERCION` option to
Expand Down Expand Up @@ -45,9 +71,13 @@ Project: jackson-databind
#4394: Better Base64 support for `java.util.UUIDs`
without padding
(fix contributed by Jesper B)
#4403: Deserialization of unknown value for enums does not yield default enum value
(reported by @dominik-henning)
#4416: Deprecate `JsonNode.asText(String)`
(suggested by András P)
- JUnit5 upgraded to 5.10.1
2.16.2 (not yet released)
2.16.2 (09-Mar-2024)
#4302: Problem deserializing some type of Enums when using `PropertyNamingStrategy`
(reported by Pieter D-S)
Expand All @@ -61,6 +91,10 @@ Project: jackson-databind
#4355: Jackson 2.16 fails attempting to obtain `ObjectWriter` for an `Enum` of which
some value returns null from `toString()`
(reported by @YutaHiguchi-bsn)
#4409: Deserialization of enums with name defined with different cases leads to
`InvalidDefinitionException`: Multiple fields representing property
(reported by Stephane B)
(fix contributed by Joo-Hyuk K)

2.16.1 (24-Dec-2023)

Expand All @@ -77,7 +111,7 @@ Project: jackson-databind

#1770: Incorrect deserialization for `BigDecimal` numbers
(reported by @cristian-mocanu-mob)
(fix contributed by @pjfanning)
(fix by @pjfanning)
#2502: Add a way to configure caches Jackson uses
(contributed by Joo-Hyuk K)
#2787: Mix-ins do not work for `Enum`s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,25 @@ public AnnotatedMember findAnySetterField() {
* defined by defaults and possible annotations.
* Note that this may be further refined by per-property annotations.
*
* @since 2.17
*/
public abstract JsonFormat.Value findExpectedFormat();

/**
* @since 2.1
* @deprecated Since 2.17 use {@link #findExpectedFormat()}
*/
public abstract JsonFormat.Value findExpectedFormat(JsonFormat.Value defValue);
@Deprecated // since 2.17
public JsonFormat.Value findExpectedFormat(JsonFormat.Value defValue) {
JsonFormat.Value v = findExpectedFormat();
if (defValue == null) {
return v;
}
if (v == null) {
return defValue;
}
return defValue.withOverrides(v);
}

/**
* Method for finding {@link Converter} used for serializing instances
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/fasterxml/jackson/databind/JsonNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,16 @@ public byte[] binaryValue() throws IOException {
* <code>defaultValue</code> in cases where null value would be returned;
* either for missing nodes (trying to access missing property, or element
* at invalid item for array) or explicit nulls.
*<p>
* NOTE: deprecated since 2.17 because {@link #asText()} very rarely returns
* {@code null} for any node types -- in fact, neither {@link MissingNode}
* nor {@code NullNode} return {@code null} from {@link #asText()}.
*
* @since 2.4
*
* @deprecated Since 2.17, to be removed from 3.0
*/
@Deprecated // @since 2.17
public String asText(String defaultValue) {
String str = asText();
return (str == null) ? defaultValue : str;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ protected BeanDeserializerBase(BeanDeserializerBuilder builder,
;

// Any transformation we may need to apply?
final JsonFormat.Value format = beanDesc.findExpectedFormat(null);
final JsonFormat.Value format = beanDesc.findExpectedFormat();
_serializationShape = format.getShape();

_needViewProcesing = hasViews;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ protected Map<String,List<PropertyName>> _collectAliases(Collection<SettableBean
protected boolean _findCaseInsensitivity() {
// 07-May-2020, tatu: First find combination of per-type config overrides (higher
// precedence) and per-type annotations (lower):
JsonFormat.Value format = _beanDesc.findExpectedFormat(null);
JsonFormat.Value format = _beanDesc.findExpectedFormat();
// and see if any of those has explicit definition; if not, use global baseline default
Boolean B = format.getFeature(JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
return (B == null) ? _config.isEnabled(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fasterxml.jackson.databind.deser;

import java.util.HashMap;
import java.util.concurrent.locks.ReentrantLock;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.*;
Expand Down Expand Up @@ -52,6 +53,12 @@ public final class DeserializerCache
protected final HashMap<JavaType, JsonDeserializer<Object>> _incompleteDeserializers
= new HashMap<JavaType, JsonDeserializer<Object>>(8);


/**
* We hold an explicit lock while creating deserializers to avoid creating duplicates.
*/
private final ReentrantLock _incompleteDeserializersLock = new ReentrantLock();

/*
/**********************************************************
/* Life-cycle
Expand Down Expand Up @@ -246,7 +253,9 @@ protected JsonDeserializer<Object> _createAndCacheValueDeserializer(Deserializat
* limitations necessary to ensure that only completely initialized ones
* are visible and used.
*/
synchronized (_incompleteDeserializers) {
try {
_incompleteDeserializersLock.lock();

// Ok, then: could it be that due to a race condition, deserializer can now be found?
JsonDeserializer<Object> deser = _findCachedDeserializer(type);
if (deser != null) {
Expand All @@ -269,6 +278,8 @@ protected JsonDeserializer<Object> _createAndCacheValueDeserializer(Deserializat
_incompleteDeserializers.clear();
}
}
} finally {
_incompleteDeserializersLock.unlock();
}
}

Expand Down Expand Up @@ -406,7 +417,7 @@ protected JsonDeserializer<?> _createDeserializer2(DeserializationContext ctxt,
// Ideally we'd determine it bit later on (to allow custom handler checks)
// but that won't work for other reasons. So do it here.
// (read: rewrite for 3.0)
JsonFormat.Value format = beanDesc.findExpectedFormat(null);
JsonFormat.Value format = beanDesc.findExpectedFormat();
if (format.getShape() != JsonFormat.Shape.OBJECT) {
MapLikeType mlt = (MapLikeType) type;
if (mlt instanceof MapType) {
Expand All @@ -421,7 +432,7 @@ protected JsonDeserializer<?> _createDeserializer2(DeserializationContext ctxt,
* (to allow custom handler checks), but that won't work for other
* reasons. So do it here.
*/
JsonFormat.Value format = beanDesc.findExpectedFormat(null);
JsonFormat.Value format = beanDesc.findExpectedFormat();
if (format.getShape() != JsonFormat.Shape.OBJECT) {
CollectionLikeType clt = (CollectionLikeType) type;
if (clt instanceof CollectionType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ public Object deserializeSetAndReturn(JsonParser p,
@Override
public void set(Object instance, Object value) throws IOException
{
if (value == null) {
if (_skipNulls) {
return;
}
}
try {
_field.set(instance, value);
} catch (Exception e) {
Expand All @@ -197,6 +202,11 @@ public void set(Object instance, Object value) throws IOException
@Override
public Object setAndReturn(Object instance, Object value) throws IOException
{
if (value == null) {
if (_skipNulls) {
return instance;
}
}
try {
_field.set(instance, value);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ public Object deserializeSetAndReturn(JsonParser p,
@Override
public final void set(Object instance, Object value) throws IOException
{
if (value == null) {
if (_skipNulls) {
return;
}
}
try {
_setter.invoke(instance, value);
} catch (Exception e) {
Expand All @@ -189,6 +194,11 @@ public final void set(Object instance, Object value) throws IOException
@Override
public Object setAndReturn(Object instance, Object value) throws IOException
{
if (value == null) {
if (_skipNulls) {
return instance;
}
}
try {
Object result = _setter.invoke(instance, value);
return (result == null) ? instance : result;
Expand Down
Loading

0 comments on commit ce2a83e

Please sign in to comment.