From 5eca512c462ad20aa7c058a224447cd717e7a2e2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 5 Feb 2019 00:41:53 +0100 Subject: [PATCH 1/6] Ref doc mentions SimpleTransactionScope next to SimpleThreadScope Closes gh-22180 --- src/docs/asciidoc/core/core-beans.adoc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc index e434098c494..411d8400380 100644 --- a/src/docs/asciidoc/core/core-beans.adoc +++ b/src/docs/asciidoc/core/core-beans.adoc @@ -2586,10 +2586,11 @@ The following table describes the supported scopes: the context of a web-aware Spring `ApplicationContext`. |=== -NOTE: As of Spring 3.0, a thread scope is available but is not registered by default. For -more information, see the documentation for -{api-spring-framework}/context/support/SimpleThreadScope.html[`SimpleThreadScope`]. -For instructions on how to register this or any other custom scope, see +NOTE: As of Spring 3.0, a thread scope is available but is not registered by default: +see {api-spring-framework}/context/support/SimpleThreadScope.html[`SimpleThreadScope`]. +As of Spring 4.2, a transaction scope is available as well: +{api-spring-framework}/transaction/support/SimpleTransactionScope.html[`SimpleTransactionScope`]. +For instructions on how to register these or any other custom scopes, see <>. From ca7634dfe8389e2be85874628e12fac6dd781466 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 5 Feb 2019 00:42:24 +0100 Subject: [PATCH 2/6] Avoid duplicate class introspection during findAnnotationOnBean Closes gh-22318 --- .../beans/factory/support/DefaultListableBeanFactory.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 416a40bd198..7fc0d24f214 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -677,7 +677,10 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto if (bd instanceof AbstractBeanDefinition) { AbstractBeanDefinition abd = (AbstractBeanDefinition) bd; if (abd.hasBeanClass()) { - ann = AnnotationUtils.findAnnotation(abd.getBeanClass(), annotationType); + Class beanClass = abd.getBeanClass(); + if (beanClass != beanType) { + ann = AnnotationUtils.findAnnotation(beanClass, annotationType); + } } } } From 59a9c8e0049cf3e17a0466985b324b8103d60f58 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 5 Feb 2019 00:43:56 +0100 Subject: [PATCH 3/6] MethodReference.MethodValueRef.setValue throws SpelEvaluationException Closes gh-22336 --- .../springframework/expression/spel/ast/MethodReference.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java index 9dd732e535e..244a6c6dd99 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.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"); * you may not use this file except in compliance with the License. @@ -395,7 +395,7 @@ public class MethodReference extends SpelNodeImpl { @Override public void setValue(@Nullable Object newValue) { - throw new IllegalAccessError(); + throw new SpelEvaluationException(0, SpelMessage.NOT_ASSIGNABLE, MethodReference.this.name); } @Override From 0ebc020b21b4818eef22c187c7001bac28c40b91 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 5 Feb 2019 00:44:52 +0100 Subject: [PATCH 4/6] Load-time weaving support for WildFly 13+ (JBoss Modules 1.8+) Fixes gh-22297 --- .../jboss/JBossLoadTimeWeaver.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/instrument/classloading/jboss/JBossLoadTimeWeaver.java b/spring-context/src/main/java/org/springframework/instrument/classloading/jboss/JBossLoadTimeWeaver.java index bee9d2e86df..cd458113b44 100644 --- a/spring-context/src/main/java/org/springframework/instrument/classloading/jboss/JBossLoadTimeWeaver.java +++ b/spring-context/src/main/java/org/springframework/instrument/classloading/jboss/JBossLoadTimeWeaver.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"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.springframework.util.ReflectionUtils; * Thanks to Ales Justin and Marius Bogoevici for the initial prototype. * *

