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

Cannot invoke "Object.equals(Object)" because the return value of "org.hipparchus.geometry.partitioning.BSPTree.getAttribute()" is null #314

Open
Sohnny0 opened this issue Mar 2, 2024 · 2 comments

Comments

@Sohnny0
Copy link

Sohnny0 commented Mar 2, 2024

I got a null pointer exception when I ran the code below. I guess it's a minor bug.

try {
intersection = (SphericalPolygonsSet) factory.intersection(zone.copySelf(), targetSphericalPolygonsSet.copySelf());
} catch (Exception e) {
e.printStackTrace();
}

java.lang.NullPointerException: Cannot invoke "Object.equals(Object)" because the return value of "org.hipparchus.geometry.partitioning.BSPTree.getAttribute()" is null
at org.hipparchus.geometry.partitioning.RegionFactory$VanishingToLeaf.fixNode(RegionFactory.java:381)
at org.hipparchus.geometry.partitioning.BSPTree.insertInTree(BSPTree.java:680)
at org.hipparchus.geometry.partitioning.RegionFactory$IntersectionMerger.merge(RegionFactory.java:267)
at org.hipparchus.geometry.partitioning.BSPTree.merge(BSPTree.java:437)
at org.hipparchus.geometry.partitioning.BSPTree.merge(BSPTree.java:455)

@maisonobe
Copy link
Contributor

Could you set up a standalone test case allowing to reproduce the issue?

@Sohnny0
Copy link
Author

Sohnny0 commented Mar 6, 2024

Could you set up a standalone test case allowing to reproduce the issue?

I have been busy recently, so I have solved it in this way for the time being. I will provide test cases later when I have time.

    public BSPTree<S> fixNode(final BSPTree<S> node) {
        Object attribute = node.getPlus().getAttribute();
        if (attribute != null && attribute.equals(node.getMinus().getAttribute())) {
            // no ambiguity
            return new BSPTree<S>(node.getPlus().getAttribute());
        } else {
            // ambiguous node
            return new BSPTree<S>(inside);
        }
    }

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

2 participants