Browse Source

Merge branch '6.0.x'

# Conflicts:
#	spring-context/spring-context.gradle
#	spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java
#	spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java
#	spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java
#	spring-test/spring-test.gradle
#	spring-webmvc/spring-webmvc.gradle
pull/30980/head
Juergen Hoeller 1 year ago
parent
commit
b9ae996dfc
  1. 2
      spring-context/spring-context.gradle
  2. 17
      spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java
  3. 10
      spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/ConnectionFactoryUtils.java
  4. 18
      spring-test/spring-test.gradle
  5. 8
      spring-tx/src/main/java/org/springframework/transaction/reactive/TransactionContextManager.java
  6. 16
      spring-tx/src/main/java/org/springframework/transaction/reactive/TransactionSynchronizationManager.java
  7. 6
      spring-web/spring-web.gradle
  8. 4
      spring-webflux/spring-webflux.gradle
  9. 22
      spring-webmvc/spring-webmvc.gradle
  10. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java

2
spring-context/spring-context.gradle

@ -21,9 +21,9 @@ dependencies { @@ -21,9 +21,9 @@ dependencies {
optional("jakarta.validation:jakarta.validation-api")
optional("javax.annotation:javax.annotation-api")
optional("javax.money:money-api")
optional("org.aspectj:aspectjweaver")
optional("org.apache.groovy:groovy")
optional("org.apache-extras.beanshell:bsh")
optional("org.aspectj:aspectjweaver")
optional("org.crac:crac")
optional("org.hibernate:hibernate-validator")
optional("org.jetbrains.kotlin:kotlin-reflect")

17
spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java

@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory; @@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory;
import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.ContainedBean;
import org.hibernate.resource.beans.spi.BeanInstanceProducer;
import org.hibernate.type.spi.TypeBootstrapContext;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanCreationException;
@ -180,14 +181,28 @@ public final class SpringBeanContainer implements BeanContainer { @@ -180,14 +181,28 @@ public final class SpringBeanContainer implements BeanContainer {
try {
if (lifecycleOptions.useJpaCompliantCreation()) {
Object bean = null;
if (fallbackProducer instanceof TypeBootstrapContext) {
// Special Hibernate type construction rules, including TypeBootstrapContext resolution.
bean = fallbackProducer.produceBeanInstance(name, beanType);
}
if (this.beanFactory.containsBean(name)) {
Object bean = this.beanFactory.autowire(beanType, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
if (bean == null) {
bean = this.beanFactory.autowire(beanType, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
}
this.beanFactory.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
this.beanFactory.applyBeanPropertyValues(bean, name);
bean = this.beanFactory.initializeBean(bean, name);
return new SpringContainedBean<>(bean, beanInstance -> this.beanFactory.destroyBean(name, beanInstance));
}
else if (bean != null) {
// No bean found by name but constructed with TypeBootstrapContext rules
this.beanFactory.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
bean = this.beanFactory.initializeBean(bean, name);
return new SpringContainedBean<>(bean, this.beanFactory::destroyBean);
}
else {
// No bean found by name -> construct by type using createBean
return new SpringContainedBean<>(
this.beanFactory.createBean(beanType),
this.beanFactory::destroyBean);

10
spring-r2dbc/src/main/java/org/springframework/r2dbc/connection/ConnectionFactoryUtils.java

@ -126,8 +126,8 @@ public abstract class ConnectionFactoryUtils { @@ -126,8 +126,8 @@ public abstract class ConnectionFactoryUtils {
holderToUse.setConnection(conn);
}
holderToUse.requested();
synchronizationManager
.registerSynchronization(new ConnectionSynchronization(holderToUse, connectionFactory));
synchronizationManager.registerSynchronization(
new ConnectionSynchronization(holderToUse, connectionFactory));
holderToUse.setSynchronizedWithTransaction(true);
if (holderToUse != conHolder) {
synchronizationManager.bindResource(connectionFactory, holderToUse);
@ -173,8 +173,7 @@ public abstract class ConnectionFactoryUtils { @@ -173,8 +173,7 @@ public abstract class ConnectionFactoryUtils {
* @see #doGetConnection
*/
public static Mono<Void> doReleaseConnection(Connection connection, ConnectionFactory connectionFactory) {
return TransactionSynchronizationManager.forCurrentTransaction()
.flatMap(synchronizationManager -> {
return TransactionSynchronizationManager.forCurrentTransaction().flatMap(synchronizationManager -> {
ConnectionHolder conHolder = (ConnectionHolder) synchronizationManager.getResource(connectionFactory);
if (conHolder != null && connectionEquals(conHolder, connection)) {
// It's the transactional Connection: Don't close it.
@ -289,7 +288,8 @@ public abstract class ConnectionFactoryUtils { @@ -289,7 +288,8 @@ public abstract class ConnectionFactoryUtils {
Connection heldCon = conHolder.getConnection();
// Explicitly check for identity too: for Connection handles that do not implement
// "equals" properly).
return (heldCon == passedInCon || heldCon.equals(passedInCon) || getTargetConnection(heldCon).equals(passedInCon));
return (heldCon == passedInCon || heldCon.equals(passedInCon) ||
getTargetConnection(heldCon).equals(passedInCon));
}
/**

18
spring-test/spring-test.gradle

@ -14,7 +14,11 @@ dependencies { @@ -14,7 +14,11 @@ dependencies {
optional(project(":spring-webflux"))
optional(project(":spring-webmvc"))
optional(project(":spring-websocket"))
optional('info.picocli:picocli')
optional("com.jayway.jsonpath:json-path")
optional("info.picocli:picocli")
optional("io.micrometer:context-propagation")
optional("io.micrometer:micrometer-observation")
optional("io.projectreactor:reactor-test")
optional("jakarta.activation:jakarta.activation-api")
optional("jakarta.el:jakarta.el-api")
optional("jakarta.inject:jakarta.inject-api")
@ -44,14 +48,10 @@ dependencies { @@ -44,14 +48,10 @@ dependencies {
}
optional("org.xmlunit:xmlunit-matchers")
optional("org.skyscreamer:jsonassert")
optional("com.jayway.jsonpath:json-path")
optional("org.jetbrains.kotlin:kotlin-reflect")
optional("org.jetbrains.kotlin:kotlin-stdlib")
optional("io.projectreactor:reactor-test")
optional("org.jetbrains.kotlinx:kotlinx-coroutines-core")
optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
optional('io.micrometer:context-propagation')
optional('io.micrometer:micrometer-observation')
testImplementation(project(":spring-core-test"))
testImplementation(project(":spring-context-support"))
testImplementation(project(":spring-oxm"))
@ -60,14 +60,15 @@ dependencies { @@ -60,14 +60,15 @@ dependencies {
testImplementation(testFixtures(project(":spring-core")))
testImplementation(testFixtures(project(":spring-tx")))
testImplementation(testFixtures(project(":spring-web")))
testImplementation("de.bechte.junit:junit-hierarchicalcontextrunner")
testImplementation("jakarta.annotation:jakarta.annotation-api")
testImplementation("javax.cache:cache-api")
testImplementation("jakarta.ejb:jakarta.ejb-api")
testImplementation("jakarta.interceptor:jakarta.interceptor-api")
testImplementation("jakarta.mail:jakarta.mail-api")
testImplementation("jakarta.validation:jakarta.validation-api")
testImplementation("javax.cache:cache-api")
testImplementation("org.hibernate:hibernate-core-jakarta")
testImplementation("org.hibernate:hibernate-validator")
testImplementation("jakarta.validation:jakarta.validation-api")
testImplementation("org.junit.platform:junit-platform-testkit")
testImplementation("com.fasterxml.jackson.core:jackson-databind")
testImplementation("com.thoughtworks.xstream:xstream")
@ -76,9 +77,8 @@ dependencies { @@ -76,9 +77,8 @@ dependencies {
testImplementation("org.apache.httpcomponents:httpclient") {
exclude group: "commons-logging", module: "commons-logging"
}
testImplementation("io.projectreactor.netty:reactor-netty-http")
testImplementation("de.bechte.junit:junit-hierarchicalcontextrunner")
testImplementation("org.awaitility:awaitility")
testImplementation("io.projectreactor.netty:reactor-netty-http")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine") {
exclude group: "junit", module: "junit"
}

8
spring-tx/src/main/java/org/springframework/transaction/reactive/TransactionContextManager.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 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.
@ -46,10 +46,10 @@ public abstract class TransactionContextManager { @@ -46,10 +46,10 @@ public abstract class TransactionContextManager {
* transactional context holder. Context retrieval fails with NoTransactionException
* if no context or context holder is registered.
* @return the current {@link TransactionContext}
* @throws NoTransactionException if no TransactionContext was found in the subscriber context
* or no context found in a holder
* @throws NoTransactionException if no TransactionContext was found in the
* subscriber context or no context found in a holder
*/
public static Mono<TransactionContext> currentContext() throws NoTransactionException {
public static Mono<TransactionContext> currentContext() {
return Mono.deferContextual(ctx -> {
if (ctx.hasKey(TransactionContext.class)) {
return Mono.just(ctx.get(TransactionContext.class));

16
spring-tx/src/main/java/org/springframework/transaction/reactive/TransactionSynchronizationManager.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 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,8 +32,8 @@ import org.springframework.util.Assert; @@ -32,8 +32,8 @@ import org.springframework.util.Assert;
/**
* Central delegate that manages resources and transaction synchronizations per
* subscriber context.
* To be used by resource management code but not by typical application code.
* subscriber context. To be used by resource management code but not by typical
* application code.
*
* <p>Supports one resource per key without overwriting, that is, a resource needs
* to be removed before a new one can be set for the same key.
@ -73,6 +73,7 @@ public class TransactionSynchronizationManager { @@ -73,6 +73,7 @@ public class TransactionSynchronizationManager {
public TransactionSynchronizationManager(TransactionContext transactionContext) {
Assert.notNull(transactionContext, "TransactionContext must not be null");
this.transactionContext = transactionContext;
}
@ -88,10 +89,11 @@ public class TransactionSynchronizationManager { @@ -88,10 +89,11 @@ public class TransactionSynchronizationManager {
return TransactionContextManager.currentContext().map(TransactionSynchronizationManager::new);
}
/**
* Check if there is a resource for the given key bound to the current thread.
* Check if there is a resource for the given key bound to the current context.
* @param key the key to check (usually the resource factory)
* @return if there is a value bound to the current thread
* @return if there is a value bound to the current context
*/
public boolean hasResource(Object key) {
Object actualKey = TransactionSynchronizationUtils.unwrapResourceIfNecessary(key);
@ -100,9 +102,9 @@ public class TransactionSynchronizationManager { @@ -100,9 +102,9 @@ public class TransactionSynchronizationManager {
}
/**
* Retrieve a resource for the given key that is bound to the current thread.
* Retrieve a resource for the given key that is bound to the current context.
* @param key the key to check (usually the resource factory)
* @return a value bound to the current thread (usually the active
* @return a value bound to the current context (usually the active
* resource object), or {@code null} if none
*/
@Nullable

6
spring-web/spring-web.gradle

@ -30,7 +30,10 @@ dependencies { @@ -30,7 +30,10 @@ dependencies {
optional("io.projectreactor.netty:reactor-netty-http")
optional("io.projectreactor.netty:reactor-netty5-http")
optional("io.undertow:undertow-core")
optional("org.apache.httpcomponents.client5:httpclient5")
optional("org.apache.httpcomponents.core5:httpcore5-reactive")
optional("org.apache.tomcat.embed:tomcat-embed-core")
optional("org.eclipse.jetty:jetty-reactive-httpclient")
optional("org.eclipse.jetty:jetty-server") {
exclude group: "jakarta.servlet", module: "jakarta.servlet-api"
}
@ -44,9 +47,6 @@ dependencies { @@ -44,9 +47,6 @@ dependencies {
exclude group: "org.eclipse.jetty", module: "jetty-server"
exclude group: "org.eclipse.jetty", module: "jetty-servlet"
}
optional("org.eclipse.jetty:jetty-reactive-httpclient")
optional('org.apache.httpcomponents.client5:httpclient5')
optional('org.apache.httpcomponents.core5:httpcore5-reactive')
optional("com.squareup.okhttp3:okhttp")
optional("com.fasterxml.woodstox:woodstox-core")
optional("com.fasterxml:aalto-xml")

4
spring-webflux/spring-webflux.gradle

@ -44,13 +44,13 @@ dependencies { @@ -44,13 +44,13 @@ dependencies {
testImplementation("io.projectreactor:reactor-test")
testImplementation("io.micrometer:micrometer-observation-test")
testImplementation("io.undertow:undertow-core")
testImplementation("org.apache.httpcomponents.client5:httpclient5")
testImplementation("org.apache.httpcomponents.core5:httpcore5-reactive")
testImplementation("org.apache.tomcat.embed:tomcat-embed-core")
testImplementation("org.apache.tomcat:tomcat-util")
testImplementation("org.eclipse.jetty:jetty-server")
testImplementation("org.eclipse.jetty:jetty-servlet")
testImplementation("org.eclipse.jetty:jetty-reactive-httpclient")
testImplementation('org.apache.httpcomponents.client5:httpclient5')
testImplementation('org.apache.httpcomponents.core5:httpcore5-reactive')
testImplementation("com.squareup.okhttp3:mockwebserver")
testImplementation("org.jetbrains.kotlin:kotlin-script-runtime")
testImplementation("org.jetbrains.kotlinx:kotlinx-serialization-json")

22
spring-webmvc/spring-webmvc.gradle

@ -15,29 +15,29 @@ dependencies { @@ -15,29 +15,29 @@ dependencies {
}
optional(project(":spring-context-support")) // for FreeMarker support
optional(project(":spring-oxm"))
optional("com.fasterxml.jackson.core:jackson-databind")
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-cbor")
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-smile")
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
optional("com.github.librepdf:openpdf")
optional("com.rometools:rome")
optional("io.micrometer:context-propagation")
optional("jakarta.el:jakarta.el-api")
optional("jakarta.servlet.jsp:jakarta.servlet.jsp-api")
optional("jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api")
optional("jakarta.el:jakarta.el-api")
optional("jakarta.validation:jakarta.validation-api")
optional("jakarta.xml.bind:jakarta.xml.bind-api")
optional('io.micrometer:context-propagation')
optional("org.webjars:webjars-locator-core")
optional("com.rometools:rome")
optional("com.github.librepdf:openpdf")
optional("org.apache.groovy:groovy-templates")
optional("org.apache.poi:poi-ooxml")
optional("org.freemarker:freemarker")
optional("com.fasterxml.jackson.core:jackson-databind")
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-smile")
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-cbor")
optional("org.apache.groovy:groovy-templates")
optional("org.jetbrains.kotlin:kotlin-reflect")
optional("org.jetbrains.kotlin:kotlin-stdlib")
optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
optional("org.jetbrains.kotlinx:kotlinx-serialization-cbor")
optional("org.jetbrains.kotlinx:kotlinx-serialization-json")
optional("org.jetbrains.kotlinx:kotlinx-serialization-protobuf")
optional("org.reactivestreams:reactive-streams")
optional("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
optional("org.webjars:webjars-locator-core")
testImplementation(testFixtures(project(":spring-beans")))
testImplementation(testFixtures(project(":spring-core")))
testImplementation(testFixtures(project(":spring-context")))

2
spring-webmvc/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java

@ -60,7 +60,7 @@ import org.springframework.web.util.pattern.PatternParseException; @@ -60,7 +60,7 @@ import org.springframework.web.util.pattern.PatternParseException;
*/
public final class MappedInterceptor implements HandlerInterceptor {
private static PathMatcher defaultPathMatcher = new AntPathMatcher();
private static final PathMatcher defaultPathMatcher = new AntPathMatcher();
@Nullable

Loading…
Cancel
Save