krickert commented on code in PR #1003:
URL: https://github.com/apache/opennlp/pull/1003#discussion_r3059086776


##########
opennlp-core/opennlp-ml/opennlp-ml-commons/src/main/java/opennlp/tools/ml/BeamSearch.java:
##########
@@ -34,23 +35,43 @@
  * <p>
  * This is based on the description in Ratnaparkhi (1998),
  * PhD diss, Univ. of Pennsylvania.
+ * <p>
+ * This implementation is thread-safe. The contexts cache and probability 
buffer
+ * are maintained per-thread via {@link ThreadLocal}.
+ * <p>
+ * <b>Note:</b> In container environments with classloader isolation (e.g. 
Jakarta EE),
+ * {@link ThreadLocal} state may pin the classloader. Ensure instances do not 
outlive
+ * the application's lifecycle, or call {@link ThreadLocal#remove()} on pooled 
threads.
  *
  * @see Sequence
  * @see SequenceValidator
  * @see BeamSearchContextGenerator
  */
+@ThreadSafe
 public class BeamSearch implements SequenceClassificationModel {

Review Comment:
   Yep — `BeamSearch` now implements `AutoCloseable` and `close()` calls 
`threadState.remove()` so long-lived pools can drop the per-thread state 
explicitly. That landed in 
https://github.com/ai-pipestream/opennlp/commit/90123d6 alongside the Javadoc 
tweaks on the cache path.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to