I¹m getting  a freemarker error when I use a s:checkboxlist tag and the
array which contains my item values is empty.

When I had a look at the stack trace it¹s pointing me to the following
error:

Caused by: java.lang.NullPointerException
        at org.apache.struts2.util.ContainUtil.contains(ContainUtil.java:96)

When I had a look at the source for ContainUtil, I noticed that the equals
expression is arse about.

if (obj1.getClass().isArray()) {
            for (int i = 0; i < Array.getLength(obj1); i++) {
                Object value = null;
                value = Array.get(obj1, i);

(Error is thrown here)  if (value.equals(obj2)) {
                    //log.debug("obj1 is an array and contains obj2");
                    return true;
                }
            }

Ideally the expression would be best rewritten if(obj2.equals(value))  as we
have already tested obj2 for nullness at the start of the contains method.

Now the hard part, I don¹t want to have to recompile the struts code and was
hoping there was a simple workaround.

All suggestions considered at this point.

TIA 

Z.

Reply via email to