Aias00 opened a new issue, #6775: URL: https://github.com/apache/shenyu/issues/6775
- Severity: Medium - Location: `shenyu-spi/src/main/java/org/apache/shenyu/spi/ExtensionLoader.java:174-194,55,331-369` - Description: `getJoins()` takes a fast path when `extensionClassesEntity.size() == cachedInstances.size()`, returning `cachedInstances.values().stream().sorted(HOLDER_COMPARATOR).map(e -> e.getValue())`. A `Holder` is inserted via `putIfAbsent` (line 153) *before* its `value`/`order` is populated inside the `synchronized(objectHolder)` block in `createExtension`. If thread A has just done `putIfAbsent` for the last name (so size reaches N) but not yet `setValue`/`setOrder`, a concurrent thread B calling `getJoins()` sees the size match, takes the fast path, reads `getValue()==null`/`getOrder()==null`. `HOLDER_COMPARATOR = Comparator.comparing(Holder::getOrder)` then throws `NullPointerException` (null `Integer` key); absent that, the returned list contains a `null` element. - Impact: Concurrent `getJoins()` (dynamic plugin/route loading) can throw NPE or return a list with `null`, causing NPE at the call site. - Suggested fix: Populate `value`/`order` before inserting the Holder, or gate the fast path on a `volatile boolean allInitialized` set after the slow path completes; or use `ConcurrentHashMap.compute` so a Holder is never observable half-built. - Confidence: Medium --- _Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._ -- 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]
