directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject [directory-fortress-core] branch jmeter-add-case updated: problem with sync method, use atomic integer
Date Mon, 21 Sep 2020 17:12:58 GMT
This is an automated email from the ASF dual-hosted git repository.

smckinney pushed a commit to branch jmeter-add-case
in repository https://gitbox.apache.org/repos/asf/directory-fortress-core.git


The following commit(s) were added to refs/heads/jmeter-add-case by this push:
     new 923d8a4  problem with sync method, use atomic integer
923d8a4 is described below

commit 923d8a4acc0fe231da01516821052e07f7f8d9b8
Author: Shawn McKinney <smckinney@symas.com>
AuthorDate: Mon Sep 21 12:12:52 2020 -0500

    problem with sync method, use atomic integer
---
 .../java/org/apache/directory/fortress/core/jmeter/UserBase.java | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/apache/directory/fortress/core/jmeter/UserBase.java b/src/test/java/org/apache/directory/fortress/core/jmeter/UserBase.java
index ea40979..aa56d0e 100644
--- a/src/test/java/org/apache/directory/fortress/core/jmeter/UserBase.java
+++ b/src/test/java/org/apache/directory/fortress/core/jmeter/UserBase.java
@@ -34,6 +34,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import static org.junit.Assert.assertNotNull;
 
@@ -47,7 +48,8 @@ public abstract class UserBase extends AbstractJavaSamplerClient
     protected AdminMgr adminMgr;
     protected ReviewMgr reviewMgr;
     protected static final Logger LOG = LoggerFactory.getLogger( UserBase.class );
-    private static int count = 0;
+    //private static int count = 0;
+    private static AtomicInteger count = new AtomicInteger(0);
     protected String hostname;
     protected String qualifier;
     private String filename;
@@ -137,9 +139,10 @@ public abstract class UserBase extends AbstractJavaSamplerClient
      *
      * @return
      */
-    synchronized int getKey( )
+    protected int getKey( )
     {
-        return ++count;
+        //return ++count;
+        return count.incrementAndGet();
     }
 
     String getThreadId()


Mime
View raw message