@Test
  public void testDummyByteBugDuringRegionClose_Bug40250() throws Exception {
    DiskRegionProperties diskRegionProperties = new DiskRegionProperties();
    diskRegionProperties.setRegionName(regionName);
    diskRegionProperties.setRolling(true);
    diskRegionProperties.setCompactionThreshold(100);
    diskRegionProperties.setDiskDirs(diskDirs);
    diskRegionProperties.setPersistBackup(true);

    DiskStoreFactory diskStoreFactory = toDiskStoreFactory(diskRegionProperties);

    createDiskStoreWithSizeInBytes(diskStoreName, diskStoreFactory);

    Region<String, String> region =
        createRegion(regionName, diskStoreName, true, true, false, false, 0);

    // create some string entries
    for (int i = 0; i < 2; ++i) {
      region.put(String.valueOf(i), String.valueOf(i));
    }

    AtomicReference<Future<Void>> closeRegionFuture = new AtomicReference<>();

    LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = true;
    CacheObserverHolder.setInstance(new CacheObserverAdapter() {
      @Override
      public void beforeGoingToCompact() {
        closeRegionFuture.set(executorServiceRule.runAsync(() -> {
          try {
            region.close();
          } catch (AssertionError | Exception e) {
            errorCollector.addError(e);
          }
        }));

        // await until the roll flag DiskRegion.OplogCompactor is false (not currently exposed)
        try {
          Thread.sleep(8000);
        } catch (AssertionError | Exception e) {
          errorCollector.addError(e);
        }
      }
    });

    getDiskRegion(region).forceRolling();

    awaitFuture(closeRegionFuture);

    // Restart the region
    Region<String, String> region2 =
        createRegion(regionName, diskStoreName, true, true, false, false, 0);

    for (int i = 0; i < 2; ++i) {
      assertThat(region2.get(String.valueOf(i))).isEqualTo(String.valueOf(i));
    }
  }
Regression test for TRAC #40250: If roller is active at the time of region.close it can end up
writing a dummy byte & thus lose the original value
geode-core/src/integrationTest/java/org/apache/geode/internal/cache/DiskRegionJUnitTest.java