I am trying to build a dynamic url for a PointSymbolizer:


The problem I am running into is that the strUrlEncode will return null if the "foo" property is null. When that happens I get the following exception:

DEBUG [function.string] - Failed to concatenate string in Concatenate function
    at java.net.URLEncoder.encode(URLEncoder.java:204)
    at org.geotools.filter.function.string.URLEncodeFunction.evaluate(URLEncodeFunction.java:87)
    at org.geotools.filter.expression.ExpressionAbstract.evaluate(ExpressionAbstract.java:45)
    at org.geotools.filter.function.string.ConcatenateFunction.evaluate(ConcatenateFunction.java:66)
    at org.geotools.filter.expression.ExpressionAbstract.evaluate(ExpressionAbstract.java:45)

I imagine that is happening because the result of my first strUrlEncode (which is null) is being concatenated to the second parameter.

Is there any way I can provide a default non-null value in a case where foo is null to avoid the NPE?

  • Why not check the value before you pass it to PointSymbolizer?
    – TomazicM
    May 5, 2019 at 16:01
  • I am not sure what you mean by check it first. If you are talking about a rule, that becomes problematic when there is more than 2 query params. I would have to provide rules for each enumeration ie if (foo & bar & third) or if(foo &bar) or if(foo & third) and so on. So even with just 3 query params the logic is a bit "heavy" May 5, 2019 at 16:07

1 Answer 1


The problem is that the java function URLEncoder.encode() doesn't handle null arguments and the GeoTools function is not checking if the argument is null. You need to add a check before line 87 and return an empty string or "null" if the argument is null.

As always pull requests with a test case are welcome.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.