Jakarta EE 9 migration
Upgrades many dependency declarations; removes old EJB 2.x support and outdated Servlet-based integrations (Commons FileUpload, FreeMarker JSP support, Tiles). Closes gh-22093 Closes gh-25354 Closes gh-26185 Closes gh-27423 See gh-27424
This commit is contained in:
@@ -21,9 +21,9 @@ import java.io.Writer;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import javax.json.bind.Jsonb;
|
||||
import javax.json.bind.JsonbBuilder;
|
||||
import javax.json.bind.JsonbConfig;
|
||||
import jakarta.json.bind.Jsonb;
|
||||
import jakarta.json.bind.JsonbBuilder;
|
||||
import jakarta.json.bind.JsonbConfig;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -33,8 +33,8 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 5.3
|
||||
* @see javax.json.bind.Jsonb
|
||||
* @see javax.json.bind.JsonbBuilder
|
||||
* @see jakarta.json.bind.Jsonb
|
||||
* @see jakarta.json.bind.JsonbBuilder
|
||||
* @see #setJsonb
|
||||
*/
|
||||
public class JsonbMessageConverter extends AbstractJsonMessageConverter {
|
||||
|
||||
@@ -63,7 +63,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
* {@link DataBuffer DataBuffer}.
|
||||
*
|
||||
* <p>Validation is applied if the method argument is annotated with
|
||||
* {@code @javax.validation.Valid} or
|
||||
* {@code @jakarta.validation.Valid} or
|
||||
* {@link org.springframework.validation.annotation.Validated}. Validation
|
||||
* failure results in an {@link MethodArgumentNotValidException}.
|
||||
*
|
||||
@@ -143,7 +143,7 @@ public class PayloadMethodArgumentResolver implements HandlerMethodArgumentResol
|
||||
* {@link Decoder}.
|
||||
*
|
||||
* <p>Validation is applied if the method argument is annotated with
|
||||
* {@code @javax.validation.Valid} or
|
||||
* {@code @jakarta.validation.Valid} or
|
||||
* {@link org.springframework.validation.annotation.Validated}. Validation
|
||||
* failure results in an {@link MethodArgumentNotValidException}.
|
||||
*
|
||||
|
||||
@@ -190,7 +190,7 @@ public class PayloadMethodArgumentResolver implements HandlerMethodArgumentResol
|
||||
|
||||
/**
|
||||
* Validate the payload if applicable.
|
||||
* <p>The default implementation checks for {@code @javax.validation.Valid},
|
||||
* <p>The default implementation checks for {@code @jakarta.validation.Valid},
|
||||
* Spring's {@link Validated},
|
||||
* and custom annotations whose name starts with "Valid".
|
||||
* @param message the currently processed message
|
||||
|
||||
@@ -112,7 +112,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
jackson2Present = ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) &&
|
||||
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", classLoader);
|
||||
gsonPresent = ClassUtils.isPresent("com.google.gson.Gson", classLoader);
|
||||
jsonbPresent = ClassUtils.isPresent("javax.json.bind.Jsonb", classLoader);
|
||||
jsonbPresent = ClassUtils.isPresent("jakarta.json.bind.Jsonb", classLoader);
|
||||
kotlinSerializationJsonPresent = ClassUtils.isPresent("kotlinx.serialization.json.Json", classLoader);
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
if (this.applicationContext != null && this.applicationContext.containsBean(MVC_VALIDATOR_NAME)) {
|
||||
validator = this.applicationContext.getBean(MVC_VALIDATOR_NAME, Validator.class);
|
||||
}
|
||||
else if (ClassUtils.isPresent("javax.validation.Validator", getClass().getClassLoader())) {
|
||||
else if (ClassUtils.isPresent("jakarta.validation.Validator", getClass().getClassLoader())) {
|
||||
Class<?> clazz;
|
||||
try {
|
||||
String className = "org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -74,8 +75,8 @@ public class JsonbMessageConverterTests {
|
||||
HashMap<String, Object> actual = (HashMap<String, Object>) converter.fromMessage(message, HashMap.class);
|
||||
|
||||
assertThat(actual.get("string")).isEqualTo("Foo");
|
||||
assertThat(actual.get("number")).isEqualTo(42);
|
||||
assertThat((Double) actual.get("fraction")).isCloseTo(42D, within(0D));
|
||||
assertThat(actual.get("number")).isEqualTo(new BigDecimal(42));
|
||||
assertThat((BigDecimal) actual.get("fraction")).isCloseTo(new BigDecimal(42), within(new BigDecimal(0)));
|
||||
assertThat(actual.get("array")).isEqualTo(Arrays.asList("Foo", "Bar"));
|
||||
assertThat(actual.get("bool")).isEqualTo(Boolean.TRUE);
|
||||
}
|
||||
@@ -165,7 +166,7 @@ public class JsonbMessageConverterTests {
|
||||
String payload = "H\u00e9llo W\u00f6rld";
|
||||
Message<?> message = converter.toMessage(payload, headers);
|
||||
|
||||
assertThat(new String((byte[]) message.getPayload(), StandardCharsets.UTF_16BE)).isEqualTo(payload);
|
||||
assertThat(new String((byte[]) message.getPayload(), StandardCharsets.UTF_16BE)).isEqualTo("\"" + payload + "\"");
|
||||
assertThat(message.getHeaders().get(MessageHeaders.CONTENT_TYPE)).isEqualTo(contentType);
|
||||
}
|
||||
|
||||
@@ -181,7 +182,7 @@ public class JsonbMessageConverterTests {
|
||||
String payload = "H\u00e9llo W\u00f6rld";
|
||||
Message<?> message = converter.toMessage(payload, headers);
|
||||
|
||||
assertThat(message.getPayload()).isEqualTo(payload);
|
||||
assertThat(message.getPayload()).isEqualTo("\"" + payload + "\"");
|
||||
assertThat(message.getHeaders().get(MessageHeaders.CONTENT_TYPE)).isEqualTo(contentType);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@ package org.springframework.messaging.converter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.xmlunit.diff.DifferenceEvaluator;
|
||||
|
||||
Reference in New Issue
Block a user