jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] 01/02: Use Map#computeIfAbsent to simplify code
Date Sun, 09 Aug 2020 12:20:08 GMT
This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git

commit d3a09cecc977e902154657d0a5281bab90d8fbac
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Sun Aug 9 14:12:03 2020 +0200

    Use Map#computeIfAbsent to simplify code
---
 .../org/apache/jmeter/extractor/json/jsonpath/JSONManager.java    | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/components/src/main/java/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java
b/src/components/src/main/java/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java
index 4905d79..03a4ee5 100644
--- a/src/components/src/main/java/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java
+++ b/src/components/src/main/java/org/apache/jmeter/extractor/json/jsonpath/JSONManager.java
@@ -53,13 +53,7 @@ public class JSONManager {
     private final Map<String, JsonPath> expressionToJsonPath = new HashMap<>(2);
 
     private JsonPath getJsonPath(String jsonPathExpression) {
-        JsonPath jsonPath = expressionToJsonPath.get(jsonPathExpression);
-        if (jsonPath == null) {
-            jsonPath = JsonPath.compile(jsonPathExpression);
-            expressionToJsonPath.put(jsonPathExpression, jsonPath);
-        }
-
-        return jsonPath;
+        return expressionToJsonPath.computeIfAbsent(jsonPathExpression, JsonPath::compile);
     }
 
     public void reset() {


Mime
View raw message