Browse Source

Merge branch '5.1.x'

pull/22881/head
Juergen Hoeller 6 years ago
parent
commit
eaa9a78d5d
  1. 4
      build.gradle
  2. 14
      spring-core/src/main/java/org/springframework/core/type/filter/AbstractTypeHierarchyTraversingFilter.java
  3. 8
      spring-core/src/main/java/org/springframework/util/SerializationUtils.java
  4. 20
      spring-core/src/test/java/org/springframework/util/SerializationTestUtils.java
  5. 7
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java
  6. 18
      spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java
  7. 18
      spring-jms/src/main/java/org/springframework/jms/listener/endpoint/DefaultJmsActivationSpecFactory.java
  8. 6
      spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java
  9. 6
      spring-web/src/main/java/org/springframework/web/method/annotation/AbstractWebArgumentResolverAdapter.java
  10. 6
      spring-webflux/src/main/java/org/springframework/web/reactive/resource/CachingResourceTransformer.java
  11. 6
      spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/LocaleChangeInterceptor.java
  12. 6
      spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceTransformer.java

4
build.gradle

@ -34,11 +34,11 @@ ext {
groovyVersion = "2.5.6" groovyVersion = "2.5.6"
hsqldbVersion = "2.4.1" hsqldbVersion = "2.4.1"
jackson2Version = "2.9.8" jackson2Version = "2.9.8"
jettyVersion = "9.4.17.v20190418" jettyVersion = "9.4.18.v20190429"
junit5Version = "5.4.2" junit5Version = "5.4.2"
kotlinVersion = "1.3.31" kotlinVersion = "1.3.31"
log4jVersion = "2.11.2" log4jVersion = "2.11.2"
nettyVersion = "4.1.35.Final" nettyVersion = "4.1.36.Final"
reactorVersion = "Dysprosium-BUILD-SNAPSHOT" reactorVersion = "Dysprosium-BUILD-SNAPSHOT"
rxjavaVersion = "1.3.8" rxjavaVersion = "1.3.8"
rxjavaAdapterVersion = "1.2.1" rxjavaAdapterVersion = "1.2.1"

14
spring-core/src/main/java/org/springframework/core/type/filter/AbstractTypeHierarchyTraversingFilter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -85,8 +85,10 @@ public abstract class AbstractTypeHierarchyTraversingFilter implements TypeFilte
} }
} }
catch (IOException ex) { catch (IOException ex) {
logger.debug("Could not read super class [" + metadata.getSuperClassName() + if (logger.isDebugEnabled()) {
"] of type-filtered class [" + metadata.getClassName() + "]"); logger.debug("Could not read super class [" + metadata.getSuperClassName() +
"] of type-filtered class [" + metadata.getClassName() + "]");
}
} }
} }
} }
@ -109,8 +111,10 @@ public abstract class AbstractTypeHierarchyTraversingFilter implements TypeFilte
} }
} }
catch (IOException ex) { catch (IOException ex) {
logger.debug("Could not read interface [" + ifc + "] for type-filtered class [" + if (logger.isDebugEnabled()) {
metadata.getClassName() + "]"); logger.debug("Could not read interface [" + ifc + "] for type-filtered class [" +
metadata.getClassName() + "]");
}
} }
} }
} }

8
spring-core/src/main/java/org/springframework/util/SerializationUtils.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -43,8 +43,7 @@ public abstract class SerializationUtils {
return null; return null;
} }
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
try { try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(object); oos.writeObject(object);
oos.flush(); oos.flush();
} }
@ -64,8 +63,7 @@ public abstract class SerializationUtils {
if (bytes == null) { if (bytes == null) {
return null; return null;
} }
try { try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes))) {
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
return ois.readObject(); return ois.readObject();
} }
catch (IOException ex) { catch (IOException ex) {

20
spring-core/src/test/java/org/springframework/util/SerializationTestUtils.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,8 +34,9 @@ public class SerializationTestUtils {
public static void testSerialization(Object o) throws IOException { public static void testSerialization(Object o) throws IOException {
OutputStream baos = new ByteArrayOutputStream(); OutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos); try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
oos.writeObject(o); oos.writeObject(o);
}
} }
public static boolean isSerializable(Object o) throws IOException { public static boolean isSerializable(Object o) throws IOException {
@ -50,16 +51,17 @@ public class SerializationTestUtils {
public static Object serializeAndDeserialize(Object o) throws IOException, ClassNotFoundException { public static Object serializeAndDeserialize(Object o) throws IOException, ClassNotFoundException {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos); try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
oos.writeObject(o); oos.writeObject(o);
oos.flush(); oos.flush();
}
baos.flush(); baos.flush();
byte[] bytes = baos.toByteArray(); byte[] bytes = baos.toByteArray();
ByteArrayInputStream is = new ByteArrayInputStream(bytes); ByteArrayInputStream is = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(is); try (ObjectInputStream ois = new ObjectInputStream(is)) {
Object o2 = ois.readObject(); return ois.readObject();
return o2; }
} }
} }

