diff --git a/micrometer-core/src/test/java/io/micrometer/core/instrument/TagsTest.java b/micrometer-core/src/test/java/io/micrometer/core/instrument/TagsTest.java index 1ca2c4f140..b382b9647a 100644 --- a/micrometer-core/src/test/java/io/micrometer/core/instrument/TagsTest.java +++ b/micrometer-core/src/test/java/io/micrometer/core/instrument/TagsTest.java @@ -338,26 +338,7 @@ void emptyShouldNotContainTags() { @Issue("#3313") @DisabledIfSystemProperty(named = "java.vm.name", matches = JAVA_VM_NAME_J9_REGEX, disabledReason = "Sun ThreadMXBean with allocation counter not available") - @EnabledForJreRange(max = JRE.JAVA_18) void andEmptyDoesNotAllocate() { - andEmptyDoesNotAllocate(0); - } - - // See https://github.com/micrometer-metrics/micrometer/issues/3436 - @Test - @Issue("#3313") - @DisabledIfSystemProperty(named = "java.vm.name", matches = JAVA_VM_NAME_J9_REGEX, - disabledReason = "Sun ThreadMXBean with allocation counter not available") - @EnabledIf("java19") - void andEmptyDoesNotAllocateOnJava19() { - andEmptyDoesNotAllocate(16); - } - - static boolean java19() { - return "19".equals(System.getProperty("java.version")); - } - - private void andEmptyDoesNotAllocate(int expectedAllocatedBytes) { ThreadMXBean threadMXBean = (ThreadMXBean) ManagementFactory.getThreadMXBean(); long currentThreadId = Thread.currentThread().getId(); Tags tags = Tags.of("a", "b"); @@ -368,29 +349,14 @@ private void andEmptyDoesNotAllocate(int expectedAllocatedBytes) { long allocatedBytes = threadMXBean.getThreadAllocatedBytes(currentThreadId) - allocatedBytesBefore; assertThat(combined).isEqualTo(tags); - assertThat(allocatedBytes).isEqualTo(expectedAllocatedBytes); + assertThat(allocatedBytes).isEqualTo(0); } @Test @Issue("#3313") @DisabledIfSystemProperty(named = "java.vm.name", matches = JAVA_VM_NAME_J9_REGEX, disabledReason = "Sun ThreadMXBean with allocation counter not available") - @EnabledForJreRange(max = JRE.JAVA_18) void ofEmptyDoesNotAllocate() { - ofEmptyDoesNotAllocate(0); - } - - // See https://github.com/micrometer-metrics/micrometer/issues/3436 - @Test - @Issue("#3313") - @DisabledIfSystemProperty(named = "java.vm.name", matches = JAVA_VM_NAME_J9_REGEX, - disabledReason = "Sun ThreadMXBean with allocation counter not available") - @EnabledIf("java19") - void ofEmptyDoesNotAllocateOnJava19() { - ofEmptyDoesNotAllocate(16); - } - - private void ofEmptyDoesNotAllocate(int expectedAllocatedBytes) { ThreadMXBean threadMXBean = (ThreadMXBean) ManagementFactory.getThreadMXBean(); long currentThreadId = Thread.currentThread().getId(); Tags extraTags = Tags.empty(); @@ -400,7 +366,7 @@ private void ofEmptyDoesNotAllocate(int expectedAllocatedBytes) { long allocatedBytes = threadMXBean.getThreadAllocatedBytes(currentThreadId) - allocatedBytesBefore; assertThat(of).isEqualTo(Tags.empty()); - assertThat(allocatedBytes).isEqualTo(expectedAllocatedBytes); + assertThat(allocatedBytes).isEqualTo(0); } private void assertTags(Tags tags, String... keyValues) {