Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: micronaut-projects/micronaut-serialization
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.12.0
Choose a base ref
...
head repository: micronaut-projects/micronaut-serialization
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.13.0
Choose a head ref

Commits on Oct 30, 2024

  1. Copy the full SHA
    9cec9b8 View commit details

Commits on Nov 3, 2024

  1. chore(deps): update softprops/action-gh-release action to v2.0.9 (#962)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 3, 2024
    Copy the full SHA
    638d605 View commit details

Commits on Nov 5, 2024

  1. fix(deps): update dependency io.micronaut.gradle:micronaut-gradle-plu…

    …gin to v4.4.4 (#964)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 5, 2024
    Copy the full SHA
    67c4a80 View commit details

Commits on Nov 6, 2024

  1. fix(deps): update dependency io.micronaut:micronaut-core-bom to v4.7.2 (

    #965)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 6, 2024
    Copy the full SHA
    44c373c View commit details

Commits on Nov 9, 2024

  1. fix(deps): update dependency io.micronaut:micronaut-core-bom to v4.7.3 (

    #967)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 9, 2024
    Copy the full SHA
    5d793c8 View commit details

Commits on Nov 10, 2024

  1. fix(deps): update dependency org.mongodb:bson to v4.11.5 (#968)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 10, 2024
    Copy the full SHA
    628c669 View commit details

Commits on Nov 12, 2024

  1. fix(deps): update dependency io.micronaut:micronaut-core-bom to v4.7.4 (

    #970)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 12, 2024
    Copy the full SHA
    0af3b1b View commit details

Commits on Nov 14, 2024

  1. fix(deps): update dependency io.micronaut:micronaut-core-bom to v4.7.5 (

    #972)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 14, 2024
    Copy the full SHA
    09e35b9 View commit details

Commits on Nov 15, 2024

  1. chore(deps): update graalvm/setup-graalvm action to v1.2.6 (#973)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 15, 2024
    Copy the full SHA
    13b6392 View commit details

Commits on Nov 23, 2024

  1. fix(deps): update dependency io.micronaut:micronaut-core-bom to v4.7.6 (

    #979)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 23, 2024
    Copy the full SHA
    b166cd7 View commit details

Commits on Nov 26, 2024

  1. Add serde for jackson-databind JsonNode (#981)

    I added it to the support module so that it still works with a non-jackson ObjectMapper.
    yawkat authored Nov 26, 2024
    Copy the full SHA
    55a3cc1 View commit details
  2. fix(deps): update dependency io.micronaut.test:micronaut-test-bom to …

    …v4.6.0 (#977)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 26, 2024
    Copy the full SHA
    1fba830 View commit details
  3. chore(deps): update plugin io.micronaut.build.shared.settings to v7.3…

    ….0 (#978)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 26, 2024
    Copy the full SHA
    f7ea6e8 View commit details
  4. fix(deps): update dependency io.micronaut.platform:micronaut-platform…

    … to v4.7.1 (#976)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 26, 2024
    Copy the full SHA
    78f39c7 View commit details
  5. fix(deps): update dependency io.micronaut.oraclecloud:micronaut-oracl…

    …ecloud-bom to v4.3.1 (#975)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 26, 2024
    Copy the full SHA
    c818891 View commit details
  6. fix(deps): update dependency com.oracle.database.jdbc:ojdbc8 to v23.6…

    ….0.24.10 (#966)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 26, 2024
    Copy the full SHA
    9607026 View commit details
  7. Copy the full SHA
    570c093 View commit details
  8. fix(deps): update dependency io.micronaut.discovery:micronaut-discove…

    …ry-client to v4.5.0 (#969)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 26, 2024
    Copy the full SHA
    dde2322 View commit details
  9. chore(deps): update dependency gradle to v8.11.1 (#971)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 26, 2024
    Copy the full SHA
    96f34a0 View commit details

Commits on Nov 28, 2024

  1. Copy the full SHA
    c73282f View commit details
  2. Merge pull request #984 from micronaut-projects/2.12.x

    Merge 2.12.x into 2.13.x
    yawkat authored Nov 28, 2024
    Copy the full SHA
    f3f7470 View commit details
  3. Copy the full SHA
    76ee596 View commit details
22 changes: 15 additions & 7 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
{
"extends": [
"config:base"
"config:recommended"
],
"addLabels": [
"type: dependency-upgrade"
],
"addLabels": ["type: dependency-upgrade"],
"schedule": [
"after 10pm every day"
"after 10pm"
],
"prHourlyLimit": 1,
"prConcurrentLimit": 20,
"timezone": "Europe/Prague",
"packageRules": [
{
"matchPackagePatterns": ["actions.*"],
"dependencyDashboardApproval": true,
"matchUpdateTypes": ["patch"],
"matchUpdateTypes": [
"patch"
],
"matchCurrentVersion": "!/^0/",
"automerge": true
"automerge": true,
"matchPackageNames": [
"/actions.*/"
]
},
{
"matchUpdateTypes": ["patch"],
"matchUpdateTypes": [
"patch"
],
"matchCurrentVersion": "!/^0/",
"automerge": true
}
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ jobs:
fetch-depth: 0

- name: "🔧 Setup GraalVM CE"
uses: graalvm/setup-graalvm@v1.2.5
uses: graalvm/setup-graalvm@v1.2.6
with:
distribution: 'graalvm'
java-version: ${{ matrix.java }}
@@ -70,7 +70,7 @@ jobs:
- name: "📊 Publish Test Report"
if: always()
uses: mikepenz/action-junit-report@v4
uses: mikepenz/action-junit-report@v5
with:
check_name: Java CI / Test Report (${{ matrix.java }})
report_paths: '**/build/test-results/test/TEST-*.xml'
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -160,6 +160,6 @@ jobs:
- name: Upload assets
# Upload the artifacts to the existing release. Note that the SLSA provenance will
# attest to each artifact file and not the aggregated ZIP file.
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
with:
files: artifacts.zip
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
projectVersion=2.12.0
projectVersion=2.13.0
projectGroup=io.micronaut.serde

jsonbApi=https://jakarta.ee/specifications/jsonb/2.0/apidocs/jakarta/json/bind/annotation
16 changes: 8 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
managed-bson = "4.11.4"
managed-bson = "4.11.5"
managed-jakarta-json-api = "2.1.3"
managed-jakarta-json-bindApi = "3.0.1"
managed-eclipse-parsson = "1.1.7"
@@ -10,21 +10,21 @@ graal-svm = "23.1.5"
aws-lambda-events = "3.14.0"
aws-lambda-serialization = "1.1.5"
microstream-storage-restclient = "08.01.02-MS-GA"
oracle-jdbc-driver = "23.5.0.24.07"
oracle-jdbc-driver = "23.6.0.24.10"
jetbrains-annotations = "24.1.0"
jmh = "1.37"
groovy = "4.0.22"

micronaut = "4.7.1"
micronaut-platform = "4.6.3"
micronaut = "4.7.6"
micronaut-platform = "4.7.1"
micronaut-docs = "2.0.0"
micronaut-test = "4.5.0"
micronaut-discovery = "4.4.0"
micronaut-test = "4.6.0"
micronaut-discovery = "4.5.0"
micronaut-logging = "1.5.0"
micronaut-oracle-cloud = "4.2.1"
micronaut-oracle-cloud = "4.3.1"
micronaut-reactor = "3.6.0"
micronaut-validation = "4.8.0"
micronaut-gradle-plugin = "4.4.3"
micronaut-gradle-plugin = "4.4.4"

[libraries]
# Micronaut
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2017-2024 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.serde.jackson.builder.introspected;

import io.micronaut.core.annotation.Introspected;
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package io.micronaut.serde.jackson

import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.JsonNodeFactory
import com.fasterxml.jackson.databind.node.ObjectNode
import io.micronaut.serde.ObjectMapper
import io.micronaut.test.extensions.spock.annotation.MicronautTest
import jakarta.inject.Inject
import spock.lang.Specification

@MicronautTest(startApplication = false)
class JacksonJsonNodeSerdeSpec extends Specification {
@Inject
ObjectMapper objectMapper

def 'back and forth'(JsonNode node) {
when:
def json = objectMapper.writeValueAsString(node)
def back = objectMapper.readValue(json, JsonNode)
then:
back == node

where:
// commented nodes have ambiguous encoding with other nodes
node << [
JsonNodeFactory.instance.nullNode(),
JsonNodeFactory.instance.booleanNode(true),
JsonNodeFactory.instance.booleanNode(false),
JsonNodeFactory.instance.textNode("foo"),
JsonNodeFactory.instance.numberNode((byte) 1),
//JsonNodeFactory.instance.numberNode((short) 1),
JsonNodeFactory.instance.numberNode((int) 1),
JsonNodeFactory.instance.numberNode(Long.MAX_VALUE),
//JsonNodeFactory.instance.numberNode((float) 1),
JsonNodeFactory.instance.numberNode((double) 1),
JsonNodeFactory.instance.numberNode(BigInteger.valueOf(Long.MAX_VALUE) + 1),
//JsonNodeFactory.instance.numberNode(BigDecimal.valueOf(Double.MAX_VALUE) + 1.5),
//JsonNodeFactory.instance.binaryNode("foo".bytes),
JsonNodeFactory.instance.objectNode()
.<ObjectNode> set("p1", JsonNodeFactory.instance.numberNode(1))
.<ObjectNode> set("p2", JsonNodeFactory.instance.numberNode(2)),
JsonNodeFactory.instance.arrayNode().add(1).add(2),
]
}
}
1 change: 1 addition & 0 deletions serde-support/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ dependencies {

compileOnly(mn.micronaut.management)
compileOnly(libs.jetbrains.annotations)
compileOnly(mn.jackson.databind)

api(projects.micronautSerdeApi)

Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* Copyright 2017-2024 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.serde.support.serdes;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.core.type.Argument;
import io.micronaut.serde.Decoder;
import io.micronaut.serde.Encoder;
import io.micronaut.serde.support.SerdeRegistrar;

import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Map;

/**
* Serde for jackson-databind {@link JsonNode}.
*
* @since 2.13.0
* @author Jonas Konrad
* @implNote Recursive implementation. Recursion depth is limited by decoder/encoder constraints ({@link io.micronaut.serde.LimitingStream}) for security.
*/
final class JacksonJsonNodeSerde implements SerdeRegistrar<JsonNode> {
private static final @NonNull Argument<JsonNode> JSON_NODE_ARGUMENT = Argument.of(JsonNode.class);

@Override
public @NonNull Argument<JsonNode> getType() {
return JSON_NODE_ARGUMENT;
}

@Override
public JsonNode deserializeNullable(@NonNull Decoder decoder, @NonNull DecoderContext context, @NonNull Argument<? super JsonNode> type) throws IOException {
return deserialize(decoder, context, type);
}

@Override
public @Nullable JsonNode deserialize(@NonNull Decoder decoder, @NonNull DecoderContext context, @NonNull Argument<? super JsonNode> type) throws IOException {
return toJacksonNode(JsonNodeFactory.instance, decoder.decodeNode());
}

private static JsonNode toJacksonNode(JsonNodeFactory factory, io.micronaut.json.tree.JsonNode mnNode) {
if (mnNode.isArray()) {
ArrayNode n = factory.arrayNode(mnNode.size());
for (io.micronaut.json.tree.JsonNode value : mnNode.values()) {
n.add(toJacksonNode(factory, value));
}
return n;
} else if (mnNode.isObject()) {
ObjectNode n = factory.objectNode();
for (Map.Entry<String, io.micronaut.json.tree.JsonNode> entry : mnNode.entries()) {
n.set(entry.getKey(), toJacksonNode(factory, entry.getValue()));
}
return n;
} else if (mnNode.isNull()) {
return factory.nullNode();
} else if (mnNode.isBoolean()) {
return factory.booleanNode(mnNode.getBooleanValue());
} else if (mnNode.isString()) {
return factory.textNode(mnNode.getStringValue());
} else {
Number numberValue = mnNode.getNumberValue();
if (numberValue instanceof Integer) {
return factory.numberNode(numberValue.intValue());
} else if (numberValue instanceof Long) {
return factory.numberNode(numberValue.longValue());
} else if (numberValue instanceof Short) {
return factory.numberNode(numberValue.shortValue());
} else if (numberValue instanceof Byte) {
return factory.numberNode(numberValue.byteValue());
} else if (numberValue instanceof Float) {
return factory.numberNode(numberValue.floatValue());
} else if (numberValue instanceof BigInteger bi) {
return factory.numberNode(bi);
} else if (numberValue instanceof BigDecimal bd) {
return factory.numberNode(bd);
} else {
// double, other number types
return factory.numberNode(numberValue.doubleValue());
}
}
}

@Override
public void serialize(@NonNull Encoder encoder, @NonNull EncoderContext context, @NonNull Argument<? extends JsonNode> type, @NonNull JsonNode node) throws IOException {
switch (node.getNodeType()) {
case BOOLEAN -> encoder.encodeBoolean(node.booleanValue());
case NULL -> encoder.encodeNull();
case NUMBER -> JsonNodeSerde.encodeNumber(encoder, node.numberValue());
case STRING -> encoder.encodeString(node.textValue());
case BINARY -> encoder.encodeBinary(node.binaryValue());
case ARRAY -> {
try (Encoder array = encoder.encodeArray(JSON_NODE_ARGUMENT)) {
for (JsonNode member : node) {
serialize(array, context, type, member);
}
}
}
case OBJECT -> {
try (Encoder obj = encoder.encodeObject(JSON_NODE_ARGUMENT)) {
for (String k : (Iterable<String>) node::fieldNames) {
obj.encodeKey(k);
serialize(encoder, context, type, node.get(k));
}
}
}
default -> throw new IllegalArgumentException("Cannot serialize jackson-databind JsonNode of type " + node.getNodeType());
}
}
}
Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@

@Internal
final class JsonNodeSerde implements SerdeRegistrar<JsonNode> {

@Override
public void serialize(Encoder encoder, EncoderContext context, Argument<? extends JsonNode> type, JsonNode value)
throws IOException {
@@ -47,23 +46,7 @@ private void serialize0(Encoder encoder, JsonNode value) throws IOException {
} else if (value.isString()) {
encoder.encodeString(value.getStringValue());
} else if (value.isNumber()) {
Number numberValue = value.getNumberValue();
if (numberValue instanceof Integer) {
encoder.encodeInt(numberValue.intValue());
} else if (numberValue instanceof Long) {
encoder.encodeLong(numberValue.longValue());
} else if (numberValue instanceof Short) {
encoder.encodeShort(numberValue.shortValue());
} else if (numberValue instanceof Byte) {
encoder.encodeByte(numberValue.byteValue());
} else if (numberValue instanceof BigInteger bi) {
encoder.encodeBigInteger(bi);
} else if (numberValue instanceof BigDecimal bd) {
encoder.encodeBigDecimal(bd);
} else {
// double, float, other number types
encoder.encodeDouble(numberValue.doubleValue());
}
encodeNumber(encoder, value.getNumberValue());
} else if (value.isObject()) {
Encoder objectEncoder = encoder.encodeObject(Argument.of(JsonNode.class));
for (Map.Entry<String, JsonNode> entry : value.entries()) {
@@ -82,6 +65,25 @@ private void serialize0(Encoder encoder, JsonNode value) throws IOException {
}
}

static void encodeNumber(Encoder encoder, Number numberValue) throws IOException {
if (numberValue instanceof Integer) {
encoder.encodeInt(numberValue.intValue());
} else if (numberValue instanceof Long) {
encoder.encodeLong(numberValue.longValue());
} else if (numberValue instanceof Short) {
encoder.encodeShort(numberValue.shortValue());
} else if (numberValue instanceof Byte) {
encoder.encodeByte(numberValue.byteValue());
} else if (numberValue instanceof BigInteger bi) {
encoder.encodeBigInteger(bi);
} else if (numberValue instanceof BigDecimal bd) {
encoder.encodeBigDecimal(bd);
} else {
// double, float, other number types
encoder.encodeDouble(numberValue.doubleValue());
}
}

@Override
public JsonNode deserialize(Decoder decoder, DecoderContext decoderContext, Argument<? super JsonNode> type)
throws IOException {
Original file line number Diff line number Diff line change
@@ -122,6 +122,15 @@ public static void register(SerdeConfiguration serdeConfiguration,
consumer.accept(new ZonedDateTimeSerde(serdeConfiguration));
consumer.accept(new EnumSerde<>(introspections));
consumer.accept(new InetAddressSerde(serdeConfiguration));
SerdeRegistrar<?> jacksonJsonNodeSerde;
try {
jacksonJsonNodeSerde = new JacksonJsonNodeSerde();
} catch (LinkageError ignored) {
jacksonJsonNodeSerde = null;
}
if (jacksonJsonNodeSerde != null) {
consumer.accept(jacksonJsonNodeSerde);
}
}

}
Loading