-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RedisLockRegistry setExecutor nullPointerException #8869
Comments
Confirmed. Please, consider to contribute the fix: https://github.com/spring-projects/spring-integration/blob/main/CONTRIBUTING.adoc Thanks |
@artembilan , I will create a pull request with the change, however I still think there's value in keeping the calls in setExecutor just in case someone calls the Do you agree? |
Well, I prefer to stay away from such a pattern where we try to mutate the configuration when the component has already started. WDYT? |
I agree with you, and I do not have a use case when you would want to change the executor on an already running instance, however would you agree with me that we should throw an IllegalStateException if the redisMessageListenerContainer is not null just in case someone tries to set the Executor outside the configuration state. Basically, I would rather fail the process than having an inconsistent behaviour. |
Well, that might makes sense, but then we would need to have such a guard everywhere in the project since any setter may suffer from same consequences. It is really a bad practice to try to mutate components state at runtime. An |
I see your point. I'll create a Pull request with an initialisation test to make sure that executors can be set up and remove the said lines from the setter method as you recommended. Thanks. |
In what version(s) of Spring Integration are you seeing this issue?
spring-integration-redis:6.2.1
Describe the bug
By looking at the RedisLockRegistry (https://github.com/spring-projects/spring-integration/blob/main/spring-integration-redis/src/main/java/org/springframework/integration/redis/util/RedisLockRegistry.java), the setExecutor method attempts to set the
this.redisMessageListenerContainer.setTaskExecutor(this.executor);
this.redisMessageListenerContainer.setSubscriptionExecutor(this.executor);
Since redisMessgeListenerContainer is lazy initialised, it's likely that the setExecutor method will fail since it does not have any null checking for this.redisMessageListenerContainer.
To Reproduce
If you run the below code snippet the execution will fail due to a NullPointerException (
Expected behavior
I would expect that setting the executor will have a null check for redisMessageListenerContainer as shown in the code below: -
Sample
The text was updated successfully, but these errors were encountered: