Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.3
-
None
-
None
Description
There appears to be an inifinite loop in org.apache.commons.jxpath.ri.NamespaceResolver.getPrefix(). While I haven't yet been able to create a minimal test app that reproduces the problem, the bug seems fairly self-evident from the code.
protected static String getPrefix(NodePointer pointer, String namespaceURI) { NodePointer currentPointer = pointer; while (currentPointer != null) { NodeIterator ni = currentPointer.namespaceIterator(); for (int position = 1; ni != null && ni.setPosition(position); position++) { NodePointer nsPointer = ni.getNodePointer(); String uri = nsPointer.getNamespaceURI(); if (uri.equals(namespaceURI)) { String prefix = nsPointer.getName().getName(); if (!"".equals(prefix)) { return prefix; } } } currentPointer = pointer.getParent(); } return null; }
The problem line is the last line in the loop: 'currentPointer = pointer.getParent();'. As the 'pointer' variable never changes, the value of 'currentPointer' never changes between loop iterations after the second iteration. Consequently if the namespace prefix is not found in the first two iterations, an infinite loop occurs. The problem seems to be resolved by changing that line to 'currentPointer = currentPointer.getParent();'.
Attachments
Issue Links
- is duplicated by
-
JXPATH-140 Error in loop of NamespaceResolver
- Closed