From 080e659e6c09e5a79fea4220ce0f03244176849a Mon Sep 17 00:00:00 2001 From: Pablete1234 Date: Wed, 3 Aug 2022 20:05:49 +0200 Subject: [PATCH] Fix flag state filters on load Signed-off-by: Pablete1234 --- .../java/tc/oc/pgm/filters/matcher/match/FlagStateFilter.java | 3 ++- .../main/java/tc/oc/pgm/filters/parse/FeatureFilterParser.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/filters/matcher/match/FlagStateFilter.java b/core/src/main/java/tc/oc/pgm/filters/matcher/match/FlagStateFilter.java index 445413da20..2269d55f1e 100644 --- a/core/src/main/java/tc/oc/pgm/filters/matcher/match/FlagStateFilter.java +++ b/core/src/main/java/tc/oc/pgm/filters/matcher/match/FlagStateFilter.java @@ -41,7 +41,8 @@ public Class queryType() { @Override public boolean matches(MatchQuery query) { Flag flag = this.flag.get().getGoal(query.getMatch()); - if (flag == null) throw new IllegalStateException("Flag not found"); + // FIXME: This may occur at load time. We need a better fix for this. + if (flag == null) return false; return flag.isCurrent(this.state) && (this.post == null || flag.isAtPost(this.post.get())); } diff --git a/core/src/main/java/tc/oc/pgm/filters/parse/FeatureFilterParser.java b/core/src/main/java/tc/oc/pgm/filters/parse/FeatureFilterParser.java index 3886122d60..2fb2e075e8 100644 --- a/core/src/main/java/tc/oc/pgm/filters/parse/FeatureFilterParser.java +++ b/core/src/main/java/tc/oc/pgm/filters/parse/FeatureFilterParser.java @@ -29,7 +29,7 @@ public ContextStore getUsedContext() { public Filter parse(Element el) throws InvalidXMLException { Filter filter = this.parseDynamic(el); if (!(filter instanceof FeatureReference)) { - factory.getFeatures().addFeature(el, (FilterDefinition) filter); + factory.getFeatures().addFeature(el, filter); } return filter; }