commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luc Maisonobe (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (MATH-1117) twod.PolygonsSet.getSize produces NullPointerException if BSPTree has no nodes
Date Sat, 26 Apr 2014 16:57:15 GMT

     [ https://issues.apache.org/jira/browse/MATH-1117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Luc Maisonobe resolved MATH-1117.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 3.3

The two problems you report are completely different from each other.

The first report is really a wrong API use. The call did not fulfill the constraints that
were already given in
the javadoc, i.e. that the provided tree MUST have proper Boolean attributes at leaf nodes.
There is no
verification here for performance reasons (it would imply walking the full trees all the time).
I really don't
think it would be a good idea to do such verifications. So I only improved the javadoc of
the constructor
to make it more clear this constructor is for expert use only (building a tree is difficult)
and that there is
no verifications, adding in the documentation that failing to provide appropriate arguments
is the
responsibility of users.

In fact, general users should never use this specific constructor, but should rely on the
other ones which
are there precisely to avoid this kind of errors : the other constructors ensure the tree
is correct before
calling this constructor.

The second one is a real problem, I have fixed it (see r1590251).

Please reopen the issue if you do not agree with the fix for the first problem, as it is documentation
only.

> twod.PolygonsSet.getSize produces NullPointerException if BSPTree has no nodes
> ------------------------------------------------------------------------------
>
>                 Key: MATH-1117
>                 URL: https://issues.apache.org/jira/browse/MATH-1117
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.2
>         Environment: Mac OS 10.9, Java 6, 7
>            Reporter: Cyrille Artho
>             Fix For: 3.3
>
>         Attachments: Report3.java, Report3_1.java
>
>
> org.apache.commons.math3.geometry.euclidean.twod.PolygonsSet.getSize() uses a tree internally:
> final BSPTree<Euclidean2D> tree = getTree(false);
> However, if that tree contains no data, it seems that the reference returned is null,
which causes a subsequent NullPointerException.
> Probably an exception with a message ("tree has no data") would clarify that this is
an API usage error.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message