Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.23.1
-
None
-
Unknown
Description
Currently DefaultHttpRegistry uses common HashSets for storing
HttpConsumers and CamelServlets. So when you are trying to register more
consumers in paralel it can lead to missing consumer in hashset due to its
nature. Another case is when you are registering consumers and servlets in
paralel. This case can lead to ConcurrentModificationException.
private final Set<HttpConsumer> consumers; private final Set<CamelServlet> providers; public DefaultHttpRegistry() { consumers = new HashSet<>(); providers = new HashSet<>(); } public void register(HttpConsumer consumer) { if (LOG.isDebugEnabled()) { LOG.debug("Registering consumer for path {} providers present: {}", consumer.getPath(), providers.size()); } consumers.add(consumer); for (CamelServlet provider : providers) { provider.connect(consumer); } } public void register(CamelServlet provider) { if (LOG.isDebugEnabled()) { LOG.debug("Registering CamelServlet with name {} consumers present: {}", provider.getServletName(), consumers.size()); } providers.add(provider); for (HttpConsumer consumer : consumers) { provider.connect(consumer); } }
I know there's possibility to use own http registry in camel route starting
with servlet. But you have to register it to servlet-component, then
implement custom servlet because inits DefaultHttpRegistry in it's init
method.
Attachments
Issue Links
- links to