Nick Shanin created SOLR-18578:
----------------------------------
Summary: ObjectReleaseTracker.tryClose() skips AutoCloseable-only
objects in test-failure cleanup
Key: SOLR-18578
URL: https://issues.apache.org/jira/browse/SOLR-18578
Project: Solr
Issue Type: Bug
Reporter: Nick Shanin
🤖 _AI text below_ 🤖 _(posted on behalf of Nick Shanin)_
{{ObjectReleaseTracker.tryClose()}}
({{solr/solrj/src/java/org/apache/solr/common/util/ObjectReleaseTracker.java}})
is the best-effort cleanup the test framework runs after a test class fails;
{{SolrTestCase}} calls it from its {{afterAlways}} path when test errors have
occurred. It closes tracked {{Closeable}} objects and shuts down tracked
{{ExecutorService}} objects, but it silently skips a tracked object that
implements only {{AutoCloseable}}.
Three tracked types are AutoCloseable-only:
* {{SolrMetricsContext}}
({{solr/core/src/java/org/apache/solr/metrics/SolrMetricsContext.java}}), which
tracks itself and whose {{close()}} releases its tracker entry and closes its
registered resources.
* {{ZkCollectionTerms}}
({{solr/core/src/java/org/apache/solr/cloud/ZkCollectionTerms.java}}), whose
{{close()}} closes every contained {{ZkShardTerms}}.
* {{ZkShardTerms}}
({{solr/core/src/java/org/apache/solr/cloud/ZkShardTerms.java}}), whose
{{close()}} marks it closed, clears listeners, and releases its tracker entry.
A leaked metrics context therefore survives the failure-cleanup pass with its
registered resources still open, which can surface as leak noise after the
failure that caused it.
[SOLR-17857|https://issues.apache.org/jira/browse/SOLR-17857] added the tracker
registration for {{SolrMetricsContext}}; the {{Closeable}}-and-executor-only
shape of {{tryClose()}} dates to SOLR-15550 and was not widened then.
The fix is narrow: add an {{AutoCloseable}} branch after the existing branches,
preserving the {{ExecutorService}} special case, and add regression tests to
{{TestObjectReleaseTracker}}. Tracked-type close safety was checked
individually, including the nested {{ZkCollectionTerms}} and {{ZkShardTerms}}
pair. Normal production shutdown is not touched. A pull request with the fix
and the tests is ready to open against this ticket.
_AI-generated description. Nick Shanin directed the work and takes
responsibility for this contribution._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]