Hi, I think, so it doesn't always lead to exception, but you need to do it for prevent issues of serialization. Is static EntryProcessor allow to avoid NPE exception in your case?
On Thu, Aug 25, 2016 at 3:56 AM, 胡永亮/Bob <[email protected]> wrote: > hi Alexey, > This is example from official website. No static EntryProcessor. > > 1. IgniteCache<String, Integer> cache = ignite.jcache("mycache"); > 2. > 3. // Increment cache value 10 times. > 4. for (int i = 0; i < 10; i++) > 5. cache.invoke("mykey", new EntryProcessor<String, Integer, Void>() { > 6. @Override > 7. public Object process(MutableEntry<Integer, String> entry, > Object... args) { > 8. Integer val = entry.getValue(); > 9. > 10. entry.setValue(val == null ? 1 : val + 1); > 11. > 12. return null; > 13. } > 14. }); > > > ------------------------------ > 胡永亮 > > > > *From:* Alexey Goncharuk <[email protected]> > *Date:* 2016-08-25 02:10 > *To:* [email protected] > *Subject:* Re: null exception about EntryProcessor > Hi, > > You need to make your EntryProcessor a static class, otherwise it captures > a reference to your enclosing class which causes the serialization > exception. > > 2016-08-24 17:54 GMT+03:00 Vladislav Pyatkov <[email protected]>: > >> Hello, >> >> Could you please provide reproduced example? >> >> On Wed, Aug 24, 2016 at 11:04 AM, 胡永亮/Bob <[email protected]> wrote: >> >>> hi, everyone: >>> >>> When I use EntryProcessor to update value in remote node, the >>> statement entry.getValue() throwed null exception. The log detail is in >>> the attachement file log.txt. >>> I don't know why. >>> >>> I first do a check with the statement cache.containsKey(key), if it >>> is true, then do the EntryProcessor. Why null exception happened? >>> >>> if (cache.containsKey(key)) { >>> // Map<String, maplink> map = cache.get(key); >>> // map.put(mapLink.seclinkID.linkID + "_" >>> + mapLink.seclinkID.dir, mapLink); >>> // cache.put(key, map); >>> line 122 cache.invoke(key, new EntryPr >>> ocessor<MapMeshLinkKey,Map<String,maplink>, Void>() { >>> @Override >>> public Void process(MutableEntry<Map >>> MeshLinkKey,Map<String,maplink>> entry, Object... args) { >>> line 125 Map<String,maplink> map = ent >>> ry.getValue(); >>> map.put(mapLink.seclinkID.linkID >>> + "_" + mapLink.seclinkID.dir, mapLink); >>> entry.setValue(map); >>> return null; >>> } >>> }); >>> ENTRY_COUNT++; >>> } >>> >>> Can anyone help me, or meet this problem? Thanks your reply. >>> >>> ------------------------------ >>> 胡永亮 >>> >>> >>> >>> ------------------------------------------------------------ >>> --------------------------------------- >>> Confidentiality Notice: The information contained in this e-mail and any >>> accompanying attachment(s) >>> is intended only for the use of the intended recipient and may be >>> confidential and/or privileged of >>> Neusoft Corporation, its subsidiaries and/or its affiliates. If any >>> reader of this communication is >>> not the intended recipient, unauthorized use, forwarding, printing, >>> storing, disclosure or copying >>> is strictly prohibited, and may be unlawful.If you have received this >>> communication in error,please >>> immediately notify the sender by return e-mail, and delete the original >>> message and all copies from >>> your system. Thank you. >>> ------------------------------------------------------------ >>> --------------------------------------- >>> >> >> >> >> -- >> Vladislav Pyatkov >> > > > ------------------------------------------------------------ > --------------------------------------- > Confidentiality Notice: The information contained in this e-mail and any > accompanying attachment(s) > is intended only for the use of the intended recipient and may be > confidential and/or privileged of > Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader > of this communication is > not the intended recipient, unauthorized use, forwarding, printing, > storing, disclosure or copying > is strictly prohibited, and may be unlawful.If you have received this > communication in error,please > immediately notify the sender by return e-mail, and delete the original > message and all copies from > your system. Thank you. > ------------------------------------------------------------ > --------------------------------------- > -- Vladislav Pyatkov
