Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-17603

onGet not triggered in Cache Interceptor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.9.1
    • None
    • cache
    • None
    • Mac, Java 11

    • Docs Required, Release Notes Required

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sdarlington Stephen Darlington
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: