Skip to content
Permalink
Browse files
8285726: [11u, 17u] Unify fix for JDK-8284548 with version from head
Reviewed-by: bae
  • Loading branch information
Yuri Nesterenko committed May 16, 2022
1 parent ec0598f commit c83eb83fcc33ba9ab6e6e783fe0e9acdbe0085c5
Showing 1 changed file with 19 additions and 11 deletions.
@@ -36,18 +36,26 @@ public class InvalidXPath {

public static void main(String... args) {
// define an invalid XPath expression
final String invalidXPath = ">>";
final String[] invalidXPath = {
// @bug JDK-8284548: expressions ending with relational operators
// throw StringIndexOutOfBoundsException instead of XPathExpressionException
"/a/b/c[@d >",
"/a/b/c[@d <",
"/a/b/c[@d >=",
">>"
};

// expect XPathExpressionException when the invalid XPath expression is compiled
try {
XPathFactory.newInstance().newXPath().compile(invalidXPath);
} catch (XPathExpressionException e) {
System.out.println("Caught expected exception: " + e.getClass().getName() +
"(" + e.getMessage() + ").");
} catch (Exception e) {
System.out.println("Caught unexpected exception: " + e.getClass().getName() +
"(" + e.getMessage() + ")!");
throw e;
for(String s: invalidXPath) {
try {
XPathFactory.newInstance().newXPath().compile(s);
} catch (XPathExpressionException e) {
System.out.println("Caught expected exception: " + e.getClass().getName() +
"(" + e.getMessage() + ").");
} catch (Exception e) {
System.out.println("Caught unexpected exception: " + e.getClass().getName() +
"(" + e.getMessage() + ")!");
throw e;
}
}
}
}

1 comment on commit c83eb83

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on c83eb83 May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.