Skip to content

Commit

Permalink
Cannot invoke Bucket4JBootProperties.getMethods()" because "bucket4jP…
Browse files Browse the repository at this point in the history
…roperties" is null #297
  • Loading branch information
MarcGiffing committed May 30, 2024
1 parent 9cb2448 commit b077c37
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ public class OnAsynchronousPropertyCondition extends SpringBootCondition {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
var bucket4jProperties = Binder.get(context.getEnvironment()).bind("bucket4j", Bucket4JBootProperties.class).orElse(null);
if (bucket4jProperties != null) {
var reactiveFilterConfigurationExists = bucket4jProperties.getFilters()
.stream()
.anyMatch(x -> List.of(FilterMethod.WEBFLUX, FilterMethod.GATEWAY).contains(x.getFilterMethod()));
if (reactiveFilterConfigurationExists) {
return ConditionOutcome.match("@ConditionalOnAsynchronousPropertyCondition Found reactive filter");
} else {
return ConditionOutcome.noMatch("@ConditionalOnAsynchronousPropertyCondition No filter configuration with FilterMethod.WEBFLUX org FilterMethod.GATEWAY configured");
}
} else {
if (bucket4jProperties == null) {
return ConditionOutcome.noMatch("@ConditionalOnAsynchronousPropertyCondition Bucket4jBootProperties not configured");
}
var reactiveFilterConfigurationExists = bucket4jProperties.getFilters()
.stream()
.anyMatch(x -> List.of(FilterMethod.WEBFLUX, FilterMethod.GATEWAY).contains(x.getFilterMethod()));
if (reactiveFilterConfigurationExists) {
return ConditionOutcome.match("@ConditionalOnAsynchronousPropertyCondition Found reactive filter");
} else {
return ConditionOutcome.noMatch("@ConditionalOnAsynchronousPropertyCondition No filter configuration with FilterMethod.WEBFLUX org FilterMethod.GATEWAY configured");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ public class OnSynchronousPropertyCondition extends SpringBootCondition {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
var bucket4jProperties = Binder.get(context.getEnvironment()).bind("bucket4j", Bucket4JBootProperties.class).orElse(null);
if(bucket4jProperties != null) {
var methodConfigurationExists = !bucket4jProperties.getMethods().isEmpty();
var servletConfigurationExist = bucket4jProperties.getFilters().stream().anyMatch(x -> x.getFilterMethod().equals(FilterMethod.SERVLET));
if (methodConfigurationExists || servletConfigurationExist) {
return ConditionOutcome.match("@ConditionalOnSynchronPropertyCondition Found filter method and/or servlet configuration");
} else {
return ConditionOutcome.noMatch("@ConditionalOnSynchronPropertyCondition No method configuration or filter configuration with FilterMethod.SERVLET configured");
}
} else {
if (bucket4jProperties == null) {
return ConditionOutcome.noMatch("@ConditionalOnSynchronPropertyCondition Bucket4jBootProperties not configured");
}
var methodConfigurationExists = !bucket4jProperties.getMethods().isEmpty();
var servletConfigurationExist = bucket4jProperties.getFilters().stream().anyMatch(x -> x.getFilterMethod().equals(FilterMethod.SERVLET));
if (methodConfigurationExists || servletConfigurationExist) {
return ConditionOutcome.match("@ConditionalOnSynchronPropertyCondition Found filter method and/or servlet configuration");
} else {
return ConditionOutcome.noMatch("@ConditionalOnSynchronPropertyCondition No method configuration or filter configuration with FilterMethod.SERVLET configured");
}
}
}

0 comments on commit b077c37

Please sign in to comment.