-
Bug
-
Resolution: Done
-
Major
-
1.1.0.Final, 1.2.0.Beta6
-
None
-
-
Workaround Exists
-
-
Low
I have few PathPrefixPredicate instantiated with PredicateParser.parse
I use them to check if a request should be allowed (predicate as security permissions) in following code
public boolean isAllowed(HttpServerExchange exchange))
{ ..... return roles(exchange).anyMatch(role -> aclForRole(role).stream().anyMatch(p -> p.resolve(exchange))); }The first p.resolve invocation goes as expected. The second throws a NPE:
java.lang.NullPointerException: null at io.undertow.predicate.PathPrefixPredicate.resolve(PathPrefixPredicate.java:55)
the fact is that Map<String, Object> context = value.getAttachment(PREDICATE_CONTEXT); return null so the NPE.
if I invoke the following method before iterating through the predicates, it goes fine:
private void fixExchangeForUndertowBug(HttpServerExchange exchange)
{ if (exchange.getAttachment(Predicate.PREDICATE_CONTEXT) == null) exchange.putAttachment(Predicate.PREDICATE_CONTEXT, new HashMap<String, Object>()); }The code was working with undertow-core 1.0