JorrenH commented on code in PR #2939:
URL: https://github.com/apache/tomee/pull/2939#discussion_r3966641366
##########
container/openejb-core/src/main/java/org/apache/openejb/core/ThreadContext.java:
##########
@@ -237,9 +239,15 @@ public String toString() {
}
private String dataToString(final Map<Class, Object> data) {
- return data.entrySet().stream()
+ // copy data under monitor (synchronized map), format outside lock
+ return synchronizedCopy(data).entrySet().stream()
.map(entry -> entry.getKey() + "=" + (entry.getValue() == null
? "null" : entry.getValue().hashCode()))
.collect(Collectors.joining(", "));
+ }
Review Comment:
It was suggested on the mailing list, since arbitrary user code can run
inside `.hashCode()`. Difficult for me to assess the trade-off on this.
> To keep the critical section short and avoid calling
entry.getValue().hashCode() (arbitrary application code) while ho-lding a
monitor that sits on the EJB invocation hot path, better to copy under the lock
and format outside it.
--
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]