jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Mouawad <philippe.moua...@gmail.com>
Subject Re: Another analyze with errorprone
Date Tue, 12 Sep 2017 20:45:55 GMT
Hi Antonio,
My answers below.
Regards

On Mon, Sep 11, 2017 at 10:06 PM, Antonio Gomes Rodrigues <ra0077@gmail.com>
wrote:

> Hi,
>
> i have analyse jmeter source with error prone (http://errorprone.info/)
> and
> I have some questions
>
>
> 1.
> It detect a lot of "[DefaultCharset] Implicit use of the platform default
> charset, which can result in e.g. non-ASCII characters being silently
> replaced with '?' in many environments"
>
> e.g.
>
>     [javac]
> /home/ra77/Utils/ErrorProne/trunk/src/functions/org/apache/
> jmeter/functions/FileRowColContainer.java:75:
> warning: [DefaultCharset] Implicit use of the platform default charset,
> which can result in e.g. non-ASCII characters being silently replaced with
> '?' in many environments
>     [javac]         try ( FileReader fis = new FileReader(fileName);
>     [javac]                                ^
>     [javac]     (see http://errorprone.info/bugpattern/DefaultCharset)
>     [javac]   Did you mean 'try ( Reader fis =
> Files.newBufferedReader(Paths.get(fileName), UTF_8);' or 'try ( Reader fis
> = Files.newBufferedReader(Paths.get(fileName),
> Charset.defaultCharset());'?
>     [javac]
> /home/ra77/Utils/ErrorProne/trunk/src/functions/org/apache/
> jmeter/functions/Groovy.java:158:
> warning: [DefaultCharset] Implicit use of the platform default charset,
> which can result in e.g. non-ASCII characters being silently replaced with
> '?' in many environments
>     [javac]             try (FileReader fr = new FileReader(file);
> BufferedReader reader = new BufferedReader(fr)) {
>     [javac]                                  ^
>     [javac]     (see http://errorprone.info/bugpattern/DefaultCharset)
>     [javac]   Did you mean 'try (Reader fr =
> Files.newBufferedReader(file.toPath(), UTF_8); BufferedReader reader = new
> BufferedReader(fr)) {' or 'try (Reader fr =
> Files.newBufferedReader(file.toPath(), Charset.defaultCharset());
> BufferedReader reader = new BufferedReader(fr)) {'?
>
> I don't have checked the source code yet but I would like to know if it is
> wanted or if it is a bug?
>
> Those need further analysis and we need to make use of default charset
explicit.

>
> 2.
> Like before, I don't have the time to study it yet but in
> TransactionSampler.java we cast a long to an it
>
>
>     [javac]
> /home/ra77/Utils/ErrorProne/trunk/src/core/org/apache/jmeter
> /control/TransactionSampler.java:121:
> warning: [NarrowingCompoundAssignment] Compound assignments from long to
> int hide lossy casts
>     [javac]         totalTime += res.getTime();
>     [javac]                   ^
>     [javac]     (see
> http://errorprone.info/bugpattern/NarrowingCompoundAssignment)
>     [javac]   Did you mean 'totalTime = (int) (totalTime +
> res.getTime());'?
>
> Is it wanted?
>
No it's a bug AFAIU. Fixed.

>
>
> 3.
> Like before, I don't have the time to study it yet
>
>     [javac]
> /home/ra77/Utils/ErrorProne/trunk/src/protocol/http/org/apac
> he/jmeter/protocol/http/sampler/hc/HttpPoolEntry.java:52:
> warning: [UnsynchronizedOverridesSynchronized] Unsynchronized method
> isExpired overrides synchronized method in PoolEntry
>     [javac]     public boolean isExpired(final long now) {
>     [javac]                    ^
>     [javac]     (see
> http://errorprone.info/bugpattern/UnsynchronizedOverridesSynchronized)
>     [javac]   Did you mean 'public synchronized boolean isExpired(final
> long now) {'?
>
False positive IMO.
This method is overriden for logging only.
The call to super is synchronized, I don't think there is an issue



>     [javac]
> /home/ra77/Utils/ErrorProne/trunk/src/protocol/http/org/apac
> he/jmeter/protocol/http/util/DirectAccessByteArrayOutputStream.java:36:
> warning: [UnsynchronizedOverridesSynchronized] Unsynchronized method
> toByteArray overrides synchronized method in ByteArrayOutputStream
>     [javac]     public byte[] toByteArray() {
>     [javac]                   ^
>     [javac]     (see
> http://errorprone.info/bugpattern/UnsynchronizedOverridesSynchronized)
>
> Is it wanted?
>
> Yes as per comment

>
> Antonio
>



-- 
Cordialement.
Philippe Mouawad.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message