Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find Bugs Fixes #7

Open
tenaciousRas opened this issue Aug 17, 2012 · 0 comments
Open

Find Bugs Fixes #7

tenaciousRas opened this issue Aug 17, 2012 · 0 comments

Comments

@tenaciousRas
Copy link
Owner

This is from a find bugs report contributed by D. Borza:

  1. com.longevitysoft.android.xml.plist.domain.Data
    line 73:
    public java.lang.String getValue(boolean decode) {
    dataStringer.newBuilder();
    if (decode) {
    return dataStringer.getBuilder()
    .append(new java.lang.String(Base64.
    decodeFast(rawData)))
    .toString();
    } else {
    -> return dataStringer.getBuilder().append(rawData).toString();
    }
    }

The code invokes toString on an array, which will generate a fairly useless result such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable String that gives the contents of the array.

  1. class: com.longevitysoft.android.xml.plist.domain.Array
    line 252:
    public boolean equals(Object that) {
    -> return data.equals(that);
    }

This class overrides equals(Object), but does not override hashCode(), and inherits the implementation of hashCode() from java.lang.Object (which returns the identity hash code, an arbitrary value assigned to the object by the VM). Therefore, the class is very likely to violate the invariant that equal objects must have equal hashcodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant