[Bug 63676] New: fixes:poi-ooxml-4.1.0:OPC:The equals (Object obj) method errors in the class org.apache.poi.openxml4j.opc.internal.ContentType and Potential bugs in method equals () and hashCode() of the class org.apache.poi.openxml4j.opc.PackageRelationship

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Bug 63676] New: fixes:poi-ooxml-4.1.0:OPC:The equals (Object obj) method errors in the class org.apache.poi.openxml4j.opc.internal.ContentType and Potential bugs in method equals () and hashCode() of the class org.apache.poi.openxml4j.opc.PackageRelationship

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63676

            Bug ID: 63676
           Summary: fixes:poi-ooxml-4.1.0:OPC:The equals (Object obj)
                    method errors in the class
                    org.apache.poi.openxml4j.opc.internal.ContentType and
                    Potential bugs in method equals () and hashCode() of
                    the class
                    org.apache.poi.openxml4j.opc.PackageRelationship
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: OPC
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: ---

Here are my modifications´╝Ü
in the class org.apache.poi.openxml4j.opc.internal.ContentType:
@Override
public boolean equals(Object obj) {

        return (obj instanceof ContentType)
&&(this.toString().equalsIgnoreCase(obj.toString()));

}
-----------------------------------------
Potential bugs in method equals () and hashCode() of the class
org.apache.poi.openxml4j.opc.PackageRelationship.I don't know if the following
changes are appropriate:
in the class PackageRelationship:
    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof PackageRelationship)) {
            return false;
        }
        PackageRelationship rel = (PackageRelationship) obj;
        return this.relationshipType.equals(rel.relationshipType)
                && (rel.source !=
null?rel.source.equals(this.source):this.source == null )
                && this.targetMode == rel.targetMode
                && this.targetUri.equals(rel.targetUri);
    }

    @Override
    public int hashCode() {
        return this.relationshipType.hashCode()
                + (this.source == null ? 0 : this.source.hashCode())
                + this.targetMode.hashCode()
                + this.targetUri.hashCode();
    }

and I removed id compared in method equals () and hashCode().I don't think that
if there are duplicate relationship types in the *.rels file, ID should not be
compared.In addition, add equals() and hashCode() methods to the class
org.apache.poi.openxml4j.opc.PackagePart.

@Override
    public int hashCode() {
        return partName.hashCode() + contentType.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return obj instanceof PackagePart
               &&this.partName.equals(((PackagePart) obj).partName)
               &&this.contentType.equals(((PackagePart) obj).contentType);
    }

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]