You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (JIRA)" <ji...@apache.org> on 2009/02/01 16:35:59 UTC

[jira] Resolved: (PDFBOX-409) Small hashcode issue, The code invokes hashCode on an array.

     [ https://issues.apache.org/jira/browse/PDFBOX-409?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler resolved PDFBOX-409.
---------------------------------------

       Resolution: Fixed
    Fix Version/s: 0.8.0-incubator

Peters suggestion won't do it, because it is a java1.5-feature. But I guess getString().hashCode will do it.

Thanks Peter

> Small hashcode issue, The code invokes hashCode on an array.
> ------------------------------------------------------------
>
>                 Key: PDFBOX-409
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-409
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 0.8.0-incubator
>         Environment: All
>            Reporter: Peter_Lenahan@ibi.com
>            Priority: Minor
>             Fix For: 0.8.0-incubator
>
>
> This problem is reported by the Findbugs tool.
> package org.apache.pdfbox.cos;
> public class COSString extends COSBase
>   public int hashCode()
>     {
>         return getBytes().hashCode();
>     }
> Invocation of hashCode on an array 
> The code invokes hashCode on an array. Calling hashCode on an array returns the same value as System.identityHashCode, and ignores the contents and length of the array. If you need a hashCode that depends on the contents of an array a, use java.util.Arrays.hashCode(a). 
> This might be a better solution.
> public int hashCode()
>     {
>         return java.util.Arrays.hashCode (getBytes());
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.