-
Notifications
You must be signed in to change notification settings - Fork 16
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
Instance without Command Handlers cannot be discovered #327
Comments
FixThanks for this detailed bug description, @kagof! You have definitely found a misser on our end here. Checking the implementation, I think we would also be saved by setting a fixed What's your thought on that? ReleaseAlthough small, I do think the fix would merit a release. Especially since the traffic on our extensions is low, such an issue with a workaround is still worthy of a new release I think. If I would release a fix in, let's say, 4.6.1 of the Spring Cloud Extension, we'd be required to release a 4.7.1, 4.8.1, and 4.9.1 too. So, if possible, I'd like your 2-cents on that. Thanks in advance! 🙏 |
Hey @smcvb , thanks for the speedy reply. Your proposed solution makes sense to me! I do understand not wanting to manage a backport of this fix all the way back to 4.6, I'm sure that's a lot of extra effort manage 4 versions instead of just 1. Since the workaround we mentioned above is quite simple (just calling |
Adjust test to not update the local capabilities, as this reflects the behavior when a node never updates its capabilities since it has not command handlers #327
Default the ServiceInstance to a fixed URI version i.o. null. Doing so, #327
Drop test prefix from tests, as that's the new style #327
Add descriptive JavaDoc to the NoopUriServiceInstance #327
Rename the nop service instance to FixedURIServiceInstance #327
…ommand-handlers [#327] Default local `ServiceInstance` to a fixed `URI` i.o. `null`
Thanks for the feedback, @kagof! Thanks again for bringing this to our attention!! |
Much appreciated, thanks for resolving this so quickly @smcvb 🚀 |
Basic information
Steps to reproduce
Have an application using the
SpringCloudCommandRouter
with theRestCapabilityDiscoveryMode
which sends commands, but does not have any command handlers.Expected behaviour
I'd expect this class to be able to send commands to other applications registered with the SpringCloudCommandRouter.
Actual behaviour
We get a "
No node known to accept command
" error when attempting to send any command from the application with no handlers.We see the following message in our logs:
for each instance the application finds through service discovery. This explains why it cannot send commands; the application has an exception when attempting to discover capabilities on any other application, and so records them as not having any capabilities.
Enabling debug logging allows us to see the stacktrace from the
RestCapabilityDiscoveryMode
:According to the stacktrace the error appears to be coming from this method:
Debugging through it confirms that
localInstance
is an emptyAtomicReference
, and so the NPE comes from calling.get().getUri()
on it.Extra info
It looks like the
RestCapabilityDiscoveryMode
expectsAbstractCapabilityDiscoveryMode#updateLocalCapabilities
to be called at least once, as it has the side effect of setting the reference for thelocalInstance
. But it seems that since thelocalCapabilities
are already correct by default if there are no command handlers on the local instance, that method never gets called and thus the side effect never occurs.This appears to be very similar to #1; maybe you could call it a regression, although that issue was for the old Metadata based approach, so that's maybe unfair.
Workarounds
Adding a class like this to the application:
causes the
updateLocalCapabilities
method to be called and gets rid of the NullPointerException thus allowing commands to be routed properly.A (slightly?) more graceful workaround we've found is to just call
in the method where we configure the
DistributedCommandBus
bean, which also forces theupdateLocalCapabilities
method to be called and allows command routing.The text was updated successfully, but these errors were encountered: