diff --git a/core/src/main/java/org/springframework/security/concurrent/DelegatingSecurityContextCallable.java b/core/src/main/java/org/springframework/security/concurrent/DelegatingSecurityContextCallable.java index 278b529a37..3b4d428665 100644 --- a/core/src/main/java/org/springframework/security/concurrent/DelegatingSecurityContextCallable.java +++ b/core/src/main/java/org/springframework/security/concurrent/DelegatingSecurityContextCallable.java @@ -64,6 +64,10 @@ public final class DelegatingSecurityContextCallable implements Callable { } } + public String toString() { + return delegate.toString(); + } + /** * Creates a {@link DelegatingSecurityContextCallable} and with the given {@link Callable} and * {@link SecurityContext}, but if the securityContext is null will defaults to the current {@link SecurityContext} diff --git a/core/src/main/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnable.java b/core/src/main/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnable.java index c9371af44f..4bae805dfb 100644 --- a/core/src/main/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnable.java +++ b/core/src/main/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnable.java @@ -61,6 +61,10 @@ public final class DelegatingSecurityContextRunnable implements Runnable { } } + public String toString() { + return delegate.toString(); + } + /** * Factory method for creating a {@link DelegatingSecurityContextRunnable}. * diff --git a/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextCallableTests.java b/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextCallableTests.java index e6d336c383..17bb536a0b 100644 --- a/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextCallableTests.java +++ b/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextCallableTests.java @@ -126,6 +126,15 @@ public class DelegatingSecurityContextCallableTests { assertWrapped(callable.call()); } + // --- toString + + // SEC-2682 + @Test + public void toStringDelegates() { + callable = new DelegatingSecurityContextCallable(delegate, securityContext); + assertThat(callable.toString()).isEqualTo(delegate.toString()); + } + private void assertWrapped(Object actualResult) throws Exception { assertThat(actualResult).isEqualTo(callableResult); verify(delegate).call(); diff --git a/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnableTests.java b/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnableTests.java index 0eb31c94d4..c5aaf3c4c9 100644 --- a/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnableTests.java +++ b/core/src/test/java/org/springframework/security/concurrent/DelegatingSecurityContextRunnableTests.java @@ -127,6 +127,15 @@ public class DelegatingSecurityContextRunnableTests { assertWrapped(); } + // --- toString + + // SEC-2682 + @Test + public void toStringDelegates() { + runnable = new DelegatingSecurityContextRunnable(delegate, securityContext); + assertThat(runnable.toString()).isEqualTo(delegate.toString()); + } + private void assertWrapped() { verify(delegate).run(); assertThat(SecurityContextHolder.getContext()).isEqualTo(SecurityContextHolder.createEmptyContext());