gnodet commented on PR #704:
URL: https://github.com/apache/creadur-rat/pull/704#issuecomment-5101046391

   @Claudenw Done — I've addressed the SPDXMatcherFactory thread-safety issue. 
Here's what changed:
   
   **`SPDXMatcherFactory`:**
   - `MATCHER_MAP` moved from `static` to instance field (`matcherMap`) — each 
factory now has its own matcher registry, so `Match` instances created by one 
factory correctly reference that factory's `lastMatch`/`checked` state via 
`SPDXMatcherFactory.this`
   - Constructor changed from `private` to package-private, added 
`newInstance()` factory method
   - `INSTANCE` kept as-is for backward compatibility (single-threaded use and 
existing tests like `SPDXMatcherTest`)
   
   **`SpdxBuilder`:**
   - Added `ThreadLocal<SPDXMatcherFactory> FACTORY` — each Maven reactor 
thread now gets its own factory instance
   - `build()` uses `FACTORY.get().create(name)` instead of 
`SPDXMatcherFactory.INSTANCE.create(name)`
   - Added `removeFactory()` cleanup method
   
   This prevents the scenario you described: two threads scanning different 
files no longer share `lastMatch`, so they won't report each other's SPDX IDs.
   
   All existing tests pass (including `SPDXMatcherTest` and `SpdxBuilderTest`), 
full `mvn clean install` BUILD SUCCESS.


-- 
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