Skip to content

Commit

Permalink
Feature/#297 cannot invoke bucket4 j boot properties.get methods() be…
Browse files Browse the repository at this point in the history
…cause bucket4j properties is null (#303)

* Cannot invoke Bucket4JBootProperties.getMethods()" because "bucket4jProperties" is null #297

* Cannot invoke Bucket4JBootProperties.getMethods()" because "bucket4jProperties" is null #297
  • Loading branch information
MarcGiffing authored May 30, 2024
1 parent 7a6d731 commit c2b80ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ 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) {
return ConditionOutcome.noMatch("@ConditionalOnAsynchronousPropertyCondition Bucket4jBootProperties not configured");
}
var reactiveFilterConfigurationExists = bucket4jProperties.getFilters()
.stream()
.anyMatch(x -> List.of(FilterMethod.WEBFLUX, FilterMethod.GATEWAY).contains(x.getFilterMethod()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ 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) {
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) {
Expand Down

0 comments on commit c2b80ea

Please sign in to comment.