@Around("execution(@ConfigureAgentStuckThresholdMillis void org.jmonitor..*Test.*())") public void aroundConfigureAgentStuckThresholdMillisPointcut(ProceedingJoinPoint joinPoint) throws Throwable { ConfigureAgentStuckThresholdMillis annotation = getAnnotation(ConfigureAgentStuckThresholdMillis.class, joinPoint); AgentConfigurationImpl mutableConfiguration = getMutableAgentConfiguration(); int previousValue = mutableConfiguration.getStuckThresholdMillis(); // set it to annotated value mutableConfiguration.setStuckThresholdMillis(annotation.value()); ConfigurationServiceImpl.getInstance().updateAgentConfiguration(mutableConfiguration); try { joinPoint.proceed(); } finally { // set it back to original value mutableConfiguration.setStuckThresholdMillis(previousValue); ConfigurationServiceImpl.getInstance().updateAgentConfiguration(mutableConfiguration); } }