-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
BoundedLocalCache throws NPE on Shutdown if CacheLoader returns a null. #35
Comments
That's an excellent point and thanks for the test case + analysis. I think your fix is correct, except most likely the added check should be only around I'll review to make sure there are tests for all cases when the CacheLoader (or mapping function) returns null (e.g. refresh) and probably have a patch release out tomorrow or the day after. |
Perfect, thanks Ben. |
There's a test case for the scenario in a generalized fashion (so all configurations can be verified). It looks like I missed this because I disabled logging to avoid spamming the results as some tests assert the exceptional conditions. Since the internal data structures of the cache weren't corrupted (e.g. removal task had nothing to do) the validation aspect passes. So the issue is benign except for scary log messages. Since this is the executor failing but the logger swallowing the cases, I'll probably have to do something quirky like supply an executor that remembers if it failed. I think figuring out how to communicate this as a test failure (so other cases are caught) will be the tricky part of this bug fix. For example |
I was about to finish changing our current caching system over to Caffeine as I stumbled upon this also. It is also harmful if "cleanUp" is called explicitely on a Cache since then this (unchecked and undeclared) Exception is thrown from the cleanUp method, which will lead to problems. |
@seidler2547 I agree A problem is that
So I think its okay to say that a CacheWriter.delete() can propagate to the I think if we can agree that's okay, then testing isn't hindered. |
When an absent computation returns null, a add/removal task was being improperly scheduled. As there was no Node, this null field was then causing an NPE during the maintenance cycle. Usually that was on a background executor, but could be visible if `cleanUp` is called. This wasn't caught by tests since the executor's was swalled, logged, and logging was disabled to avoid spamming the report. Now the executor is instrumented so that the validation can assert no failures occurred. This detected the two bugs found with existing tests, so this provides more coverage than a one-off fix.
Okay, I'll release |
This is now released. It took a little while to work out some test issues. Should sync from staging to central within 2 hours. |
Looks good, thanks for the speedy response Ben! |
This:
Throws:
on shutdown. Is this desired behaviour or have I done something wrong above?
Should the check on BondedLocalCache line 1812:
maybe include removed[0] not being null? I.e.
The text was updated successfully, but these errors were encountered: