Bug 68229 - removeRelationship(String)@PackageRelationshipCollection can have an error on sorted list
Summary: removeRelationship(String)@PackageRelationshipCollection can have an error on...
Status: NEEDINFO
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 5.3.x-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-27 01:59 UTC by zhonghao
Modified: 2023-11-29 07:13 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zhonghao 2023-11-27 01:59:49 UTC
I noticed that NPOI fixed a bug:

https://github.com/nissl-lab/npoi/commit/4e85b803eb29b1de2a85813e1d43baac32daaa81

The buggy code is as follows:

public void RemoveRelationship(String id)
{
  ...
  internalRelationshipsByTargetName.Values.Remove(rel);
...}

The fixed code is as follows:

public void RemoveRelationship(String id)
{
  ...
  internalRelationshipsByTargetName.RemoveAt(internalRelationshipsByTargetName.IndexOfValue(rel));
...}

NPOI programmers fixed a sortedlist remove error. POI still uses the buggy way:

 public void removeRelationship(String id) {
        PackageRelationship rel = relationshipsByID.get(id);
        if (rel != null) {
            relationshipsByID.remove(rel.getId());
            internalRelationshipsByTargetName.values().remove(rel);
        }
    }

It can have the identical error.
Comment 1 PJ Fanning 2023-11-27 10:31:02 UTC
We are not going to just copy NPOI. Please provide real world examples. POI is a volunteer project and it is normally best to provide a patch with a test case yourself.
Comment 2 zhonghao 2023-11-29 07:13:34 UTC
NPOI is ported from POI. They have many similar source files,so they can have some shared bugs. For example, POI has fixed the following bug:

https://github.com/apache/poi/commit/9484ef6f17137eca19415628e4151718f88a84c2#diff-677195010c4c8c081b91e2f54573f93c59edb6eda72a339d18904eb8e6ba95f2

However, this bug is not fixed in NPOI. I have reported it to NPOI programmers:

https://github.com/nissl-lab/npoi/issues/1219

In my bug report, the commit (https://github.com/nissl-lab/npoi/commit/4e85b803eb29b1de2a85813e1d43baac32daaa81) does not provide the details such as test cases or bug reports. 

I will try to provide test cases and patches, but the process can be slow since I have to report my found bugs to other projects.