Forum Discussion

noxidog's avatar
15 years ago

bug in RemoveEmptyContentRequestFilter

Hi,

I really like the huge amount of functionality your product provides, keep up the good work.

Method: com.eviware.soapui.impl.wsdl.submit.filters.RemoveEmptyContentRequestFilter.removeEmptyContent()
Problem: if( attributes.getLength() == 0 && cursor.getTextValue() == null
|| cursor.getTextValue().trim().length() == 0 && XmlUtils.getFirstChildElement( elm ) == null )

the logical OR (||) has a lower precedence than the logical AND (&&) and the entire expression actually ends up being two AND clauses. The result is that items which have attributes, but DO NOT HAVE children are deleted INCORRECTLY.

Solution: if( attributes.getLength() == 0
&& (cursor.getTextValue() == null || cursor.getTextValue().trim().length() == 0)
&& XmlUtils.getFirstChildElement( elm ) == null )

Another Problem: Items that have children which end up being removed, WILL NOT be removed. I have a fix for this and if you are interested I can just send you the body of the method, but you will probably come up with your own solution. My solution is basically to remember the parents of removed nodes, and then to check if they did not become empty as a result of the removal.

Hope this helps,

Tervel

1 Reply

  • Hi Tervel!

    Hugt thanks for this, I've added the fix to the nightly builds codebase.

    Regarding the other issue I think this is supported by adding a "RemoveEmptyRecursive" property to the context which will trigger the filter to rerun the actual algorithm until nothing can be removed any more.. does that make sense?

    regards!

    /Ole
    eviware.com