You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Stephen Darlington (Jira)" <ji...@apache.org> on 2022/08/31 17:06:00 UTC

[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&focusedCommentId=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<Long, Object> cacheConfiguration = new CacheConfiguration<>();
>         cacheConfiguration.setName("PERSON_CACHE");
>         cacheConfiguration.setAtomicityMode(CacheAtomicityMode.ATOMIC);
>         cacheConfiguration.setIndexedTypes(Long.class, Person.class);
>         cacheConfiguration.setInterceptor(new CacheInterceptor<Long, 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<Long, Object> 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<Long, Object> entry) \{
>                 // do nothing
>             }
>             @Override
>             public IgniteBiTuple<Boolean, Object> onBeforeRemove(Cache.Entry<Long, Object> entry) \{
>                 return new IgniteBiTuple<>(true, entry.getValue());
>             }
>             @Override
>             public void onAfterRemove(Cache.Entry<Long, Object> 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)