[jira] [Commented] (IGNITE-17603) onGet not triggered in Cache Interceptor
[ https://issues.apache.org/jira/browse/IGNITE-17603?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17598514#comment-17598514 ] Stephen Darlington commented on IGNITE-17603: - Also possibly related to IGNITE-1903 . > onGet not triggered in Cache Interceptor > > > Key: IGNITE-17603 > URL: https://issues.apache.org/jira/browse/IGNITE-17603 > Project: Ignite > Issue Type: Bug > Components: cache >Affects Versions: 2.9.1 > Environment: Mac, Java 11 >Reporter: Stephen Darlington >Priority: Major > > The onGet method in cache interceptors appears not to be called since version > 2.9.0. Or at least, the API changed. I have the following code: > CacheConfiguration cacheConfiguration = new > CacheConfiguration<>(); > cacheConfiguration.setName("PERSON_CACHE"); > cacheConfiguration.setAtomicityMode(CacheAtomicityMode.ATOMIC); > cacheConfiguration.setIndexedTypes(Long.class, Person.class); > cacheConfiguration.setInterceptor(new CacheInterceptor Object>() \{ > @Override > public Object onGet(Long aLong, Object p) { > Person person = (Person)p; > return new Person(new > StringBuilder(person.getName()).reverse().toString(), person.getHeight()); > } > @Override > public Object onBeforePut(Cache.Entry entry, Object > p) \{ > if (p.getClass().equals(Person.class)) { > Person person = (Person)p; > return new Person(new > StringBuilder(person.getName()).reverse().toString(), person.getHeight()); > } > else if (p.getClass().equals(BinaryObjectImpl.class)) \{ > BinaryObjectBuilder person = ((BinaryObject) > p).toBuilder(); > String name = person.getField("name"); > person.setField("name", new > StringBuilder(name).reverse().toString()); > return person.build(); > } > else \{ > return null; > } > } > @Override > public void onAfterPut(Cache.Entry entry) \{ > // do nothing > } > @Override > public IgniteBiTuple > onBeforeRemove(Cache.Entry entry) \{ > return new IgniteBiTuple<>(true, entry.getValue()); > } > @Override > public void onAfterRemove(Cache.Entry entry) \{ > // do nothing > } > }); > It reverses the name before storing it and reverses it again on a get. In > 2.9.0 this works as expected. In every version since it fails. It reverses > the string on a put but the onGet method never gets called. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (IGNITE-17603) onGet not triggered in Cache Interceptor
[ https://issues.apache.org/jira/browse/IGNITE-17603?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17598513#comment-17598513 ] Stephen Darlington commented on IGNITE-17603: - Caused by / related to IGNITE-13417? > onGet not triggered in Cache Interceptor > > > Key: IGNITE-17603 > URL: https://issues.apache.org/jira/browse/IGNITE-17603 > Project: Ignite > Issue Type: Bug > Components: cache >Affects Versions: 2.9.1 > Environment: Mac, Java 11 >Reporter: Stephen Darlington >Priority: Major > > The onGet method in cache interceptors appears not to be called since version > 2.9.0. Or at least, the API changed. I have the following code: > CacheConfiguration cacheConfiguration = new > CacheConfiguration<>(); > cacheConfiguration.setName("PERSON_CACHE"); > cacheConfiguration.setAtomicityMode(CacheAtomicityMode.ATOMIC); > cacheConfiguration.setIndexedTypes(Long.class, Person.class); > cacheConfiguration.setInterceptor(new CacheInterceptor Object>() \{ > @Override > public Object onGet(Long aLong, Object p) { > Person person = (Person)p; > return new Person(new > StringBuilder(person.getName()).reverse().toString(), person.getHeight()); > } > @Override > public Object onBeforePut(Cache.Entry entry, Object > p) \{ > if (p.getClass().equals(Person.class)) { > Person person = (Person)p; > return new Person(new > StringBuilder(person.getName()).reverse().toString(), person.getHeight()); > } > else if (p.getClass().equals(BinaryObjectImpl.class)) \{ > BinaryObjectBuilder person = ((BinaryObject) > p).toBuilder(); > String name = person.getField("name"); > person.setField("name", new > StringBuilder(name).reverse().toString()); > return person.build(); > } > else \{ > return null; > } > } > @Override > public void onAfterPut(Cache.Entry entry) \{ > // do nothing > } > @Override > public IgniteBiTuple > onBeforeRemove(Cache.Entry entry) \{ > return new IgniteBiTuple<>(true, entry.getValue()); > } > @Override > public void onAfterRemove(Cache.Entry entry) \{ > // do nothing > } > }); > It reverses the name before storing it and reverses it again on a get. In > 2.9.0 this works as expected. In every version since it fails. It reverses > the string on a put but the onGet method never gets called. -- This message was sent by Atlassian Jira (v8.20.10#820010)