camunda-community-hub / camunda-platform-7-reactor

Event Driven process applications
https://camunda.github.io/camunda-bpm-reactor/
Apache License 2.0
80 stars 34 forks source link

UriPathTemplate from camunda-bpm-reactor/extension/eventbus is not thread safe #86

Closed tobiasbehr closed 5 years ago

tobiasbehr commented 5 years ago

org.camunda.bpm.extension.reactor.projectreactor.selector.UriPathTemplate#matcher caches matchers for a uriPattern. However, java.util.regex.Matcher is not thread safe as it has an internal state that is changed during java.util.regex.Matcher#matches.

Under heavy load that caused a loss of events in our environment.

I don't see the need to cache the Matcher. The expensive operation when creating a new Matcher is the compilation of the java.util.regex.Pattern. This is only done once per pattern anyway which is ensured here: java.util.regex.Pattern#matcher.