As of Spring Framework 5.0, this weaver supports WildFly 8+. + * As of Spring Framework 5.1.5, it also supports WildFly 13+. * * @author Costin Leau * @author Juergen Hoeller @@ -42,6 +43,9 @@ public class JBossLoadTimeWeaver implements LoadTimeWeaver { private static final String DELEGATING_TRANSFORMER_CLASS_NAME = "org.jboss.as.server.deployment.module.DelegatingClassFileTransformer"; + private static final String WRAPPER_TRANSFORMER_CLASS_NAME = + "org.jboss.modules.JLIClassTransformer"; + private final ClassLoader classLoader; @@ -76,12 +80,23 @@ public class JBossLoadTimeWeaver implements LoadTimeWeaver { } transformer.setAccessible(true); - this.delegatingTransformer = transformer.get(classLoader); - if (!this.delegatingTransformer.getClass().getName().equals(DELEGATING_TRANSFORMER_CLASS_NAME)) { + Object suggestedTransformer = transformer.get(classLoader); + if (suggestedTransformer.getClass().getName().equals(WRAPPER_TRANSFORMER_CLASS_NAME)) { + Field wrappedTransformer = ReflectionUtils.findField(suggestedTransformer.getClass(), "transformer"); + if (wrappedTransformer == null) { + throw new IllegalArgumentException( + "Could not find 'transformer' field on JBoss JLIClassTransformer: " + + suggestedTransformer.getClass().getName()); + } + wrappedTransformer.setAccessible(true); + suggestedTransformer = wrappedTransformer.get(suggestedTransformer); + } + if (!suggestedTransformer.getClass().getName().equals(DELEGATING_TRANSFORMER_CLASS_NAME)) { throw new IllegalStateException( "Transformer not of the expected type DelegatingClassFileTransformer: " + - this.delegatingTransformer.getClass().getName()); + suggestedTransformer.getClass().getName()); } + this.delegatingTransformer = suggestedTransformer; Method addTransformer = ReflectionUtils.findMethod(this.delegatingTransformer.getClass(), "addTransformer", ClassFileTransformer.class); From d27bae245a000c974c43b0281e25832d59845e13 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 5 Feb 2019 00:45:28 +0100 Subject: [PATCH 5/6] Polishing --- .../aop/support/ControlFlowPointcut.java | 5 +- .../core/CollectionFactory.java | 8 +-- .../util/ConcurrentReferenceHashMap.java | 5 +- .../SQLStateSQLExceptionTranslator.java | 54 +++++++++---------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java index 832eaafcfed..35d9a6ab010 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.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"); * you may not use this file except in compliance with the License. @@ -77,8 +77,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher } /** - * Subclasses can override this if it's possible to filter out - * some candidate classes. + * Subclasses can override this if it's possible to filter out some candidate classes. */ @Override public boolean matches(Method method, Class targetClass) { diff --git a/spring-core/src/main/java/org/springframework/core/CollectionFactory.java b/spring-core/src/main/java/org/springframework/core/CollectionFactory.java index 7b67ed34cbd..d2a3830d1c5 100644 --- a/spring-core/src/main/java/org/springframework/core/CollectionFactory.java +++ b/spring-core/src/main/java/org/springframework/core/CollectionFactory.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"); * you may not use this file except in compliance with the License. @@ -145,7 +145,7 @@ public final class CollectionFactory { * Create the most appropriate collection for the given collection type. *

Delegates to {@link #createCollection(Class, Class, int)} with a * {@code null} element type. - * @param collectionType the desired type of the target collection; never {@code null} + * @param collectionType the desired type of the target collection (never {@code null}) * @param capacity the initial capacity * @return a new collection instance * @throws IllegalArgumentException if the supplied {@code collectionType} @@ -164,7 +164,7 @@ public final class CollectionFactory { * supplied {@code elementType} is an enum type matching type {@code E}. * As an alternative, the caller may wish to treat the return value as a * raw collection or collection of {@link Object}. - * @param collectionType the desired type of the target collection; never {@code null} + * @param collectionType the desired type of the target collection (never {@code null}) * @param elementType the collection's element type, or {@code null} if unknown * (note: only relevant for {@link EnumSet} creation) * @param capacity the initial capacity @@ -280,7 +280,7 @@ public final class CollectionFactory { * may wish to treat the return value as a raw map or map keyed by * {@link Object}. Similarly, type safety cannot be enforced if the * desired {@code mapType} is {@link MultiValueMap}. - * @param mapType the desired type of the target map; never {@code null} + * @param mapType the desired type of the target map (never {@code null}) * @param keyType the map's key type, or {@code null} if unknown * (note: only relevant for {@link EnumMap} creation) * @param capacity the initial capacity diff --git a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java index 4e6de5b8f23..76abb8ba265 100644 --- a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java +++ b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.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"); * you may not use this file except in compliance with the License. @@ -574,7 +574,8 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen * @param allowResize if resizing is permitted */ protected final void restructureIfNecessary(boolean allowResize) { - boolean needsResize = (this.count > 0 && this.count >= this.resizeThreshold); + int currCount = this.count; + boolean needsResize = (currCount > 0 && currCount >= this.resizeThreshold); Reference ref = this.referenceManager.pollForPurge(); if (ref != null || (needsResize && allowResize)) { lock(); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslator.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslator.java index 3178f0c21a7..554f4abcf16 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslator.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslator.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"); * you may not use this file except in compliance with the License. @@ -58,32 +58,32 @@ public class SQLStateSQLExceptionTranslator extends AbstractFallbackSQLException static { - BAD_SQL_GRAMMAR_CODES.add("07"); // Dynamic SQL error - BAD_SQL_GRAMMAR_CODES.add("21"); // Cardinality violation - BAD_SQL_GRAMMAR_CODES.add("2A"); // Syntax error direct SQL - BAD_SQL_GRAMMAR_CODES.add("37"); // Syntax error dynamic SQL - BAD_SQL_GRAMMAR_CODES.add("42"); // General SQL syntax error - BAD_SQL_GRAMMAR_CODES.add("65"); // Oracle: unknown identifier - - DATA_INTEGRITY_VIOLATION_CODES.add("01"); // Data truncation - DATA_INTEGRITY_VIOLATION_CODES.add("02"); // No data found - DATA_INTEGRITY_VIOLATION_CODES.add("22"); // Value out of range - DATA_INTEGRITY_VIOLATION_CODES.add("23"); // Integrity constraint violation - DATA_INTEGRITY_VIOLATION_CODES.add("27"); // Triggered data change violation - DATA_INTEGRITY_VIOLATION_CODES.add("44"); // With check violation - - DATA_ACCESS_RESOURCE_FAILURE_CODES.add("08"); // Connection exception - DATA_ACCESS_RESOURCE_FAILURE_CODES.add("53"); // PostgreSQL: insufficient resources (e.g. disk full) - DATA_ACCESS_RESOURCE_FAILURE_CODES.add("54"); // PostgreSQL: program limit exceeded (e.g. statement too complex) - DATA_ACCESS_RESOURCE_FAILURE_CODES.add("57"); // DB2: out-of-memory exception / database not started - DATA_ACCESS_RESOURCE_FAILURE_CODES.add("58"); // DB2: unexpected system error - - TRANSIENT_DATA_ACCESS_RESOURCE_CODES.add("JW"); // Sybase: internal I/O error - TRANSIENT_DATA_ACCESS_RESOURCE_CODES.add("JZ"); // Sybase: unexpected I/O error - TRANSIENT_DATA_ACCESS_RESOURCE_CODES.add("S1"); // DB2: communication failure - - CONCURRENCY_FAILURE_CODES.add("40"); // Transaction rollback - CONCURRENCY_FAILURE_CODES.add("61"); // Oracle: deadlock + BAD_SQL_GRAMMAR_CODES.add("07"); // Dynamic SQL error + BAD_SQL_GRAMMAR_CODES.add("21"); // Cardinality violation + BAD_SQL_GRAMMAR_CODES.add("2A"); // Syntax error direct SQL + BAD_SQL_GRAMMAR_CODES.add("37"); // Syntax error dynamic SQL + BAD_SQL_GRAMMAR_CODES.add("42"); // General SQL syntax error + BAD_SQL_GRAMMAR_CODES.add("65"); // Oracle: unknown identifier + + DATA_INTEGRITY_VIOLATION_CODES.add("01"); // Data truncation + DATA_INTEGRITY_VIOLATION_CODES.add("02"); // No data found + DATA_INTEGRITY_VIOLATION_CODES.add("22"); // Value out of range + DATA_INTEGRITY_VIOLATION_CODES.add("23"); // Integrity constraint violation + DATA_INTEGRITY_VIOLATION_CODES.add("27"); // Triggered data change violation + DATA_INTEGRITY_VIOLATION_CODES.add("44"); // With check violation + + DATA_ACCESS_RESOURCE_FAILURE_CODES.add("08"); // Connection exception + DATA_ACCESS_RESOURCE_FAILURE_CODES.add("53"); // PostgreSQL: insufficient resources (e.g. disk full) + DATA_ACCESS_RESOURCE_FAILURE_CODES.add("54"); // PostgreSQL: program limit exceeded (e.g. statement too complex) + DATA_ACCESS_RESOURCE_FAILURE_CODES.add("57"); // DB2: out-of-memory exception / database not started + DATA_ACCESS_RESOURCE_FAILURE_CODES.add("58"); // DB2: unexpected system error + + TRANSIENT_DATA_ACCESS_RESOURCE_CODES.add("JW"); // Sybase: internal I/O error + TRANSIENT_DATA_ACCESS_RESOURCE_CODES.add("JZ"); // Sybase: unexpected I/O error + TRANSIENT_DATA_ACCESS_RESOURCE_CODES.add("S1"); // DB2: communication failure + + CONCURRENCY_FAILURE_CODES.add("40"); // Transaction rollback + CONCURRENCY_FAILURE_CODES.add("61"); // Oracle: deadlock } From 165d2511b9853087b08b0bedd68af46ac4ecbce1 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 5 Feb 2019 00:46:07 +0100 Subject: [PATCH 6/6] Upgrade to Apache HttpClient 4.5.7 and Commons FileUpload 1.4 Includes RxJava 2.2.6, Netty 4.1.33, Undertow 2.0.17. --- build.gradle | 6 +++--- spring-test/spring-test.gradle | 2 +- spring-web/spring-web.gradle | 4 ++-- spring-webflux/spring-webflux.gradle | 2 +- spring-webmvc/spring-webmvc.gradle | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 1a1d91a92f9..dd5ed3931ac 100644 --- a/build.gradle +++ b/build.gradle @@ -37,15 +37,15 @@ ext { junit5Version = "5.3.2" kotlinVersion = "1.2.71" log4jVersion = "2.11.1" - nettyVersion = "4.1.32.Final" + nettyVersion = "4.1.33.Final" reactorVersion = "Californium-SR4" rxjavaVersion = "1.3.8" rxjavaAdapterVersion = "1.2.1" - rxjava2Version = "2.2.5" + rxjava2Version = "2.2.6" slf4jVersion = "1.7.25" // spring-jcl + consistent 3rd party deps tiles3Version = "3.0.8" tomcatVersion = "9.0.14" - undertowVersion = "2.0.16.Final" + undertowVersion = "2.0.17.Final" gradleScriptDir = "${rootProject.projectDir}/gradle" withoutJclOverSlf4J = { diff --git a/spring-test/spring-test.gradle b/spring-test/spring-test.gradle index 765b2d3c65a..5d7ae715f15 100644 --- a/spring-test/spring-test.gradle +++ b/spring-test/spring-test.gradle @@ -72,7 +72,7 @@ dependencies { testCompile("org.apache.tiles:tiles-core:${tiles3Version}", withoutJclOverSlf4J) testCompile("org.apache.tiles:tiles-servlet:${tiles3Version}", withoutJclOverSlf4J) testCompile("org.hsqldb:hsqldb:${hsqldbVersion}") - testCompile("org.apache.httpcomponents:httpclient:4.5.6") { + testCompile("org.apache.httpcomponents:httpclient:4.5.7") { exclude group: "commons-logging", module: "commons-logging" } testCompile("io.projectreactor.netty:reactor-netty") diff --git a/spring-web/spring-web.gradle b/spring-web/spring-web.gradle index 560a0ad3f23..4e7b0a679e9 100644 --- a/spring-web/spring-web.gradle +++ b/spring-web/spring-web.gradle @@ -39,13 +39,13 @@ dependencies { } optional("org.eclipse.jetty:jetty-reactive-httpclient:1.0.2") optional("com.squareup.okhttp3:okhttp:3.12.1") - optional("org.apache.httpcomponents:httpclient:4.5.6") { + optional("org.apache.httpcomponents:httpclient:4.5.7") { exclude group: "commons-logging", module: "commons-logging" } optional("org.apache.httpcomponents:httpasyncclient:4.1.4") { exclude group: "commons-logging", module: "commons-logging" } - optional("commons-fileupload:commons-fileupload:1.3.3") + optional("commons-fileupload:commons-fileupload:1.4") optional("org.synchronoss.cloud:nio-multipart-parser:1.1.0") optional("com.fasterxml.woodstox:woodstox-core:5.2.0") { // woodstox before aalto exclude group: "stax", module: "stax-api" diff --git a/spring-webflux/spring-webflux.gradle b/spring-webflux/spring-webflux.gradle index 126470eed4b..cf51de3776b 100644 --- a/spring-webflux/spring-webflux.gradle +++ b/spring-webflux/spring-webflux.gradle @@ -34,7 +34,7 @@ dependencies { optional("io.undertow:undertow-websockets-jsr:${undertowVersion}") { exclude group: "org.jboss.spec.javax.websocket", module: "jboss-websocket-api_1.1_spec" } - optional("org.apache.httpcomponents:httpclient:4.5.6") { + optional("org.apache.httpcomponents:httpclient:4.5.7") { exclude group: "commons-logging", module: "commons-logging" } optional("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}") diff --git a/spring-webmvc/spring-webmvc.gradle b/spring-webmvc/spring-webmvc.gradle index 507c7e0befa..ea1e01c9aae 100644 --- a/spring-webmvc/spring-webmvc.gradle +++ b/spring-webmvc/spring-webmvc.gradle @@ -50,10 +50,10 @@ dependencies { testCompile("org.eclipse.jetty:jetty-server") { exclude group: "javax.servlet", module: "javax.servlet" } - testCompile("org.apache.httpcomponents:httpclient:4.5.6") { + testCompile("org.apache.httpcomponents:httpclient:4.5.7") { exclude group: "commons-logging", module: "commons-logging" } - testCompile("commons-fileupload:commons-fileupload:1.3.3") + testCompile("commons-fileupload:commons-fileupload:1.4") testCompile("commons-io:commons-io:2.5") testCompile("joda-time:joda-time:2.10.1") testCompile("org.mozilla:rhino:1.7.10")