From 6d84b58730fd2c673b1a0adf24cc6383422f43f9 Mon Sep 17 00:00:00 2001 From: Daniel Kec Date: Thu, 19 Dec 2024 11:03:06 +0100 Subject: [PATCH] Review issues Signed-off-by: Daniel Kec --- .../virtual-threads/etc/spotbugs/exclude.xml | 29 ------------------- common/testing/virtual-threads/pom.xml | 1 + ...eption.java => PinningAssertionError.java} | 6 ++-- .../virtualthreads/PinningRecorder.java | 14 ++++----- dependencies/pom.xml | 4 +-- .../testing/junit5/TestPinnedThread.java | 4 +-- .../testing/testng/TestPinnedThread.java | 8 ++--- .../testing/junit5/TestPinnedThread.java | 4 +-- 8 files changed, 21 insertions(+), 49 deletions(-) delete mode 100644 common/testing/virtual-threads/etc/spotbugs/exclude.xml rename common/testing/virtual-threads/src/main/java/io/helidon/common/testing/virtualthreads/{PinningException.java => PinningAssertionError.java} (89%) diff --git a/common/testing/virtual-threads/etc/spotbugs/exclude.xml b/common/testing/virtual-threads/etc/spotbugs/exclude.xml deleted file mode 100644 index daa62177beb..00000000000 --- a/common/testing/virtual-threads/etc/spotbugs/exclude.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - diff --git a/common/testing/virtual-threads/pom.xml b/common/testing/virtual-threads/pom.xml index f5b8b2752dc..1e5f5a32066 100644 --- a/common/testing/virtual-threads/pom.xml +++ b/common/testing/virtual-threads/pom.xml @@ -23,6 +23,7 @@ io.helidon.common.testing helidon-common-testing-project 4.2.0-SNAPSHOT + ../pom.xml helidon-common-testing-virtual-threads diff --git a/common/testing/virtual-threads/src/main/java/io/helidon/common/testing/virtualthreads/PinningException.java b/common/testing/virtual-threads/src/main/java/io/helidon/common/testing/virtualthreads/PinningAssertionError.java similarity index 89% rename from common/testing/virtual-threads/src/main/java/io/helidon/common/testing/virtualthreads/PinningException.java rename to common/testing/virtual-threads/src/main/java/io/helidon/common/testing/virtualthreads/PinningAssertionError.java index 33415b3afd0..0c709ec2bef 100644 --- a/common/testing/virtual-threads/src/main/java/io/helidon/common/testing/virtualthreads/PinningException.java +++ b/common/testing/virtual-threads/src/main/java/io/helidon/common/testing/virtualthreads/PinningAssertionError.java @@ -19,9 +19,9 @@ import jdk.jfr.consumer.RecordedEvent; /** - * Exception used for reporting of Virtual Thread pinning detected during test. + * Assertion error used for reporting of Virtual Thread pinning detected during test. */ -public class PinningException extends AssertionError { +public class PinningAssertionError extends AssertionError { /** * Pinning JFR event. @@ -33,7 +33,7 @@ public class PinningException extends AssertionError { * * @param recordedEvent pinning JFR event */ - PinningException(RecordedEvent recordedEvent) { + PinningAssertionError(RecordedEvent recordedEvent) { this.recordedEvent = recordedEvent; if (recordedEvent.getStackTrace() != null) { StackTraceElement[] stackTraceElements = recordedEvent.getStackTrace().getFrames().stream() diff --git a/common/testing/virtual-threads/src/main/java/io/helidon/common/testing/virtualthreads/PinningRecorder.java b/common/testing/virtual-threads/src/main/java/io/helidon/common/testing/virtualthreads/PinningRecorder.java index 1771e1593f4..e85e25e6175 100644 --- a/common/testing/virtual-threads/src/main/java/io/helidon/common/testing/virtualthreads/PinningRecorder.java +++ b/common/testing/virtual-threads/src/main/java/io/helidon/common/testing/virtualthreads/PinningRecorder.java @@ -32,7 +32,7 @@ public class PinningRecorder implements AutoCloseable { public static final long DEFAULT_THRESHOLD = 20; private static final String JFR_EVENT_VIRTUAL_THREAD_PINNED = "jdk.VirtualThreadPinned"; private final RecordingStream recordingStream = new RecordingStream(); - private volatile PinningException pinningException; + private volatile PinningAssertionError pinningAssertionError; private PinningRecorder() { //noop @@ -72,17 +72,17 @@ public void close() { } void checkAndThrow() { - if (pinningException != null) { - throw pinningException; + if (pinningAssertionError != null) { + throw pinningAssertionError; } } private void record(RecordedEvent event) { - PinningException e = new PinningException(event); - if (pinningException == null) { - pinningException = e; + PinningAssertionError e = new PinningAssertionError(event); + if (pinningAssertionError == null) { + pinningAssertionError = e; } else { - pinningException.addSuppressed(e); + pinningAssertionError.addSuppressed(e); } } } diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 95812ab7342..7ab3a7d54de 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -95,7 +95,7 @@ 3.1.9 6.7.0.202309050840-r 5.9.3 - 1.11.3 + 1.11.3 3.8.1 2.21.1 1.4.14 @@ -1288,7 +1288,7 @@ org.junit.platform junit-platform-testkit - ${version.lib.junit-platform-teskit} + ${version.lib.junit-platform-testkit} org.testcontainers diff --git a/microprofile/tests/testing/junit5/src/test/java/io/helidon/microprofile/tests/testing/junit5/TestPinnedThread.java b/microprofile/tests/testing/junit5/src/test/java/io/helidon/microprofile/tests/testing/junit5/TestPinnedThread.java index 32788f04c58..398bd0c4424 100644 --- a/microprofile/tests/testing/junit5/src/test/java/io/helidon/microprofile/tests/testing/junit5/TestPinnedThread.java +++ b/microprofile/tests/testing/junit5/src/test/java/io/helidon/microprofile/tests/testing/junit5/TestPinnedThread.java @@ -18,7 +18,7 @@ import java.util.Arrays; -import io.helidon.common.testing.virtualthreads.PinningException; +import io.helidon.common.testing.virtualthreads.PinningAssertionError; import io.helidon.microprofile.testing.junit5.AddBean; import io.helidon.microprofile.testing.junit5.HelidonTest; @@ -66,7 +66,7 @@ void engineTest() { private Condition failedWithPinningException(String expectedPinningMethodName) { return finishedWithFailure( - instanceOf(PinningException.class), + instanceOf(PinningAssertionError.class), message(m -> m.startsWith("Pinned virtual threads were detected")) , new Condition<>(where( t -> Arrays.stream(t.getStackTrace()), diff --git a/microprofile/tests/testing/testng/src/test/java/io/helidon/microprofile/tests/testing/testng/TestPinnedThread.java b/microprofile/tests/testing/testng/src/test/java/io/helidon/microprofile/tests/testing/testng/TestPinnedThread.java index 9cafdb0a369..8fdd6bda3bc 100644 --- a/microprofile/tests/testing/testng/src/test/java/io/helidon/microprofile/tests/testing/testng/TestPinnedThread.java +++ b/microprofile/tests/testing/testng/src/test/java/io/helidon/microprofile/tests/testing/testng/TestPinnedThread.java @@ -18,7 +18,7 @@ import java.util.Arrays; -import io.helidon.common.testing.virtualthreads.PinningException; +import io.helidon.common.testing.virtualthreads.PinningAssertionError; import io.helidon.microprofile.tests.testing.testng.programmatic.PinningExtraThreadTest; import org.hamcrest.BaseMatcher; @@ -42,9 +42,9 @@ void testListener() { testng.setTestClasses(new Class[] {PinningExtraThreadTest.class}); TestListenerAdapter tla = new TestListenerAdapter(); testng.addListener(tla); - PinningException pinningException = Assert.expectThrows(PinningException.class, testng::run); - assertThat(pinningException.getMessage(), startsWith("Pinned virtual threads were detected:")); - assertThat("Method with pinning is missing from stack strace.", Arrays.asList(pinningException.getStackTrace()), + PinningAssertionError pinningAssertionError = Assert.expectThrows(PinningAssertionError.class, testng::run); + assertThat(pinningAssertionError.getMessage(), startsWith("Pinned virtual threads were detected:")); + assertThat("Method with pinning is missing from stack strace.", Arrays.asList(pinningAssertionError.getStackTrace()), hasItem(new StackTraceElementMatcher(EXPECTED_PINNING_METHOD_NAME))); } diff --git a/webserver/testing/junit5/junit5/src/test/java/io/helidon/webserver/testing/junit5/TestPinnedThread.java b/webserver/testing/junit5/junit5/src/test/java/io/helidon/webserver/testing/junit5/TestPinnedThread.java index 37d2b4d4e36..1098d8e01b4 100644 --- a/webserver/testing/junit5/junit5/src/test/java/io/helidon/webserver/testing/junit5/TestPinnedThread.java +++ b/webserver/testing/junit5/junit5/src/test/java/io/helidon/webserver/testing/junit5/TestPinnedThread.java @@ -18,7 +18,7 @@ import java.util.Arrays; -import io.helidon.common.testing.virtualthreads.PinningException; +import io.helidon.common.testing.virtualthreads.PinningAssertionError; import io.helidon.webclient.api.WebClient; import io.helidon.webserver.http.HttpRouting; @@ -62,7 +62,7 @@ void engineTest() { private Condition failedWithPinningException(String expectedPinningMethodName) { return finishedWithFailure( - instanceOf(PinningException.class), + instanceOf(PinningAssertionError.class), message(m -> m.startsWith("Pinned virtual threads were detected")) , new Condition<>( t -> Arrays.stream(t.getStackTrace())