From 59c66eaf413ae22c05a43a775abc86315a7e8429 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 5 Feb 2019 12:30:46 +0000 Subject: [PATCH] Correct documented path for locked synchronizer's identity hashcode Closes gh-15847 --- .../ThreadDumpEndpointDocumentationTests.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ThreadDumpEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ThreadDumpEndpointDocumentationTests.java index 156c7becb9..a213b566b4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ThreadDumpEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/ThreadDumpEndpointDocumentationTests.java @@ -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"); * 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; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.locks.ReentrantLock; + import org.junit.Test; import org.springframework.boot.actuate.management.ThreadDumpEndpoint; @@ -42,6 +45,22 @@ public class ThreadDumpEndpointDocumentationTests @Test 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()) .andDo(MockMvcRestDocumentation.document("threaddump", preprocessResponse(limit("threads")), @@ -111,7 +130,7 @@ public class ThreadDumpEndpointDocumentationTests + "synchronizer.") .optional().type(JsonFieldType.STRING), fieldWithPath( - "threads.[].lockedSynchronizers.[].identifyHashCode") + "threads.[].lockedSynchronizers.[].identityHashCode") .description( "Identity hash code of the locked " + "synchronizer.") @@ -187,6 +206,7 @@ public class ThreadDumpEndpointDocumentationTests "Time in milliseconds that the thread has spent " + "waiting. -1 if thread contention " + "monitoring is disabled")))); + latch.countDown(); } @Configuration