@ -19,8 +19,10 @@ package org.springframework.boot.actuate.endpoint.invoker.cache;
@@ -19,8 +19,10 @@ package org.springframework.boot.actuate.endpoint.invoker.cache;
import java.util.function.Function ;
import org.springframework.boot.actuate.endpoint.OperationType ;
import org.springframework.boot.actuate.endpoint.SecurityContext ;
import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker ;
import org.springframework.boot.actuate.endpoint.invoke.OperationInvokerAdvisor ;
import org.springframework.boot.actuate.endpoint.invoke.OperationParameter ;
import org.springframework.boot.actuate.endpoint.invoke.OperationParameters ;
/ * *
@ -40,7 +42,7 @@ public class CachingOperationInvokerAdvisor implements OperationInvokerAdvisor {
@@ -40,7 +42,7 @@ public class CachingOperationInvokerAdvisor implements OperationInvokerAdvisor {
@Override
public OperationInvoker apply ( String endpointId , OperationType operationType ,
OperationParameters parameters , OperationInvoker invoker ) {
if ( operationType = = OperationType . READ & & ! parameters . hasMandatoryParameter ( ) ) {
if ( operationType = = OperationType . READ & & ! hasMandatoryParameter ( parameters ) ) {
Long timeToLive = this . endpointIdTimeToLive . apply ( endpointId ) ;
if ( timeToLive ! = null & & timeToLive > 0 ) {
return new CachingOperationInvoker ( invoker , timeToLive ) ;
@ -49,4 +51,14 @@ public class CachingOperationInvokerAdvisor implements OperationInvokerAdvisor {
@@ -49,4 +51,14 @@ public class CachingOperationInvokerAdvisor implements OperationInvokerAdvisor {
return invoker ;
}
private boolean hasMandatoryParameter ( OperationParameters parameters ) {
for ( OperationParameter parameter : parameters ) {
if ( parameter . isMandatory ( )
& & ! SecurityContext . class . isAssignableFrom ( parameter . getType ( ) ) ) {
return true ;
}
}
return false ;
}
}