Skip to content

Commit

Permalink
Adopt Jackson 2.16.1
Browse files Browse the repository at this point in the history
Signed-off-by: jansupol <jan.supol@oracle.com>
  • Loading branch information
jansupol authored and senivam committed Jan 3, 2024
1 parent bd7774f commit c3d3132
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 24 deletions.
2 changes: 1 addition & 1 deletion NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Javassist Version 3.29.2-GA
* Project: http://www.javassist.org/
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.

Jackson JAX-RS Providers Version 2.15.2
Jackson JAX-RS Providers Version 2.16.1
* License: Apache License, 2.0
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
* Copyright: (c) 2009-2023 FasterXML, LLC. All rights reserved unless otherwise indicated.
Expand Down
2 changes: 1 addition & 1 deletion examples/NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Javassist Version 3.29.2-GA
* Project: http://www.javassist.org/
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.

Jackson JAX-RS Providers Version 2.15.2
Jackson JAX-RS Providers Version 2.16.1
* License: Apache License, 2.0
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
* Copyright: (c) 2009-2023 FasterXML, LLC. All rights reserved unless otherwise indicated.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -122,7 +122,11 @@ private void updateFactoryConstraints(JsonFactory jsonFactory) {
final StreamReadConstraints constraints = jsonFactory.streamReadConstraints();
jsonFactory.setStreamReadConstraints(
StreamReadConstraints.builder()
// our
.maxStringLength(maxStringLength)
// customers
.maxDocumentLength(constraints.getMaxDocumentLength())
.maxNameLength(constraints.getMaxNameLength())
.maxNestingDepth(constraints.getMaxNestingDepth())
.maxNumberLength(constraints.getMaxNumberLength())
.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -26,6 +26,7 @@
import org.glassfish.jersey.message.filtering.spi.EntityGraphProvider;
import org.glassfish.jersey.message.filtering.spi.EntityInspector;
import org.glassfish.jersey.message.filtering.spi.ObjectGraph;
import org.glassfish.jersey.message.filtering.spi.ScopeProvider;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonMappingException;
Expand All @@ -37,7 +38,6 @@
import com.fasterxml.jackson.databind.ser.PropertyFilter;
import com.fasterxml.jackson.databind.ser.PropertyWriter;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import org.glassfish.jersey.message.filtering.spi.ScopeProvider;

import javax.inject.Inject;
import javax.ws.rs.core.Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.ObjectWriterInjector;
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.ObjectWriterModifier;
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.util.ClassKey;
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.util.LRUMap;

import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonGenerator;
Expand All @@ -44,6 +43,7 @@
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.util.LRUMap;
import com.fasterxml.jackson.databind.type.TypeFactory;

public abstract class ProviderBase<
Expand Down Expand Up @@ -1056,4 +1056,4 @@ protected static void _addSuperTypes(Class<?> cls, Class<?> endBefore, Collectio
private final THIS _this() {
return (THIS) this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public enum JaxRSFeature implements ConfigFeature
* @since 2.15
*/
READ_FULL_STREAM(true),

/*
/**********************************************************
/* HTTP headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public final class PackageVersion implements Versioned {
public final static Version VERSION = VersionUtil.parseVersion(
"2.15.2", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider");
"2.16.1", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider");

@Override
public Version version() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import java.util.LinkedHashMap;
import java.util.Map;

// TO BE REMOVED FROM JACKSON 2.18 or later
/**
* Helper for simple bounded LRU maps used for reusing lookup values.
*
* @since 2.2
*
* @deprecated Since 2.16.1 Use one from {@code jackson-databind} instead.
*/
@Deprecated // since 2.16.1
@SuppressWarnings("serial")
public class LRUMap<K,V> extends LinkedHashMap<K,V>
{
Expand All @@ -24,5 +28,4 @@ protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
{
return size() > _maxEntries;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The project maintains the following source code repositories:

## Third-party Content

Jackson JAX-RS Providers version 2.15.2
Jackson JAX-RS Providers version 2.16.1
* License: Apache License, 2.0
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
* Copyright: (c) 2009-2023 FasterXML, LLC. All rights reserved unless otherwise indicated.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -30,6 +30,7 @@
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;


import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -48,9 +49,10 @@ public final void testDisabledModule() {
.register(JacksonFeature.class)
.register(TestJacksonJaxbJsonProvider.class)
.property("jersey.config.json.jackson.disabled.modules", "Jdk8Module");
final String response = target("JAXBEntity")
.request().get(String.class);
assertNotEquals("{\"key\":\"key\",\"value\":\"value\"}", response);
try (Response response = target("JAXBEntity").request().get()) {
assertEquals(400, response.getStatus());
assertNotEquals("{\"key\":\"key\",\"value\":\"value\"}", response.readEntity(String.class));
}
}

private static class TestJacksonJaxbJsonProvider extends JacksonJaxbJsonProvider {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -22,7 +22,9 @@
import org.junit.jupiter.api.Test;

import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

public class DefaultJsonJacksonProviderForEnabledModulesTest extends JerseyTest {
Expand All @@ -34,9 +36,10 @@ protected final Application configure() {

@Test
public final void testDisabledModule() {
final String response = target("entity/simple")
.request().get(String.class);
assertNotEquals("{\"name\":\"Hello\",\"value\":\"World\"}", response);
try (Response response = target("entity/simple").request().get()) {
assertEquals(400, response.getStatus());
assertNotEquals("{\"name\":\"Hello\",\"value\":\"World\"}", response.readEntity(String.class));
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -54,6 +54,7 @@
import java.util.List;

public class StreamReadConstrainsTest extends JerseyTest {
private static final String ERROR_MSG_PART = "maximum allowed (";

@Override
protected final Application configure() {
Expand Down Expand Up @@ -82,7 +83,7 @@ void testNumberLength() {
.post(Entity.entity(new MyEntity(8), MediaType.APPLICATION_JSON_TYPE))) {
Assertions.assertEquals(200, response.getStatus());
String errorMsg = response.readEntity(String.class);
Assertions.assertTrue(errorMsg.contains("maximum length (4)"));
Assertions.assertTrue(errorMsg.contains(ERROR_MSG_PART + 4));
}
}

Expand Down Expand Up @@ -129,7 +130,7 @@ void testConstraintOnClient(WebTarget target, int expectedLength) {
throw ex;
}
String errorMsg = ex.getCause().getMessage();
Assertions.assertTrue(errorMsg.contains("maximum length (" + String.valueOf(expectedLength) + ")"));
Assertions.assertTrue(errorMsg.contains(ERROR_MSG_PART + String.valueOf(expectedLength)));
}
}

Expand All @@ -141,7 +142,7 @@ void testStreamReadConstraintsMethods() {
+ " Please update the code in " + DefaultJacksonJaxbJsonProvider.class.getName()
+ " updateFactoryConstraints method";
Method[] method = StreamReadConstraints.Builder.class.getDeclaredMethods();
Assertions.assertEquals(4, method.length, message); // three max + build methods
Assertions.assertEquals(6, method.length, message); // five setMax... + build() methods
}

@Path("len")
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2010, 2024 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -2248,7 +2248,7 @@
<xmlunit.version>2.9.1</xmlunit.version>
<httpclient.version>4.5.14</httpclient.version>
<httpclient5.version>5.2.1</httpclient5.version>
<jackson.version>2.15.2</jackson.version>
<jackson.version>2.16.1</jackson.version>
<jackson1.version>1.9.13</jackson1.version>
<javassist.version>3.29.2-GA</javassist.version>
<jersey1.version>1.19.3</jersey1.version>
Expand Down

0 comments on commit c3d3132

Please sign in to comment.