You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by sc...@apache.org on 2014/08/27 18:05:38 UTC

svn commit: r1620923 - /tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java

Author: schultz
Date: Wed Aug 27 16:05:38 2014
New Revision: 1620923

URL: http://svn.apache.org/r1620923
Log:
Added missing hashCode method.

Modified:
    tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java

Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java?rev=1620923&r1=1620922&r2=1620923&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java (original)
+++ tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java Wed Aug 27 16:05:38 2014
@@ -25,6 +25,8 @@
 
 package org.apache.jasper.xmlparser;
 
+import java.util.Arrays;
+
 /**
  * This class is used as a structure to pass text contained in the underlying
  * character buffer of the scanner. The offset and length fields allow the
@@ -138,6 +140,11 @@ public class XMLString {
     //
     // Object methods
     //
+    @Override
+    public int hashCode()
+    {
+        return Arrays.hashCode(ch);
+    }
 
     /** Returns a string representation of this object. */
     @Override



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1620923 - /tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Mark,

On 8/27/14, 1:33 PM, Mark Thomas wrote:
> On 27/08/2014 18:00, Christopher Schultz wrote:
>> Mark,
>>
>> On 8/27/14, 12:12 PM, Mark Thomas wrote:
>>> On 27/08/2014 17:05, schultz@apache.org wrote:
>>>> Author: schultz
>>>> Date: Wed Aug 27 16:05:38 2014
>>>> New Revision: 1620923
>>>>
>>>> URL: http://svn.apache.org/r1620923
>>>> Log:
>>>> Added missing hashCode method.
>>>
>>> Two questions.
>>>
>>> 1. Why do you think this method is missing? I'm pretty sure (although
>>> I'm going to need to install it to check) that FindBugs is now going
>>> complain about a missing equals(XMLString) method.
>>
>> You're right. I was looking at equals(String) and jumping to the wrong
>> conclusion. What is your preference, here? Remove hashCode() or add
>> equals(Object)?
> 
> We don't need a custom hashcode() or equals() so my vote is for removing
> the hashcode method (preference is always to delete code if practical).
> 
>>> 2. Why were length and offset (both part of XMLString's state) not
>>> included in the hashcode calculation?
>>
>> Whoops. Depending upon your response to the above, I'll either correct
>> it or remove the method.
> 
> See above.

Reverted x 2

-chris

>>>> Modified:
>>>>     tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java
>>>>
>>>> Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java
>>>> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java?rev=1620923&r1=1620922&r2=1620923&view=diff
>>>> ==============================================================================
>>>> --- tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java (original)
>>>> +++ tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java Wed Aug 27 16:05:38 2014
>>>> @@ -25,6 +25,8 @@
>>>>  
>>>>  package org.apache.jasper.xmlparser;
>>>>  
>>>> +import java.util.Arrays;
>>>> +
>>>>  /**
>>>>   * This class is used as a structure to pass text contained in the underlying
>>>>   * character buffer of the scanner. The offset and length fields allow the
>>>> @@ -138,6 +140,11 @@ public class XMLString {
>>>>      //
>>>>      // Object methods
>>>>      //
>>>> +    @Override
>>>> +    public int hashCode()
>>>> +    {
>>>> +        return Arrays.hashCode(ch);
>>>> +    }
>>>>  
>>>>      /** Returns a string representation of this object. */
>>>>      @Override
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


Re: svn commit: r1620923 - /tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java

Posted by Mark Thomas <ma...@apache.org>.
On 27/08/2014 18:00, Christopher Schultz wrote:
> Mark,
> 
> On 8/27/14, 12:12 PM, Mark Thomas wrote:
>> On 27/08/2014 17:05, schultz@apache.org wrote:
>>> Author: schultz
>>> Date: Wed Aug 27 16:05:38 2014
>>> New Revision: 1620923
>>>
>>> URL: http://svn.apache.org/r1620923
>>> Log:
>>> Added missing hashCode method.
>>
>> Two questions.
>>
>> 1. Why do you think this method is missing? I'm pretty sure (although
>> I'm going to need to install it to check) that FindBugs is now going
>> complain about a missing equals(XMLString) method.
> 
> You're right. I was looking at equals(String) and jumping to the wrong
> conclusion. What is your preference, here? Remove hashCode() or add
> equals(Object)?

We don't need a custom hashcode() or equals() so my vote is for removing
the hashcode method (preference is always to delete code if practical).

>> 2. Why were length and offset (both part of XMLString's state) not
>> included in the hashcode calculation?
> 
> Whoops. Depending upon your response to the above, I'll either correct
> it or remove the method.

See above.

Cheers,

Mark

> 
> Thanks,
> -chris
> 
>>> Modified:
>>>     tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java
>>>
>>> Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java
>>> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java?rev=1620923&r1=1620922&r2=1620923&view=diff
>>> ==============================================================================
>>> --- tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java (original)
>>> +++ tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java Wed Aug 27 16:05:38 2014
>>> @@ -25,6 +25,8 @@
>>>  
>>>  package org.apache.jasper.xmlparser;
>>>  
>>> +import java.util.Arrays;
>>> +
>>>  /**
>>>   * This class is used as a structure to pass text contained in the underlying
>>>   * character buffer of the scanner. The offset and length fields allow the
>>> @@ -138,6 +140,11 @@ public class XMLString {
>>>      //
>>>      // Object methods
>>>      //
>>> +    @Override
>>> +    public int hashCode()
>>> +    {
>>> +        return Arrays.hashCode(ch);
>>> +    }
>>>  
>>>      /** Returns a string representation of this object. */
>>>      @Override
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1620923 - /tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Mark,

On 8/27/14, 12:12 PM, Mark Thomas wrote:
> On 27/08/2014 17:05, schultz@apache.org wrote:
>> Author: schultz
>> Date: Wed Aug 27 16:05:38 2014
>> New Revision: 1620923
>>
>> URL: http://svn.apache.org/r1620923
>> Log:
>> Added missing hashCode method.
> 
> Two questions.
> 
> 1. Why do you think this method is missing? I'm pretty sure (although
> I'm going to need to install it to check) that FindBugs is now going
> complain about a missing equals(XMLString) method.

You're right. I was looking at equals(String) and jumping to the wrong
conclusion. What is your preference, here? Remove hashCode() or add
equals(Object)?

> 2. Why were length and offset (both part of XMLString's state) not
> included in the hashcode calculation?

Whoops. Depending upon your response to the above, I'll either correct
it or remove the method.

Thanks,
-chris

>> Modified:
>>     tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java
>>
>> Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java
>> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java?rev=1620923&r1=1620922&r2=1620923&view=diff
>> ==============================================================================
>> --- tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java (original)
>> +++ tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java Wed Aug 27 16:05:38 2014
>> @@ -25,6 +25,8 @@
>>  
>>  package org.apache.jasper.xmlparser;
>>  
>> +import java.util.Arrays;
>> +
>>  /**
>>   * This class is used as a structure to pass text contained in the underlying
>>   * character buffer of the scanner. The offset and length fields allow the
>> @@ -138,6 +140,11 @@ public class XMLString {
>>      //
>>      // Object methods
>>      //
>> +    @Override
>> +    public int hashCode()
>> +    {
>> +        return Arrays.hashCode(ch);
>> +    }
>>  
>>      /** Returns a string representation of this object. */
>>      @Override
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


Re: svn commit: r1620923 - /tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java

Posted by Mark Thomas <ma...@apache.org>.
On 27/08/2014 17:05, schultz@apache.org wrote:
> Author: schultz
> Date: Wed Aug 27 16:05:38 2014
> New Revision: 1620923
> 
> URL: http://svn.apache.org/r1620923
> Log:
> Added missing hashCode method.

Two questions.

1. Why do you think this method is missing? I'm pretty sure (although
I'm going to need to install it to check) that FindBugs is now going
complain about a missing equals(XMLString) method.

2. Why were length and offset (both part of XMLString's state) not
included in the hashcode calculation?

Mark


> 
> Modified:
>     tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java
> 
> Modified: tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java?rev=1620923&r1=1620922&r2=1620923&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java (original)
> +++ tomcat/trunk/java/org/apache/jasper/xmlparser/XMLString.java Wed Aug 27 16:05:38 2014
> @@ -25,6 +25,8 @@
>  
>  package org.apache.jasper.xmlparser;
>  
> +import java.util.Arrays;
> +
>  /**
>   * This class is used as a structure to pass text contained in the underlying
>   * character buffer of the scanner. The offset and length fields allow the
> @@ -138,6 +140,11 @@ public class XMLString {
>      //
>      // Object methods
>      //
> +    @Override
> +    public int hashCode()
> +    {
> +        return Arrays.hashCode(ch);
> +    }
>  
>      /** Returns a string representation of this object. */
>      @Override
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org