jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1380860 - in /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http: control/HC3CookieHandler.java control/HC4CookieHandler.java sampler/AjpSampler.java
Date Thu, 06 Sep 2012 00:00:45 GMT
On 5 September 2012 23:58, sebb <sebbaz@gmail.com> wrote:
> On 4 September 2012 21:28,  <pmouawad@apache.org> wrote:
>> Author: pmouawad
>> Date: Tue Sep  4 20:28:41 2012
>> New Revision: 1380860
>>
>> URL: http://svn.apache.org/viewvc?rev=1380860&view=rev
>> Log:
>> Make some fields final
>>
>> Modified:
>>     jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java
>>     jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC4CookieHandler.java
>>     jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
>>
>> Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java
>> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java?rev=1380860&r1=1380859&r2=1380860&view=diff
>> ==============================================================================
>> --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java
(original)
>> +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC3CookieHandler.java
Tue Sep  4 20:28:41 2012
>> @@ -36,7 +36,7 @@ import org.apache.log.Logger;
>>  public class HC3CookieHandler implements CookieHandler {
>>     private static final Logger log = LoggingManager.getLoggerForClass();
>>
>> -       private transient CookieSpec cookieSpec;
>> +       private final transient CookieSpec cookieSpec;
>
> Adding final here is fine, but it makes me wonder if the field should
> be transient?
>
> Generally, transient fields cannot be final, as serialised instances
> cannot generally set final fields.
>
> In this case, the class is not serialisable, so transient should
> probably be dropped.

There are some occasions when it is necessary to flag fields transient:
- to avoid warnings about serialisable classes having non-serialisable
fields. Almost all the GUI classes inherit serialisable, but they are
not serialised when using client server mode so there is no issue with
the field not being initialised correctly.
- I think it also prevents the field from being saved to JMX files

>
>>         /**
>>          *
>>
>> Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC4CookieHandler.java
>> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC4CookieHandler.java?rev=1380860&r1=1380859&r2=1380860&view=diff
>> ==============================================================================
>> --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC4CookieHandler.java
(original)
>> +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HC4CookieHandler.java
Tue Sep  4 20:28:41 2012
>> @@ -48,7 +48,7 @@ import org.apache.log.Logger;
>>  public class HC4CookieHandler implements CookieHandler {
>>      private static final Logger log = LoggingManager.getLoggerForClass();
>>
>> -    private transient CookieSpec cookieSpec;
>> +    private final transient CookieSpec cookieSpec;
>>
>>      private static CookieSpecRegistry registry  = new CookieSpecRegistry();
>>
>>
>> Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
>> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java?rev=1380860&r1=1380859&r2=1380860&view=diff
>> ==============================================================================
>> --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
(original)
>> +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/AjpSampler.java
Tue Sep  4 20:28:41 2012
>> @@ -90,9 +90,9 @@ public class AjpSampler extends HTTPSamp
>>      private String lastHost = null;
>>      private String localName = null;
>>      private String localAddress = null;
>> -    private byte [] inbuf = new byte[8*1024];
>> -    private byte [] outbuf = new byte[8*1024];
>> -    private transient ByteArrayOutputStream responseData = new ByteArrayOutputStream();
>> +    private final byte [] inbuf = new byte[8*1024];
>> +    private final byte [] outbuf = new byte[8*1024];
>> +    private final transient ByteArrayOutputStream responseData = new ByteArrayOutputStream();
>>      private int inpos = 0;
>>      private int outpos = 0;
>>      private transient String stringBody = null;
>>
>>

Mime
View raw message