You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2019/08/20 15:38:29 UTC

[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

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: dev@poi.apache.org
          Reporter: dandinghe202@163.com
  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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63676] Adjust equals()/hashCode() in ContentType and PackageRelationship

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63676

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|fixes:poi-ooxml-4.1.0:OPC:T |Adjust equals()/hashCode()
                   |he equals (Object obj)      |in ContentType and
                   |method errors in the class  |PackageRelationship
                   |org.apache.poi.openxml4j.op |
                   |c.internal.ContentType and  |
                   |Potential bugs in method    |
                   |equals () and hashCode() of |
                   |the class                   |
                   |org.apache.poi.openxml4j.op |
                   |c.PackageRelationship       |
                 OS|                            |All

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org