On Saturday, March 2, 2019, Felix Schumacher <
[email protected]> wrote:

>
>
> Am 2. März 2019 11:57:29 MEZ schrieb [email protected]:
> >Author: pmouawad
> >Date: Sat Mar  2 10:57:29 2019
> >New Revision: 1854637
> >
> >URL: http://svn.apache.org/viewvc?rev=1854637&view=rev
> >Log:
> >Replace synchronization by ConcurrentHashMap
> >
> >Modified:
> >    jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
> >
> >Modified:
> >jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
> >URL:
> >http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/
> apache/jmeter/samplers/SampleResult.java?rev=1854637&
> r1=1854636&r2=1854637&view=diff
> >===========================================================
> ===================
> >--- jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
> >(original)
> >+++ jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
> >Sat Mar  2 10:57:29 2019
> >@@ -25,9 +25,9 @@ import java.net.URL;
> > import java.nio.charset.Charset;
> > import java.nio.charset.StandardCharsets;
> > import java.util.ArrayList;
> >-import java.util.HashSet;
> > import java.util.List;
> >-import java.util.Set;
> >+import java.util.Map;
> >+import java.util.concurrent.ConcurrentHashMap;
> > import java.util.concurrent.TimeUnit;
> >
> > import org.apache.jmeter.assertions.AssertionResult;
> >@@ -47,7 +47,7 @@ import org.slf4j.LoggerFactory;
> >  *
> >  */
> >public class SampleResult implements Serializable, Cloneable,
> >Searchable {
> >-
> >+    private static final Byte BYTE = Byte.valueOf((byte)0);
>
> I wondered quite a long time, why you introduced a new constant name BYTE.
> I think I would have got the meaning a bit faster, if it would have been
> named DUMMY, MARKER or SOME_VALUE.


Go ahead and change its name.

>
> Do you have any special reason for using Byte instead of a naked Object?


No special reason.

>
> Felix
>
> >     private static final long serialVersionUID = 241L;
> >
> >     // Needs to be accessible from Test code
> >@@ -213,9 +213,9 @@ public class SampleResult implements Ser
> >     /**
> >      * Files that this sample has been saved in.
> >  * In Non GUI mode and when best config is used, size never exceeds 1,
> >-     * but as a compromise set it to 3
> >+     * but as a compromise set it to 2
> >      */
> >-    private final Set<String> files = new HashSet<>(3);
> >+    private final Map<String, Byte> files = new
> >ConcurrentHashMap<>(2);
> >
> >// TODO do contentType and/or dataEncoding belong in HTTPSampleResult
> >instead?
> >private String dataEncoding;// (is this really the character set?) e.g.
> >@@ -499,8 +499,9 @@ public class SampleResult implements Ser
> >      * @param filename the name of the file
> >      * @return <code>true</code> if the result was previously marked
> >      */
> >-    public synchronized boolean markFile(String filename) {
> >-        return !files.add(filename);
> >+    public boolean markFile(String filename) {
> >+        Byte result = files.putIfAbsent(filename, BYTE);
> >+        return result != null;
> >     }
> >
> >     public String getResponseCode() {
>


-- 
Cordialement.
Philippe Mouawad.

Reply via email to