Source:
<code><START> public void testKeyValueContainerCheckCorruption() throws Exception { <END> long containerID = 102; int deletedBlocks = 1; int normalBlocks = 3; int chunksPerBlock = 4; boolean valid = false; createContainerWithBlocks(containerID, normalBlocks, deletedBlocks, 65536, chunksPerBlock); File chunksPath = new File(containerData.getChunksPath()); assertTrue(chunksPath.listFiles().length == (deletedBlocks + normalBlocks) * chunksPerBlock); container.close(); KeyValueContainerCheck kvCheck = new KeyValueContainerCheck(containerData.getMetadataPath(), conf, containerID); File metaDir = new File(containerData.getMetadataPath()); File dbFile = KeyValueContainerLocationUtil .getContainerDBFile(metaDir, containerID); containerData.setDbFile(dbFile); try(ReferenceCountedDB db = BlockUtils.getDB(containerData, conf); KeyValueBlockIterator kvIter = new KeyValueBlockIterator(containerID, new File(containerData.getContainerPath()))) { BlockData block = kvIter.nextBlock(); assertTrue(!block.getChunks().isEmpty()); ContainerProtos.ChunkInfo c = block.getChunks().get(0); File chunkFile = ChunkUtils.getChunkFile(containerData, ChunkInfo.getFromProtoBuf(c)); long length = chunkFile.length(); assertTrue(length > 0); try (RandomAccessFile file = new RandomAccessFile(chunkFile, "rws")) { file.setLength(length / 2); } assertEquals(length/2, chunkFile.length()); } valid = kvCheck.fastCheck(); assertTrue(valid); valid = kvCheck.fullCheck(new DataTransferThrottler( HddsConfigKeys.HDDS_CONTAINER_SCANNER_VOLUME_BYTES_PER_SECOND_DEFAULT), null); assertFalse(valid); }</code><technical_language>run this test memory profiler leaks. Thanks</technical_language>

Target:
public void testKeyValueContainerCheckCorruption() throws Exception { long containerID = 102; int deletedBlocks = 1; int normalBlocks = 3; int chunksPerBlock = 4; boolean valid = false; ContainerScrubberConfiguration sc = conf.getObject( ContainerScrubberConfiguration.class); createContainerWithBlocks(containerID, normalBlocks, deletedBlocks, 65536, chunksPerBlock); File chunksPath = new File(containerData.getChunksPath()); assertTrue(chunksPath.listFiles().length == (deletedBlocks + normalBlocks) * chunksPerBlock); container.close(); KeyValueContainerCheck kvCheck = new KeyValueContainerCheck(containerData.getMetadataPath(), conf, containerID); File metaDir = new File(containerData.getMetadataPath()); File dbFile = KeyValueContainerLocationUtil .getContainerDBFile(metaDir, containerID); containerData.setDbFile(dbFile); try(ReferenceCountedDB db = BlockUtils.getDB(containerData, conf); KeyValueBlockIterator kvIter = new KeyValueBlockIterator(containerID, new File(containerData.getContainerPath()))) { BlockData block = kvIter.nextBlock(); assertTrue(!block.getChunks().isEmpty()); ContainerProtos.ChunkInfo c = block.getChunks().get(0); File chunkFile = ChunkUtils.getChunkFile(containerData, ChunkInfo.getFromProtoBuf(c)); long length = chunkFile.length(); assertTrue(length > 0); try (RandomAccessFile file = new RandomAccessFile(chunkFile, "rws")) { file.setLength(length / 2); } assertEquals(length/2, chunkFile.length()); } valid = kvCheck.fastCheck(); assertTrue(valid); valid = kvCheck.fullCheck(new DataTransferThrottler( sc.getBandwidthPerVolume()), null); assertFalse(valid); }