From 6d04ea9e84e95882b7350081aa1043cbeac06938 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 31 Jul 2026 16:24:09 +0200 Subject: [PATCH 1/2] Check existing database transaction against UnitOfWork See gh-37085 --- .../orm/jpa/vendor/EclipseLinkJpaDialect.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaDialect.java b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaDialect.java index 7f984356c4d..4d8fcf2c1c9 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaDialect.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaDialect.java @@ -24,7 +24,6 @@ import java.util.concurrent.locks.ReentrantLock; import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceException; import org.eclipse.persistence.sessions.DatabaseLogin; -import org.eclipse.persistence.sessions.DatabaseSession; import org.eclipse.persistence.sessions.UnitOfWork; import org.jspecify.annotations.Nullable; @@ -176,8 +175,8 @@ public class EclipseLinkJpaDialect extends DefaultJpaDialect { public Connection getConnection() { Connection con = this.connection; if (con == null) { - DatabaseSession dbs = this.entityManager.unwrap(DatabaseSession.class); - if (dbs.isInTransaction()) { + UnitOfWork uow = this.entityManager.unwrap(UnitOfWork.class); + if (uow.getParent().isInTransaction()) { // Existing Connection to be retrieved from this EntityManager. con = this.entityManager.unwrap(Connection.class); } From f5564e7e31e157c5a5fe6971684a1b271f39da06 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 31 Jul 2026 16:27:18 +0200 Subject: [PATCH 2/2] Consistently use default constants within builder See gh-36983 --- .../core/retry/RetryPolicy.java | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/retry/RetryPolicy.java b/spring-core/src/main/java/org/springframework/core/retry/RetryPolicy.java index adb92e90148..fd913820574 100644 --- a/spring-core/src/main/java/org/springframework/core/retry/RetryPolicy.java +++ b/spring-core/src/main/java/org/springframework/core/retry/RetryPolicy.java @@ -157,6 +157,12 @@ public interface RetryPolicy { */ public static final long DEFAULT_DELAY = 1000; + /** + * The default {@linkplain #jitter(Duration) jitter}: {@value}. + * @since 7.0.9 + */ + public static final long DEFAULT_JITTER = 0; + /** * The default {@linkplain #multiplier(double) multiplier}: {@value}. */ @@ -179,8 +185,6 @@ public interface RetryPolicy { private @Nullable Long maxRetries; - private Duration timeout = Duration.ZERO; - private @Nullable Duration delay; private @Nullable Duration jitter; @@ -189,6 +193,8 @@ public interface RetryPolicy { private @Nullable Duration maxDelay; + private Duration timeout = DEFAULT_TIMEOUT; + private final Set> includes = new LinkedHashSet<>(); private final Set> excludes = new LinkedHashSet<>(); @@ -240,24 +246,6 @@ public interface RetryPolicy { return this; } - /** - * Specify a timeout for the maximum amount of elapsed time allowed for - * the initial invocation and any subsequent retry attempts, including - * delays. - *

The default is {@link Duration#ZERO}, which signals that no timeout - * should be applied. - *

The supplied value will override any previously configured value. - * @param timeout the timeout, typically in milliseconds or seconds; - * must be greater than or equal to zero - * @return this {@code Builder} instance for chained method invocations - * @since 7.0.2 - */ - public Builder timeout(Duration timeout) { - assertIsNotNegative("timeout", timeout); - this.timeout = timeout; - return this; - } - /** * Specify the base delay after the initial invocation. *

If a {@linkplain #multiplier(double) multiplier} is specified, this @@ -353,6 +341,24 @@ public interface RetryPolicy { return this; } + /** + * Specify a timeout for the maximum amount of elapsed time allowed for + * the initial invocation and any subsequent retry attempts, including + * delays. + *

The default is {@link Duration#ZERO}, which signals that no timeout + * should be applied. + *

The supplied value will override any previously configured value. + * @param timeout the timeout, typically in milliseconds or seconds; + * must be greater than or equal to zero + * @return this {@code Builder} instance for chained method invocations + * @since 7.0.2 + */ + public Builder timeout(Duration timeout) { + assertIsNotNegative("timeout", timeout); + this.timeout = timeout; + return this; + } + /** * Specify the types of exceptions for which the {@link RetryPolicy} * should retry a failed operation. @@ -483,11 +489,9 @@ public interface RetryPolicy { ExponentialBackOff exponentialBackOff = new ExponentialBackOff(); exponentialBackOff.setMaxAttempts(this.maxRetries != null ? this.maxRetries : DEFAULT_MAX_RETRIES); exponentialBackOff.setInitialInterval(this.delay != null ? this.delay.toMillis() : DEFAULT_DELAY); - exponentialBackOff.setMaxInterval(this.maxDelay != null ? this.maxDelay.toMillis() : DEFAULT_MAX_DELAY); + exponentialBackOff.setJitter(this.jitter != null ? this.jitter.toMillis() : DEFAULT_JITTER); exponentialBackOff.setMultiplier(this.multiplier != null ? this.multiplier : DEFAULT_MULTIPLIER); - if (this.jitter != null) { - exponentialBackOff.setJitter(this.jitter.toMillis()); - } + exponentialBackOff.setMaxInterval(this.maxDelay != null ? this.maxDelay.toMillis() : DEFAULT_MAX_DELAY); backOff = exponentialBackOff; } return new DefaultRetryPolicy(this.includes, this.excludes, this.predicate, this.timeout, backOff);