mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Change cache lookup logic in XML and JSON response handlers
This commit is contained in:
+5
-3
@@ -114,6 +114,7 @@ public final class JsonPathResponseHandler extends SelectorBasedResponseHandler
|
||||
return extractValueAndCheckType(selector, (String)context, Boolean.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
@Nullable
|
||||
private Long selectLong(@NotNull Selector selector, @NotNull String source) throws Exception {
|
||||
return extractValueAndCheckType(selector, source, Long.class);
|
||||
@@ -121,16 +122,17 @@ public final class JsonPathResponseHandler extends SelectorBasedResponseHandler
|
||||
|
||||
@NotNull
|
||||
private JsonPath lazyCompile(@NotNull String path) throws Exception {
|
||||
if (!myCompiledCache.containsKey(path)) {
|
||||
JsonPath jsonPath = myCompiledCache.get(path);
|
||||
if (jsonPath == null) {
|
||||
try {
|
||||
final JsonPath jsonPath = JsonPath.compile(path);
|
||||
jsonPath = JsonPath.compile(path);
|
||||
myCompiledCache.put(path, jsonPath);
|
||||
}
|
||||
catch (InvalidPathException e) {
|
||||
throw new Exception(String.format("Malformed JsonPath expression '%s'", path));
|
||||
}
|
||||
}
|
||||
return myCompiledCache.get(path);
|
||||
return jsonPath;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -65,16 +65,17 @@ public final class XPathResponseHandler extends SelectorBasedResponseHandler {
|
||||
|
||||
@NotNull
|
||||
private XPath lazyCompile(@NotNull String path) throws Exception {
|
||||
if (!myCompiledCache.containsKey(path)) {
|
||||
XPath xPath = myCompiledCache.get(path);
|
||||
if (xPath == null) {
|
||||
try {
|
||||
final XPath compiled = XPath.newInstance(path);
|
||||
myCompiledCache.put(path, compiled);
|
||||
xPath = XPath.newInstance(path);
|
||||
myCompiledCache.put(path, xPath);
|
||||
}
|
||||
catch (JDOMException e) {
|
||||
throw new Exception(String.format("Malformed XPath expression '%s'", path));
|
||||
}
|
||||
}
|
||||
return myCompiledCache.get(path);
|
||||
return xPath;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user