Skip to content

Commit

Permalink
Remove JDK 19-specific tests in TagsTest
Browse files Browse the repository at this point in the history
  • Loading branch information
izeye committed Dec 28, 2023
1 parent 08573c6 commit 0c72fff
Showing 1 changed file with 2 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,26 +329,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");
Expand All @@ -359,7 +340,7 @@ private void andEmptyDoesNotAllocate(int expectedAllocatedBytes) {
long allocatedBytes = threadMXBean.getThreadAllocatedBytes(currentThreadId) - allocatedBytesBefore;

assertThat(combined).isEqualTo(tags);
assertThat(allocatedBytes).isEqualTo(expectedAllocatedBytes);
assertThat(allocatedBytes).isEqualTo(0);
}

@Test
Expand All @@ -368,20 +349,6 @@ private void andEmptyDoesNotAllocate(int expectedAllocatedBytes) {
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();
Expand All @@ -391,7 +358,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) {
Expand Down

0 comments on commit 0c72fff

Please sign in to comment.