-
Notifications
You must be signed in to change notification settings - Fork 43
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
NotSerializableException in AsyncCacheAPI#getOrElseUpdate #140
Comments
Hi, I'm sorry to hear that. I'll look into it at weekend and investigate what's going on. Note: When there are 2 issues, please, open 2 tickets. These seem to be unrelated to each other. The second one is probably just a regression issue. |
I investigated your report and I couldn't reproduce either of the issues. First, you reported the loosing of the context. I checked the code base and there is still the patch as well as the test preventing the regression issue. Please, check them, if you see any issue in any of them, report it. Second, I tried the very simple scenario of the def index = Action {
val value = cache.getOrElseUpdate( "ABC", ( ) => {
println( "getting a string" )
"message"
}, 10 )
Ok( value )
} I tried even a custom object instead of the string and it still works. So, could you provide an example to reproduce the issue? Otherwise, I am unfortunately unable to do more. And finally just a side note. As you probably know, the error indicates that you are trying to serialize plain |
Ok, I have created an example on GitHub so you can see the issues that I have. https://github.com/tzimisce012/redis-test With this example you will see the error with the deserialization. Be fast with the retries on the request because I put 5 seconds of expiration time. |
Also I have added an example where the context is lost. |
Great example, I reproduced the serialization issue. Unfortunately, I don't know how to fix it right now. The issue lies in the Java erasure of runtime types and occurs only with Java version of ExplanationWhen you miss on cache, you compute the actual value and then serialize it, which works as it asks the value itself for its type. However, when you hit, it considers the In the previous version of Play, i.e., Play 2.5 and earlier, Play's API didn't support type parameter So, it seems the issue is not in play-redis but I have to investigate it more to see how to deal with it. |
I also reproduced the second issue and it partially relates to the first one. The support of the context is implemented only for Java handler, which is It explains why I couldn't reproduce the issues. Both these issues partially relates to the Scala implementation. First, there is given wrong classTag, second, it doesn't support Java context. Surprisingly, the solution is pretty simple. Sync api uses SolutionSo to sum it up, one issue is cause by Java type erasure in Play, the second one is the Scala implementation under the Java API. I change the implementation of I'll release the fix as 2.0.2 and will be added also in 2.1.0. Thanks for your contribution and the example to reproduce it. |
Thanks for your fast solution |
Released 2.0.2 |
is it published already? |
It takes usually several hours to sync |
Are you filing an issue? Please follow these checklists and provide us all the possible information to speed up the process.
Reporting a bug?
So I was working on play-redis 1.6.1 but as soon as I migrated to 2.0.1 I faced two different problems using the method
getOrElseUpdate
.When I use this method for the first time, they key is not found on redis, so the method does the update and store in redis before returning the value. The second time I ask for this key, I am getting the following error:
The second issue that I have is a problem that was solved on 1.6.1. Again, the java context is lost in
getOrElseUpdate
with the last version.The text was updated successfully, but these errors were encountered: