Uploaded image for project: 'Spring Data GemFire'
  1. Spring Data GemFire
  2. SGF-327

Avoid setting null values with GemFire's Cache Region put(key, value) operation when GemFire is used as the caching provider in Spring's Cache Abstraction (@Cacheable).

    XMLWordPrintable

    Details

      Description

      Currently, when GemFire is used as the caching provider in Spring's Cache Abstraction like so...

          @Cacheable("ExampleRegion")
          public Integer get(final String key) {
            return repository.get(key);
          }
      

      ... And repository.get(key) returns a null value, then Spring's Cache Abstraction will still attempt to associate a key with the null value by performing a GemFire Cache Region.put("key", null), which GemFire does not allow, resulting in the following Exception...

      java.lang.NullPointerException: value must not be null
      	at com.gemstone.gemfire.internal.cache.LocalRegion.newUpdateEntryEvent(LocalRegion.java:1745)
      	at com.gemstone.gemfire.internal.cache.LocalRegion.put(LocalRegion.java:1706)
      	at com.gemstone.gemfire.internal.cache.AbstractRegion.put(AbstractRegion.java:286)
      	at org.spring.cache.CachingWithGemFireIntegrationTest.testRegionCacheHit(CachingWithGemFireIntegrationTest.java:50)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
      	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
      	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
      

      This improvement is to work around this "GemFire" limitation.

        Attachments

          Activity

            People

            Assignee:
            jblum John Blum
            Reporter:
            jblum John Blum
            Last updater:
            Trevor Marshall
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0.25d
                0.25d
                Remaining:
                Remaining Estimate - 0.25d
                0.25d
                Logged:
                Time Spent - Not Specified
                Not Specified