From 1a040fa8f9a02cbdabaafd9302ec7490e6af1491 Mon Sep 17 00:00:00 2001 From: Lukas Morawietz Date: Fri, 13 Aug 2021 14:36:45 +0200 Subject: [PATCH] replace classInChaosMonkeyPackage calls with isBlackListedPointcut --- .../chaos/monkey/watcher/aspect/ChaosMonkeyBaseAspect.java | 5 ++--- .../watcher/aspect/SpringBootHealthIndicatorAspect.java | 2 +- .../chaos/monkey/watcher/aspect/SpringComponentAspect.java | 2 +- .../chaos/monkey/watcher/aspect/SpringControllerAspect.java | 2 +- .../monkey/watcher/aspect/SpringRepositoryAspectJDBC.java | 2 +- .../monkey/watcher/aspect/SpringRepositoryAspectJPA.java | 2 +- .../monkey/watcher/aspect/SpringRestControllerAspect.java | 2 +- .../chaos/monkey/watcher/aspect/SpringServiceAspect.java | 2 +- 8 files changed, 9 insertions(+), 10 deletions(-) diff --git a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/ChaosMonkeyBaseAspect.java b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/ChaosMonkeyBaseAspect.java index 4fc839df..a8ab1744 100644 --- a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/ChaosMonkeyBaseAspect.java +++ b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/ChaosMonkeyBaseAspect.java @@ -29,11 +29,10 @@ public void classInChaosMonkeyPackage() {} public void nonFinalOrJdkProxiedClassPointcut() {} // GenericFilterBean cannot be proxied due to final init method. - @Pointcut("this(org.springframework.web.filter.GenericFilterBean)") + @Pointcut("classInChaosMonkeyPackage() || target(org.springframework.web.filter.GenericFilterBean)") public void isBlackListedPointcut() {} - @Pointcut( - "!isBlackListedPointcut() && nonFinalOrJdkProxiedClassPointcut() && execution(* *.*(..))") + @Pointcut("nonFinalOrJdkProxiedClassPointcut() && execution(* *.*(..))") public void allPublicMethodPointcut() {} @Pointcut( diff --git a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringBootHealthIndicatorAspect.java b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringBootHealthIndicatorAspect.java index 2b134bef..26fd9f75 100644 --- a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringBootHealthIndicatorAspect.java +++ b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringBootHealthIndicatorAspect.java @@ -24,7 +24,7 @@ public class SpringBootHealthIndicatorAspect extends ChaosMonkeyBaseAspect { @Pointcut("execution(* org.springframework.boot.actuate.health.HealthIndicator.getHealth(..))") public void getHealthPointCut() {} - @Around("getHealthPointCut() && !classInChaosMonkeyPackage()") + @Around("getHealthPointCut() && !isBlackListedPointcut()") public Object intercept(ProceedingJoinPoint pjp) throws Throwable { Health health = (Health) pjp.proceed(); if (watcherProperties.isActuatorHealth()) { diff --git a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringComponentAspect.java b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringComponentAspect.java index 77462662..5cc1c5b1 100644 --- a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringComponentAspect.java +++ b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringComponentAspect.java @@ -49,7 +49,7 @@ public void classInSpringCloudContextPackage() {} @Around( "classAnnotatedWithComponentPointcut() && !classInSpringCloudContextPackage() " - + "&& allPublicMethodPointcut() && !classInChaosMonkeyPackage() && !springHooksPointcut()") + + "&& allPublicMethodPointcut() && !isBlackListedPointcut() && !springHooksPointcut()") public Object intercept(ProceedingJoinPoint pjp) throws Throwable { if (watcherProperties.isComponent()) { log.debug("Watching public method on component class: {}", pjp.getSignature()); diff --git a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringControllerAspect.java b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringControllerAspect.java index 69f61683..a7428463 100644 --- a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringControllerAspect.java +++ b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringControllerAspect.java @@ -45,7 +45,7 @@ public class SpringControllerAspect extends ChaosMonkeyBaseAspect { public void classAnnotatedWithControllerPointcut() {} @Around( - "classAnnotatedWithControllerPointcut() && allPublicMethodPointcut() && !classInChaosMonkeyPackage()") + "classAnnotatedWithControllerPointcut() && allPublicMethodPointcut() && !isBlackListedPointcut()") public Object intercept(ProceedingJoinPoint pjp) throws Throwable { if (watcherProperties.isController()) { diff --git a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRepositoryAspectJDBC.java b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRepositoryAspectJDBC.java index 33d0af34..123f5604 100644 --- a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRepositoryAspectJDBC.java +++ b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRepositoryAspectJDBC.java @@ -45,7 +45,7 @@ public class SpringRepositoryAspectJDBC extends ChaosMonkeyBaseAspect { public void classAnnotatedWithRepositoryPointcut() {} @Around( - "classAnnotatedWithRepositoryPointcut() && allPublicMethodPointcut() && !classInChaosMonkeyPackage()") + "classAnnotatedWithRepositoryPointcut() && allPublicMethodPointcut() && !isBlackListedPointcut()") public Object intercept(ProceedingJoinPoint pjp) throws Throwable { if (watcherProperties.isRepository()) { diff --git a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRepositoryAspectJPA.java b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRepositoryAspectJPA.java index df2613ca..761e044a 100644 --- a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRepositoryAspectJPA.java +++ b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRepositoryAspectJPA.java @@ -45,7 +45,7 @@ public class SpringRepositoryAspectJPA extends ChaosMonkeyBaseAspect { "this(org.springframework.data.repository.Repository) || within(@org.springframework.data.repository.RepositoryDefinition *)") public void implementsCrudRepository() {} - @Around("implementsCrudRepository() && allPublicMethodPointcut() && !classInChaosMonkeyPackage()") + @Around("implementsCrudRepository() && allPublicMethodPointcut() && !isBlackListedPointcut()") public Object intercept(ProceedingJoinPoint pjp) throws Throwable { if (watcherProperties.isRepository()) { diff --git a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRestControllerAspect.java b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRestControllerAspect.java index 45dcc21f..09eba019 100644 --- a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRestControllerAspect.java +++ b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringRestControllerAspect.java @@ -45,7 +45,7 @@ public class SpringRestControllerAspect extends ChaosMonkeyBaseAspect { public void classAnnotatedWithControllerPointcut() {} @Around( - "classAnnotatedWithControllerPointcut() && allPublicMethodPointcut() && !classInChaosMonkeyPackage()") + "classAnnotatedWithControllerPointcut() && allPublicMethodPointcut() && !isBlackListedPointcut()") public Object intercept(ProceedingJoinPoint pjp) throws Throwable { if (watcherProperties.isRestController()) { diff --git a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringServiceAspect.java b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringServiceAspect.java index 673be14b..6f10e0a5 100644 --- a/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringServiceAspect.java +++ b/chaos-monkey-spring-boot/src/main/java/de/codecentric/spring/boot/chaos/monkey/watcher/aspect/SpringServiceAspect.java @@ -45,7 +45,7 @@ public class SpringServiceAspect extends ChaosMonkeyBaseAspect { public void classAnnotatedWithServicePointcut() {} @Around( - "classAnnotatedWithServicePointcut() && allPublicMethodPointcut() && !classInChaosMonkeyPackage()" + "classAnnotatedWithServicePointcut() && allPublicMethodPointcut() && !isBlackListedPointcut()" + "&& !springHooksPointcut()") public Object intercept(ProceedingJoinPoint pjp) throws Throwable {