-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
An infinity loop in the method java.util.concurrent.ConcurrentMap#computeIfPresent #11816
Comments
There is this behavior because in com.hazelcast.map.impl.operation.ReplaceIfSameOperation#run we try to replace with a new value and before check that no modifications was between to apply the lambda and an attempt to replace. But the lambda has modified reference already and this check always will be failed because in com.hazelcast.map.impl.recordstore.DefaultRecordStore#replace(com.hazelcast.nio.serialization.Data, java.lang.Object, java.lang.Object) we compare the value by a key in the local map with a record in a cluster and there value by the same key has not modified yet. |
I know that a Hazelcast's target is Java 6, but in Java 8 this is a bug. The method
|
Additionally, the test case for ConcurrentMap.computeIfPresent-like behavior is provided to ensure we are supporting it properly in its current restricted form. Closes: #11816
@QIvan Unfortunately, the issue can't be fixed at this moment. The root cause of the problem is that Hazelcast maps expect values to have value type semantics, while standard Java implementations expect reference type semantics. Hazelcast is still at Java 6, so we can't override I have enhanced You may workaround the issue by returning a new value instance from |
Fixed in 4.1. |
Hi! This code have an infinity loop
a output will be like this
But if we comment lines 1-3 and uncomment line 4 the output will be
as expected.
$ java -version openjdk version "1.8.0_111" OpenJDK Runtime Environment (build 1.8.0_111-b16) OpenJDK 64-Bit Server VM (build 25.111-b16, mixed mode)
8,9 - no available
The text was updated successfully, but these errors were encountered: