Created
November 15, 2017 00:10
-
-
Save QIvan/fe49541547e1e31a971492cb247b58ff to your computer and use it in GitHub Desktop.
Potential bug of Hazelcast,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.revolut.interview; | |
import com.hazelcast.config.Config; | |
import com.hazelcast.core.Hazelcast; | |
import com.hazelcast.core.HazelcastInstance; | |
import com.hazelcast.internal.serialization.impl.ClassDefinitionImpl; | |
import lombok.Data; | |
import lombok.EqualsAndHashCode; | |
import lombok.ToString; | |
import java.io.Serializable; | |
import java.math.BigDecimal; | |
import java.util.Map; | |
import java.util.Queue; | |
import java.util.concurrent.ConcurrentHashMap; | |
/** | |
* TODO | |
* | |
* @author Ivan Zemlyanskiy | |
*/ | |
public class Starter { | |
public static final String ACCOUNTS = "accounts"; | |
public static void main(String[] args) { | |
// Config cfg = new Config(); | |
// HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg); | |
// Map<Long, Account> mapCustomers = instance.getMap(ACCOUNTS); | |
Map<Long, Account> mapCustomers = new ConcurrentHashMap<>(); | |
System.out.println("init"); | |
mapCustomers.put(1L, new Account(1L, "my")); | |
System.out.println("compute"); | |
mapCustomers.computeIfPresent(1L, (id, account) -> { | |
account.setValue(BigDecimal.TEN); | |
return account; | |
}); | |
System.out.println("done"); | |
mapCustomers.values().forEach(System.out::println); | |
} | |
@Data | |
@EqualsAndHashCode | |
@ToString | |
public static class Account implements Serializable { | |
private final long id; | |
private final String name; | |
private BigDecimal value = BigDecimal.ZERO; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This output is
If uncomment 27-29 lines in main method and comment 30 it will be infinity loop with output