@Test
  public void testBug31592() throws Exception {
    final String name = getUniqueName();
    final Object key = "KEY";
    final Object value = "VALUE";
    final Object key2 = "KEY2";
    final Object value2 = "VALUE2";

    AttributesFactory factory = new AttributesFactory();
    factory.setOffHeap(isOffHeapEnabled());
    factory.setScope(Scope.LOCAL);
    factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(10));
    final Region region = createRegion(name, factory.create());

    region.put(key, value);

    final Throwable[] errors = new Throwable[1];
    region.getAttributesMutator().addCacheListener(new CacheListenerAdapter() {
      @Override
      public void afterCreate(EntryEvent event) {
        try {
          LogWriterUtils.getLogWriter().info("AFTER CREATE");
          region.put(key, value2);

        } catch (VirtualMachineError e) {
          SystemFailure.initiateFailure(e);
          throw e;
        } catch (Throwable ex) {
          region.getCache().getLogger().severe("failed to access cache from listener", ex);
          errors[0] = ex;
        }
      }
    });
    region.put(key2, value2);

    assertNull(errors[0]);
    assertEquals(value2, region.get(key));
    assertEquals(value2, region.get(key2));
  }
Tests that a Region with an LRU capacity controller can be accessed from inside a cache
listener.
geode-core/src/distributedTest/java/org/apache/geode/cache30/LRUEvictionControllerDUnitTest.java