{"action":"created","issue":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/8149","repository_url":"https://api.github.com/repos/hazelcast/hazelcast","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/8149/labels{/name}","comments_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/8149/comments","events_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/8149/events","html_url":"https://github.com/hazelcast/hazelcast/issues/8149","id":154275625,"number":8149,"title":"IAtomicReference#alter does not persist changes","user":{"login":"KIC","id":10957396,"avatar_url":"https://avatars.githubusercontent.com/u/10957396?v=3","gravatar_id":"","url":"https://api.github.com/users/KIC","html_url":"https://github.com/KIC","followers_url":"https://api.github.com/users/KIC/followers","following_url":"https://api.github.com/users/KIC/following{/other_user}","gists_url":"https://api.github.com/users/KIC/gists{/gist_id}","starred_url":"https://api.github.com/users/KIC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KIC/subscriptions","organizations_url":"https://api.github.com/users/KIC/orgs","repos_url":"https://api.github.com/users/KIC/repos","events_url":"https://api.github.com/users/KIC/events{/privacy}","received_events_url":"https://api.github.com/users/KIC/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Team:%20Core","name":"Team: Core","color":"109def"},{"url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Type:%20Defect","name":"Type: Defect","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/hazelcast/hazelcast/milestones/70","html_url":"https://github.com/hazelcast/hazelcast/milestones/3.7","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/milestones/70/labels","id":1346433,"number":70,"title":"3.7","description":"","creator":{"login":"pveentjer","id":105243,"avatar_url":"https://avatars.githubusercontent.com/u/105243?v=3","gravatar_id":"","url":"https://api.github.com/users/pveentjer","html_url":"https://github.com/pveentjer","followers_url":"https://api.github.com/users/pveentjer/followers","following_url":"https://api.github.com/users/pveentjer/following{/other_user}","gists_url":"https://api.github.com/users/pveentjer/gists{/gist_id}","starred_url":"https://api.github.com/users/pveentjer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pveentjer/subscriptions","organizations_url":"https://api.github.com/users/pveentjer/orgs","repos_url":"https://api.github.com/users/pveentjer/repos","events_url":"https://api.github.com/users/pveentjer/events{/privacy}","received_events_url":"https://api.github.com/users/pveentjer/received_events","type":"User","site_admin":false},"open_issues":184,"closed_issues":497,"state":"open","created_at":"2015-10-09T12:16:13Z","updated_at":"2016-05-11T18:29:31Z","due_on":"2016-06-19T21:00:00Z","closed_at":null},"comments":4,"created_at":"2016-05-11T15:41:18Z","updated_at":"2016-05-11T18:35:21Z","closed_at":null,"body":"For some reason when I just want to alter an AtomicReference<MyObject> like so:\r\n\r\n```\r\n  ref.alter(node -> {\r\n            node.nextNodes[0] = lala;\r\n            node.nextKeys[0] = \"lala\";\r\n            return node;\r\n        });\r\n```\r\n\r\nthen nothing changes. A later get will still return the old object. But when i change this to alterAndGet\r\n\r\n```\r\n  ref.alterAndGet(node -> {\r\n            node.nextNodes[0] = lala;\r\n            node.nextKeys[0] = \"lala\";\r\n            return node;\r\n        });\r\n```\r\n\r\nthen everything works as expected. But in fact I do not want so send the whole object over wire, I just want to modify a property.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/comments/218549712","html_url":"https://github.com/hazelcast/hazelcast/issues/8149#issuecomment-218549712","issue_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/8149","id":218549712,"user":{"login":"KIC","id":10957396,"avatar_url":"https://avatars.githubusercontent.com/u/10957396?v=3","gravatar_id":"","url":"https://api.github.com/users/KIC","html_url":"https://github.com/KIC","followers_url":"https://api.github.com/users/KIC/followers","following_url":"https://api.github.com/users/KIC/following{/other_user}","gists_url":"https://api.github.com/users/KIC/gists{/gist_id}","starred_url":"https://api.github.com/users/KIC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KIC/subscriptions","organizations_url":"https://api.github.com/users/KIC/orgs","repos_url":"https://api.github.com/users/KIC/repos","events_url":"https://api.github.com/users/KIC/events{/privacy}","received_events_url":"https://api.github.com/users/KIC/received_events","type":"User","site_admin":false},"created_at":"2016-05-11T18:35:21Z","updated_at":"2016-05-11T18:35:21Z","body":"Sure:\r\n\r\n```\r\npackage com.mindbusters.range.cache.column.stuff.hazelcast;\r\n\r\nimport com.hazelcast.core.Hazelcast;\r\nimport com.hazelcast.core.HazelcastInstance;\r\nimport com.hazelcast.core.IAtomicReference;\r\n\r\nimport java.io.Serializable;\r\nimport java.util.Arrays;\r\n\r\n/**\r\n * Created by kic on 11.05.16.\r\n */\r\npublic class Issue {\r\n    public static class MyClass implements Serializable {\r\n        private static final long serialVersionUID = -3394196400279204634L;\r\n        public String[] someArray;\r\n\r\n        public MyClass() {\r\n            this.someArray = new String[10];\r\n        }\r\n\r\n        @Override\r\n        public String toString() {\r\n            return Arrays.toString(someArray);\r\n        }\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n        HazelcastInstance hi = Hazelcast.newHazelcastInstance();\r\n        IAtomicReference<MyClass> foo = hi.getAtomicReference(\"foo\");\r\n\r\n        foo.set(new MyClass());\r\n\r\n        foo.alter(mc -> {\r\n            mc.someArray[0] = \"hello\";\r\n            return mc;\r\n        });\r\n\r\n        System.out.println(foo.get()); // prints [null, null, null, null, null, null, null, null, null, null]\r\n\r\n        foo.alterAndGet(mc -> {\r\n            mc.someArray[0] = \"hello\";\r\n            return mc;\r\n        });\r\n\r\n        System.out.println(foo.get()); // prints [hello, null, null, null, null, null, null, null, null, null]\r\n\r\n    }\r\n}\r\n```\r\n"}}