7
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package org.springframework.jdbc.datasource.embedded;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -42,7 +43,9 @@ abstract class AbstractEmbeddedDatabaseConfigurer implements EmbeddedDatabaseCon
try { try {
con = dataSource.getConnection(); con = dataSource.getConnection();
if (con != null) { if (con != null) {
con.createStatement().execute("SHUTDOWN"); try (Statement stmt = con.createStatement()) {
stmt.execute("SHUTDOWN");
}
} }
} }
catch (SQLException ex) { catch (SQLException ex) {

18
spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -74,13 +74,15 @@ public final class CustomSQLExceptionTranslatorRegistry {
*/ */
public void registerTranslator(String dbName, SQLExceptionTranslator translator) { public void registerTranslator(String dbName, SQLExceptionTranslator translator) {
SQLExceptionTranslator replaced = this.translatorMap.put(dbName, translator); SQLExceptionTranslator replaced = this.translatorMap.put(dbName, translator);
if (replaced != null) { if (logger.isDebugEnabled()) {
logger.debug("Replacing custom translator [" + replaced + "] for database '" + dbName + if (replaced != null) {
"' with [" + translator + "]"); logger.debug("Replacing custom translator [" + replaced + "] for database '" + dbName +
} "' with [" + translator + "]");
else { }
logger.debug("Adding custom translator of type [" + translator.getClass().getName() + else {
"] for database '" + dbName + "'"); logger.debug("Adding custom translator of type [" + translator.getClass().getName() +
"] for database '" + dbName + "'");
}
} }
} }

18
spring-jms/src/main/java/org/springframework/jms/listener/endpoint/DefaultJmsActivationSpecFactory.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -85,7 +85,9 @@ public class DefaultJmsActivationSpecFactory extends StandardJmsActivationSpecFa
return adapter.getClass().getClassLoader().loadClass(specClassName); return adapter.getClass().getClassLoader().loadClass(specClassName);
} }
catch (ClassNotFoundException ex) { catch (ClassNotFoundException ex) {
logger.debug("No default <Provider>ActivationSpec class found: " + specClassName); if (logger.isDebugEnabled()) {
logger.debug("No default <Provider>ActivationSpec class found: " + specClassName);
}
} }
} }
@ -98,7 +100,9 @@ public class DefaultJmsActivationSpecFactory extends StandardJmsActivationSpecFa
return adapter.getClass().getClassLoader().loadClass(specClassName); return adapter.getClass().getClassLoader().loadClass(specClassName);
} }
catch (ClassNotFoundException ex) { catch (ClassNotFoundException ex) {
logger.debug("No default <Provider>ActivationSpecImpl class found: " + specClassName); if (logger.isDebugEnabled()) {
logger.debug("No default <Provider>ActivationSpecImpl class found: " + specClassName);
}
} }
} }
@ -109,7 +113,9 @@ public class DefaultJmsActivationSpecFactory extends StandardJmsActivationSpecFa
return adapter.getClass().getClassLoader().loadClass(specClassName); return adapter.getClass().getClassLoader().loadClass(specClassName);
} }
catch (ClassNotFoundException ex) { catch (ClassNotFoundException ex) {
logger.debug("No default ActivationSpecImpl class found in provider package: " + specClassName); if (logger.isDebugEnabled()) {
logger.debug("No default ActivationSpecImpl class found in provider package: " + specClassName);
}
} }
// ActivationSpecImpl class in "inbound" subpackage (WebSphere MQ 6.0.2.1) // ActivationSpecImpl class in "inbound" subpackage (WebSphere MQ 6.0.2.1)
@ -118,7 +124,9 @@ public class DefaultJmsActivationSpecFactory extends StandardJmsActivationSpecFa
return adapter.getClass().getClassLoader().loadClass(specClassName); return adapter.getClass().getClassLoader().loadClass(specClassName);
} }
catch (ClassNotFoundException ex) { catch (ClassNotFoundException ex) {
logger.debug("No default ActivationSpecImpl class found in inbound subpackage: " + specClassName); if (logger.isDebugEnabled()) {
logger.debug("No default ActivationSpecImpl class found in inbound subpackage: " + specClassName);
}
} }
throw new IllegalStateException("No ActivationSpec class defined - " + throw new IllegalStateException("No ActivationSpec class defined - " +

6
spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -64,8 +64,8 @@ public final class MediaTypeFactory {
* @return a multi-value map, mapping media types to file extensions. * @return a multi-value map, mapping media types to file extensions.
*/ */
private static MultiValueMap<String, MediaType> parseMimeTypes() { private static MultiValueMap<String, MediaType> parseMimeTypes() {
try (InputStream is = MediaTypeFactory.class.getResourceAsStream(MIME_TYPES_FILE_NAME)) { InputStream is = MediaTypeFactory.class.getResourceAsStream(MIME_TYPES_FILE_NAME);
BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.US_ASCII)); try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.US_ASCII))) {
MultiValueMap<String, MediaType> result = new LinkedMultiValueMap<>(); MultiValueMap<String, MediaType> result = new LinkedMultiValueMap<>();
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {

6
spring-web/src/main/java/org/springframework/web/method/annotation/AbstractWebArgumentResolverAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -81,7 +81,9 @@ public abstract class AbstractWebArgumentResolverAdapter implements HandlerMetho
} }
catch (Exception ex) { catch (Exception ex) {
// ignore (see class-level doc) // ignore (see class-level doc)
logger.debug("Error in checking support for parameter [" + parameter + "], message: " + ex.getMessage()); if (logger.isDebugEnabled()) {
logger.debug("Error in checking support for parameter [" + parameter + "]: " + ex.getMessage());
}
return false; return false;
} }
} }

