Browse Source

Polishing

pull/35990/head
Sam Brannen 1 week ago
parent
commit
ce4c9ebe3c
  1. 2
      spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java
  2. 6
      spring-core/src/main/java/org/springframework/core/retry/RetryTemplate.java
  3. 10
      spring-core/src/test/java/org/springframework/core/retry/RetryTemplateTests.java

2
spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java

@ -532,7 +532,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements @@ -532,7 +532,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
/**
* Callback before singleton creation.
* <p>The default implementation register the singleton as currently in creation.
* <p>The default implementation registers the singleton as currently in creation.
* @param beanName the name of the singleton about to be created
* @see #isSingletonCurrentlyInCreation
*/

6
spring-core/src/main/java/org/springframework/core/retry/RetryTemplate.java

@ -214,10 +214,10 @@ public class RetryTemplate implements RetryOperations { @@ -214,10 +214,10 @@ public class RetryTemplate implements RetryOperations {
long elapsedTime = System.currentTimeMillis() + sleepTime - startTime;
if (elapsedTime >= timeout) {
String message = (sleepTime > 0 ? """
Retry policy for operation '%s' would exceed timeout (%d ms) due \
to pending sleep time (%d ms); preemptively aborting execution"""
Retry policy for operation '%s' would exceed timeout (%dms) due \
to pending sleep time (%dms); preemptively aborting execution"""
.formatted(retryable.getName(), timeout, sleepTime) :
"Retry policy for operation '%s' exceeded timeout (%d ms); aborting execution"
"Retry policy for operation '%s' exceeded timeout (%dms); aborting execution"
.formatted(retryable.getName(), timeout));
RetryException retryException = new RetryException(message, exceptions.removeLast());
exceptions.forEach(retryException::addSuppressed);

10
spring-core/src/test/java/org/springframework/core/retry/RetryTemplateTests.java

@ -476,7 +476,7 @@ class RetryTemplateTests { @@ -476,7 +476,7 @@ class RetryTemplateTests {
assertThat(invocationCount).hasValue(0);
assertThatExceptionOfType(RetryException.class)
.isThrownBy(() -> retryTemplate.execute(retryable))
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(5 ms\\); aborting execution")
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(5ms\\); aborting execution")
.withCause(new CustomException("Boom 1"))
.satisfies(throwable -> inOrder.verify(retryListener).onRetryPolicyTimeout(
eq(retryPolicy), eq(retryable), eq(throwable)));
@ -503,8 +503,8 @@ class RetryTemplateTests { @@ -503,8 +503,8 @@ class RetryTemplateTests {
assertThatExceptionOfType(RetryException.class)
.isThrownBy(() -> retryTemplate.execute(retryable))
.withMessageMatching("""
Retry policy for operation '.+?' would exceed timeout \\(5 ms\\) \
due to pending sleep time \\(10 ms\\); preemptively aborting execution\
Retry policy for operation '.+?' would exceed timeout \\(5ms\\) \
due to pending sleep time \\(10ms\\); preemptively aborting execution\
""")
.withCause(new CustomException("Boom 1"))
.satisfies(throwable -> inOrder.verify(retryListener).onRetryPolicyTimeout(
@ -535,7 +535,7 @@ class RetryTemplateTests { @@ -535,7 +535,7 @@ class RetryTemplateTests {
assertThat(invocationCount).hasValue(0);
assertThatExceptionOfType(RetryException.class)
.isThrownBy(() -> retryTemplate.execute(retryable))
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(20 ms\\); aborting execution")
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(20ms\\); aborting execution")
.withCause(new CustomException("Boom 2"))
.satisfies(throwable -> {
inOrder.verify(retryListener).beforeRetry(retryPolicy, retryable);
@ -570,7 +570,7 @@ class RetryTemplateTests { @@ -570,7 +570,7 @@ class RetryTemplateTests {
assertThat(invocationCount).hasValue(0);
assertThatExceptionOfType(RetryException.class)
.isThrownBy(() -> retryTemplate.execute(retryable))
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(20 ms\\); aborting execution")
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(20ms\\); aborting execution")
.withCause(new CustomException("Boom 3"))
.satisfies(throwable -> {
var counter = new AtomicInteger(1);

Loading…
Cancel
Save