Example usage for org.springframework.boot.actuate.endpoint.web WebEndpointResponse WebEndpointResponse

List of usage examples for org.springframework.boot.actuate.endpoint.web WebEndpointResponse WebEndpointResponse

Introduction

In this page you can find the example usage for org.springframework.boot.actuate.endpoint.web WebEndpointResponse WebEndpointResponse.

Prototype

public WebEndpointResponse(T body) 

Source Link

Document

Creates a new WebEndpointResponse with then given body and a 200 (OK) status.

Usage

From source file:org.springframework.boot.actuate.management.HeapDumpWebEndpoint.java

@ReadOperation
public WebEndpointResponse<Resource> heapDump(@Nullable Boolean live) {
    try {/*  ww  w . ja v  a2  s  .  c  o m*/
        if (this.lock.tryLock(this.timeout, TimeUnit.MILLISECONDS)) {
            try {
                return new WebEndpointResponse<>(dumpHeap((live != null) ? live : true));
            } finally {
                this.lock.unlock();
            }
        }
    } catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
    } catch (IOException ex) {
        return new WebEndpointResponse<>(WebEndpointResponse.STATUS_INTERNAL_SERVER_ERROR);
    } catch (HeapDumperUnavailableException ex) {
        return new WebEndpointResponse<>(WebEndpointResponse.STATUS_SERVICE_UNAVAILABLE);
    }
    return new WebEndpointResponse<>(WebEndpointResponse.STATUS_TOO_MANY_REQUESTS);
}