Correct documented path for locked synchronizer's identity hashcode

Closes gh-15847
pull/15889/head
Andy Wilkinson 6 years ago
parent ebcc53a9b7
commit 59c66eaf41

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,9 @@
package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation; package org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.ReentrantLock;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.actuate.management.ThreadDumpEndpoint; import org.springframework.boot.actuate.management.ThreadDumpEndpoint;
@ -42,6 +45,22 @@ public class ThreadDumpEndpointDocumentationTests
@Test @Test
public void threadDump() throws Exception { public void threadDump() throws Exception {
ReentrantLock lock = new ReentrantLock();
CountDownLatch latch = new CountDownLatch(1);
new Thread(() -> {
try {
lock.lock();
try {
latch.await();
}
finally {
lock.unlock();
}
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}).start();
this.mockMvc.perform(get("/actuator/threaddump")).andExpect(status().isOk()) this.mockMvc.perform(get("/actuator/threaddump")).andExpect(status().isOk())
.andDo(MockMvcRestDocumentation.document("threaddump", .andDo(MockMvcRestDocumentation.document("threaddump",
preprocessResponse(limit("threads")), preprocessResponse(limit("threads")),
@ -111,7 +130,7 @@ public class ThreadDumpEndpointDocumentationTests
+ "synchronizer.") + "synchronizer.")
.optional().type(JsonFieldType.STRING), .optional().type(JsonFieldType.STRING),
fieldWithPath( fieldWithPath(
"threads.[].lockedSynchronizers.[].identifyHashCode") "threads.[].lockedSynchronizers.[].identityHashCode")
.description( .description(
"Identity hash code of the locked " "Identity hash code of the locked "
+ "synchronizer.") + "synchronizer.")
@ -187,6 +206,7 @@ public class ThreadDumpEndpointDocumentationTests
"Time in milliseconds that the thread has spent " "Time in milliseconds that the thread has spent "
+ "waiting. -1 if thread contention " + "waiting. -1 if thread contention "
+ "monitoring is disabled")))); + "monitoring is disabled"))));
latch.countDown();
} }
@Configuration @Configuration

Loading…
Cancel
Save