jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject [jmeter] branch master updated: Move lock out of try block
Date Wed, 25 Nov 2020 16:34:20 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


The following commit(s) were added to refs/heads/master by this push:
     new f5fe3f5  Move lock out of try block
f5fe3f5 is described below

commit f5fe3f5f404724f8a1fb28fd0668394a60ebf499
Author: Felix Schumacher <felix.schumacher@internetallee.de>
AuthorDate: Wed Nov 25 17:33:16 2020 +0100

    Move lock out of try block
    
    That way the release in finally will not release a possibly non-locked
    lock.
---
 .../src/main/java/org/apache/jmeter/functions/StringToFile.java         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/functions/src/main/java/org/apache/jmeter/functions/StringToFile.java b/src/functions/src/main/java/org/apache/jmeter/functions/StringToFile.java
index 3cb0879..0d02a24 100644
--- a/src/functions/src/main/java/org/apache/jmeter/functions/StringToFile.java
+++ b/src/functions/src/main/java/org/apache/jmeter/functions/StringToFile.java
@@ -102,8 +102,8 @@ public class StringToFile extends AbstractFunction {
         }
         log.debug("Writing {} to file {} with charset {} and append {}", content, fileName,
charset, append);
         Lock lock = lockMap.computeIfAbsent(fileName, key -> new ReentrantLock());
+        lock.lock();
         try {
-            lock.lock();
             File file = new File(fileName);
             File fileParent = file.getParentFile();
             if (fileParent == null || (fileParent.exists() && fileParent.isDirectory()
&& fileParent.canWrite())) {


Mime
View raw message