6
spring-webflux/src/main/java/org/springframework/web/reactive/resource/CachingResourceTransformer.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -69,7 +69,9 @@ public class CachingResourceTransformer implements ResourceTransformer {
Resource cachedResource = this.cache.get(resource, Resource.class); Resource cachedResource = this.cache.get(resource, Resource.class);
if (cachedResource != null) { if (cachedResource != null) {
logger.trace(exchange.getLogPrefix() + "Resource resolved from cache"); if (logger.isTraceEnabled()) {
logger.trace(exchange.getLogPrefix() + "Resource resolved from cache");
}
return Mono.just(cachedResource); return Mono.just(cachedResource);
} }

6
spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/LocaleChangeInterceptor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -154,7 +154,9 @@ public class LocaleChangeInterceptor extends HandlerInterceptorAdapter {
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
if (isIgnoreInvalidLocale()) { if (isIgnoreInvalidLocale()) {
logger.debug("Ignoring invalid locale value [" + newLocale + "]: " + ex.getMessage()); if (logger.isDebugEnabled()) {
logger.debug("Ignoring invalid locale value [" + newLocale + "]: " + ex.getMessage());
}
} }
else { else {
throw ex; throw ex;

6
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceTransformer.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -71,9 +71,7 @@ public class CachingResourceTransformer implements ResourceTransformer {
Resource transformed = this.cache.get(resource, Resource.class); Resource transformed = this.cache.get(resource, Resource.class);
if (transformed != null) { if (transformed != null) {
if (logger.isTraceEnabled()) { logger.trace("Resource resolved from cache");
logger.trace("Resource resolved from cache");
}
return transformed; return transformed;
} }

Loading…
Cancel
Save