[
https://issues.apache.org/jira/browse/MATH-1532?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gilles Sadowski resolved MATH-1532.
-----------------------------------
Resolution: Abandoned
> Lazy evaluation in AbstractRegion is not threadsafe
> ---------------------------------------------------
>
> Key: MATH-1532
> URL: https://issues.apache.org/jira/browse/MATH-1532
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 3.6.1
> Reporter: Baljit Singh
> Priority: Major
>
> In the documents for
> [AbstractRegion.html#getTree(boolean)|https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/partitioning/AbstractRegion.html#getTree(boolean)],
> it says the following:
> {quote}Since computing the boundary is not always required and can be
> time-consuming for large trees, these internal nodes attributes are computed
> using lazy evaluation only when required by setting the
> includeBoundaryAttributes argument to true.
> {quote}
> However, the lazy evaluation is not thread-safe. Calling other methods in
> multithreaded environment that perform {{getTree(true)}} leads to a race
> condition. Looking [at the
> code|https://github.com/apache/commons-math/blob/3.6.1-release/src/main/java/org/apache/commons/math3/geometry/partitioning/AbstractRegion.java#L354],
> it looks like when the first thread starts the initialization, and the root
> attributes are set to non-null. However, while the {{BoundaryBuilder}} is
> still updating the internal nodes, a call to {{getTree(true)}} from another
> thread returns the (partially initialized) tree, which leads to
> {{NullPointException}} since all the attributes are not (yet) set.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)