diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 45ddd08f37..3f7104a3cc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,6 +34,7 @@ You can use a Git client to clone the source code to your local machine. Micrometer targets Java 8 but requires JDK 11 or later to build. If you are not running Gradle with JDK 11 or later and Gradle cannot detect an existing JDK 17 installation, it will download one. +If you want to build the reference docs, you need to use JDK 17 or later. The Gradle wrapper is provided and should be used for building with a consistent version of Gradle. diff --git a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/MicrometerHttpRequestExecutorTest.java b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/MicrometerHttpRequestExecutorTest.java index 3a1683def6..eb8151bd8c 100644 --- a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/MicrometerHttpRequestExecutorTest.java +++ b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/httpcomponents/hc5/MicrometerHttpRequestExecutorTest.java @@ -37,7 +37,6 @@ import org.apache.hc.core5.http.io.HttpClientResponseHandler; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.util.Timeout; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; @@ -182,12 +181,12 @@ void routeTaggedIfEnabled(boolean configureObservationRegistry, @WiremockResolve } @Test - @Disabled("brittle test using reflection to check internals of third-party code") void waitForContinueGetsPassedToSuper() { MicrometerHttpRequestExecutor requestExecutor = MicrometerHttpRequestExecutor.builder(registry) .waitForContinue(Timeout.ofMilliseconds(1000)) .build(); - assertThat(requestExecutor).hasFieldOrPropertyWithValue("waitForContinue", Timeout.ofMilliseconds(1000)); + assertThat(requestExecutor).extracting("http1Config.waitForContinueTimeout") + .isEqualTo(Timeout.ofMilliseconds(1000)); } @ParameterizedTest diff --git a/micrometer-observation-test/src/main/java/io/micrometer/observation/tck/InvalidObservationException.java b/micrometer-observation-test/src/main/java/io/micrometer/observation/tck/InvalidObservationException.java index cd22299d16..d95f3c0dc4 100644 --- a/micrometer-observation-test/src/main/java/io/micrometer/observation/tck/InvalidObservationException.java +++ b/micrometer-observation-test/src/main/java/io/micrometer/observation/tck/InvalidObservationException.java @@ -31,6 +31,8 @@ */ public class InvalidObservationException extends RuntimeException { + private static final StackTraceElement[] EMPTY_STACK_TRACE = new StackTraceElement[0]; + private final Context context; private final List history; @@ -63,14 +65,14 @@ public static class HistoryElement { HistoryElement(EventName eventName) { this.eventName = eventName; - StackTraceElement[] currentStackTrace = Thread.getAllStackTraces().get(Thread.currentThread()); + StackTraceElement[] currentStackTrace = Thread.currentThread().getStackTrace(); this.stackTrace = findRelevantStackTraceElements(currentStackTrace); } private StackTraceElement[] findRelevantStackTraceElements(StackTraceElement[] stackTrace) { int index = findFirstRelevantStackTraceElementIndex(stackTrace); if (index == -1) { - return new StackTraceElement[0]; + return EMPTY_STACK_TRACE; } else { return Arrays.copyOfRange(stackTrace, index, stackTrace.length); diff --git a/micrometer-observation-test/src/test/java/io/micrometer/observation/tck/ObservationValidatorTests.java b/micrometer-observation-test/src/test/java/io/micrometer/observation/tck/ObservationValidatorTests.java index ca3c595824..14a181a1c1 100644 --- a/micrometer-observation-test/src/test/java/io/micrometer/observation/tck/ObservationValidatorTests.java +++ b/micrometer-observation-test/src/test/java/io/micrometer/observation/tck/ObservationValidatorTests.java @@ -42,8 +42,8 @@ void doubleStartShouldBeInvalid() { .hasMessage("Invalid start: Observation 'test' has already been started") .satisfies(exception -> assertThat(exception.toString()).matches( "(?s)^io\\.micrometer\\.observation\\.tck\\.InvalidObservationException: Invalid start: Observation 'test' has already been started\n" - + "START: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$doubleStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" - + "START: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$doubleStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); + + "START: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$doubleStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" + + "START: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$doubleStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); } @Test @@ -54,7 +54,7 @@ void stopBeforeStartShouldBeInvalid() { .hasMessage("Invalid stop: Observation 'test' has not been started yet") .satisfies(exception -> assertThat(exception.toString()).matches( "(?s)^io\\.micrometer\\.observation\\.tck\\.InvalidObservationException: Invalid stop: Observation 'test' has not been started yet\n" - + "STOP: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$stopBeforeStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); + + "STOP: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$stopBeforeStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); } @Test @@ -65,7 +65,7 @@ void errorBeforeStartShouldBeInvalid() { .hasMessage("Invalid error signal: Observation 'test' has not been started yet") .satisfies(exception -> assertThat(exception.toString()).matches( "(?s)^io\\.micrometer\\.observation\\.tck\\.InvalidObservationException: Invalid error signal: Observation 'test' has not been started yet\n" - + "ERROR: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$errorBeforeStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); + + "ERROR: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$errorBeforeStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); } @Test @@ -76,7 +76,7 @@ void eventBeforeStartShouldBeInvalid() { .hasMessage("Invalid event signal: Observation 'test' has not been started yet") .satisfies(exception -> assertThat(exception.toString()).matches( "(?s)^io\\.micrometer\\.observation\\.tck\\.InvalidObservationException: Invalid event signal: Observation 'test' has not been started yet\n" - + "EVENT: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$eventBeforeStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); + + "EVENT: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$eventBeforeStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); } @Test @@ -89,7 +89,7 @@ void scopeBeforeStartShouldBeInvalid() { .hasMessage("Invalid scope opening: Observation 'test' has not been started yet") .satisfies(exception -> assertThat(exception.toString()).matches( "(?s)^io\\.micrometer\\.observation\\.tck\\.InvalidObservationException: Invalid scope opening: Observation 'test' has not been started yet\n" - + "SCOPE_OPEN: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$scopeBeforeStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); + + "SCOPE_OPEN: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$scopeBeforeStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); } @Test @@ -100,8 +100,8 @@ void observeAfterStartShouldBeInvalid() { .hasMessage("Invalid start: Observation 'test' has already been started") .satisfies(exception -> assertThat(exception.toString()).matches( "(?s)^io\\.micrometer\\.observation\\.tck\\.InvalidObservationException: Invalid start: Observation 'test' has already been started\n" - + "START: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$observeAfterStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" - + "START: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$observeAfterStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); + + "START: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$observeAfterStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" + + "START: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$observeAfterStartShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); } @Test @@ -115,9 +115,9 @@ void doubleStopShouldBeInvalid() { .hasMessage("Invalid stop: Observation 'test' has already been stopped") .satisfies(exception -> assertThat(exception.toString()).matches( "(?s)^io\\.micrometer\\.observation\\.tck\\.InvalidObservationException: Invalid stop: Observation 'test' has already been stopped\n" - + "START: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$doubleStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" - + "STOP: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$doubleStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" - + "STOP: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$doubleStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); + + "START: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$doubleStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" + + "STOP: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$doubleStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" + + "STOP: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$doubleStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); } @Test @@ -131,9 +131,9 @@ void errorAfterStopShouldBeInvalid() { .hasMessage("Invalid error signal: Observation 'test' has already been stopped") .satisfies(exception -> assertThat(exception.toString()).matches( "(?s)^io\\.micrometer\\.observation\\.tck\\.InvalidObservationException: Invalid error signal: Observation 'test' has already been stopped\n" - + "START: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$errorAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" - + "STOP: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$errorAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" - + "ERROR: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$errorAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); + + "START: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$errorAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" + + "STOP: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$errorAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" + + "ERROR: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$errorAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); } @Test @@ -147,9 +147,9 @@ void eventAfterStopShouldBeInvalid() { .hasMessage("Invalid event signal: Observation 'test' has already been stopped") .satisfies(exception -> assertThat(exception.toString()).matches( "(?s)^io\\.micrometer\\.observation\\.tck\\.InvalidObservationException: Invalid event signal: Observation 'test' has already been stopped\n" - + "START: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$eventAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" - + "STOP: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$eventAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" - + "EVENT: app//io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$eventAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); + + "START: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$eventAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" + + "STOP: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$eventAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)\n" + + "EVENT: io\\.micrometer\\.observation\\.tck\\.ObservationValidatorTests\\.lambda\\$eventAfterStopShouldBeInvalid\\$\\d+\\(ObservationValidatorTests\\.java:\\d+\\)$")); } @Test