janhoy commented on code in PR #4930:
URL: https://github.com/apache/solr/pull/4930#discussion_r4211677485
##########
solr/modules/extraction/src/java/org/apache/solr/handler/extraction/TikaServerExtractionBackend.java:
##########
@@ -447,13 +447,10 @@ private void
appendBackCompatTikaMetadata(ExtractionMetadata md) {
@Override
public void close() {
- RefCounted<HttpClientResources> ref;
- synchronized (INIT_LOCK) {
- ref = acquiredResourcesRef;
- acquiredResourcesRef = null;
- }
- if (ref != null) {
- ref.decref();
+ if (closed.compareAndSet(false, true)) {
+ synchronized (INIT_LOCK) {
+ acquiredResourcesRef.decref();
Review Comment:
Claude did this for me:
----
What I added to the existing Testcontainers test class
TikaServerExtractionBackendTest:
- testConcurrentCloseAndAcquireSharedResources: for at least 25 iterations,
a barrier releases two threads at once. One closes the sole remaining backend,
which stops the shared HttpClient. The other constructs a new backend. The new
backend must then complete a real extraction against the Tika container.
- testCloseIsIdempotent: closes one backend twice while a second is still
open, verifies the second still extracts, then verifies a third backend created
after everything is closed also works.
Verification
- All seven tests in the class ran against Docker and passed.
- I temporarily swapped in the pre-fix production source and ran the race
test with three seeds. It failed every time with "Unexpected error while
calling TikaServer", so it does catch the stopped-client handoff. The fix was
then restored.
- Module check -x test and tidy are clean.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]