From 57eff0d0c37ec003ebed48d3334c93cd9c038f64 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Wed, 1 Jan 2014 17:29:18 +0000 Subject: [PATCH] Avoid NullPointerException in some corner cases. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1554653 13f79535-47bb-0310-9956-ffa450edef68 --- .../math3/geometry/euclidean/oned/SubOrientedPoint.java | 5 +++++ .../math3/geometry/partitioning/AbstractRegion.java | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/SubOrientedPoint.java b/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/SubOrientedPoint.java index 22a554bd9..8d8f6c67c 100644 --- a/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/SubOrientedPoint.java +++ b/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/SubOrientedPoint.java @@ -45,6 +45,11 @@ public class SubOrientedPoint extends AbstractSubHyperplane buildNew(final Hyperplane hyperplane, diff --git a/src/main/java/org/apache/commons/math3/geometry/partitioning/AbstractRegion.java b/src/main/java/org/apache/commons/math3/geometry/partitioning/AbstractRegion.java index 63c631d7f..d384b419c 100644 --- a/src/main/java/org/apache/commons/math3/geometry/partitioning/AbstractRegion.java +++ b/src/main/java/org/apache/commons/math3/geometry/partitioning/AbstractRegion.java @@ -128,8 +128,11 @@ public abstract class AbstractRegion implement /** {@inheritDoc} */ public void visitLeafNode(final BSPTree node) { - node.setAttribute((node == node.getParent().getPlus()) ? - Boolean.FALSE : Boolean.TRUE); + if (node.getParent() == null || node == node.getParent().getMinus()) { + node.setAttribute(Boolean.TRUE); + } else { + node.setAttribute(Boolean.FALSE); + } } });