coheigea commented on code in PR #3788:
URL: https://github.com/apache/cxf/pull/3788#discussion_r4708386293


##########
core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java:
##########
@@ -183,7 +183,10 @@ public static XMLInputFactory getXMLInputFactory(Message 
m) {
 
                 try {
                     xif = 
(XMLInputFactory)(cls.getDeclaredConstructor().newInstance());
-                    factories.put(o, xif);
+                    XMLInputFactory existing = FACTORIES.putIfAbsent(o, xif);

Review Comment:
   Thanks, agreed. I’ve switched both interceptors to computeIfAbsent and kept 
the get() fast path in front of it. computeIfAbsent needs a Function rather 
than a Supplier, and the reflective exceptions are now caught inside the lambda 
and rethrown as Fault, so a failed construction isn’t cached. I’ve also added 
StaxFactoryCacheTest, which covers the class and class-name configuration, 
failures, and 16 threads hitting an empty cache at once (exactly one factory is 
constructed).



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