void putAfterFlush(final Region region) {
    alreadyComeHere = false;
    CacheObserverHolder.setInstance(new CacheObserverAdapter() {

      @Override
      public void afterWritingBytes() {
        if (!alreadyComeHere) {
          DiskEntry de = (DiskEntry) ((LocalRegion) region).basicGetEntry("Key");
          if (de == null) {
            return; // this is caused by the first flush
          }
          DiskId id = de.getDiskId();
          long oldOplogId = id.getOplogId();
          long oldOplogOffset = id.getOffsetInOplog();
          ((LocalRegion) region).getDiskRegion().pauseFlusherForTesting();
          // region.getCache().getLogger().info("putting value2");
          region.put("Key", "Value2");
          id = ((DiskEntry) (((LocalRegion) region).basicGetEntry("Key"))).getDiskId();
          long newOplogId = id.getOplogId();
          long newOplogOffset = id.getOffsetInOplog();
          id.setOplogId(oldOplogId);
          id.setOffsetInOplog(oldOplogOffset);
          assertEquals("Value1", ((LocalRegion) region).getDiskRegion().getNoBuffer(id));
          id.setOplogId(newOplogId);
          id.setOffsetInOplog(newOplogOffset);
        }
        alreadyComeHere = true;
      }
    });
    // region.getCache().getLogger().info("before pause");
    ((LocalRegion) region).getDiskRegion().pauseFlusherForTesting();
    // region.getCache().getLogger().info("putting value1");
    region.put("Key", "Value1");
    // region.getCache().getLogger().info("before flush");
    ((LocalRegion) region).getDiskRegion().flushForTesting();
    try {
      // region.getCache().getLogger().info("getting value2");
      assertEquals("Value2", region.get("Key"));
    } catch (Exception e) {
      logWriter.error("Exception occurred", e);
      fail("Entry not found although was supposed to be there");
    }

    ((LocalRegion) region).getDiskRegion().flushForTesting();

    try {
      assertEquals("Value2", getValueOnDisk(region));
    } catch (EntryNotFoundException e) {
      logWriter.error("Exception occurred", e);
      fail("Entry not found although was supposed to be there");
    }

  }
A region close is done after flush is over. The close is done in a separate thread and a 3000
ms wait is put to ensure that the separate thread has closed the region
geode-core/src/integrationTest/java/org/apache/geode/internal/cache/ConcurrentFlushingAndRegionOperationsJUnitTest.java