essobedo commented on PR #9332:
URL: https://github.com/apache/camel/pull/9332#issuecomment-1426831598

   > I have changed the synchronized block to lock. Now the evaluate method 
tries to get the ReadLock that does not block the thread for multiple ReadLock. 
The `init` method is using the WriteLock, thus the `evaluate` method is blocked 
only in case of a WriteLock on `init` method. It avoids the `evaluate` method 
to be blocked unnecessarily.
   > 
   
   It if needs to be fixed, it is not the right way to fix it, you don't even 
need locks here. If you really want to fix it, you will have to rewrite the 
code of the `concatExpression`, to have 2 classes instead of one (for constants 
only and not only constants). The problem is with the case of the not only 
constants, for it, you simply need to set the content of `col` once for all 
while initializing the instance instead of doing it in the init method. 
Moreover, you would need to add a unit test to prove that the bug is really 
fixed, [see TDD](https://en.wikipedia.org/wiki/Test-driven_development).
   
   > I think we should develop this method as thread-safe, as it is cached and 
can be used in a multithreaded task (like parallel or some internal multithread 
task). Thus, to avoid an issue now or in future, I think it should be immutable 
or thread-safe
   
   This decision doesn't really belong to us, especially if we disagree, I 
guess that someone like @davsclaus or @oscerd could eventually decide. But, 
here, according to your stack trace, if we get this problem it is because the 
expressions are misused such that the threads spend their time to re-initialize 
the same expression over and over again instead of only once at startup as the 
framework does, I don't believe that for a production-ready code, we would 
really want this behavior, so it tends to prove that it is more a misuse than a 
bug but it is only my point of view, let's see what others think.
   
   


-- 
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: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to