Skip to content

Commit

Permalink
HBASE-25691 Test failure: TestVerifyBucketCacheFile.testRetrieveFromFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Huaxiang Sun committed Mar 23, 2021
1 parent 202b17f commit e03cc37
Showing 1 changed file with 16 additions and 3 deletions.
Expand Up @@ -1112,14 +1112,27 @@ private void retrieveFromFile(int[] bucketSizes) throws IOException {
*/
private FileInputStream deleteFileOnClose(final File file) throws IOException {
return new FileInputStream(file) {
private File myFile;
private FileInputStream init(File file) {
myFile = file;
return this;
}
@Override
public void close() throws IOException {
// close() will be called during try-with-resources and it will be
// called by finalizer thread during GC. To avoid double-free resource,
// set myFile to null after the first call.
if (myFile == null) {
return;
}

super.close();
if (!file.delete()) {
throw new IOException("Failed deleting persistence file " + file.getAbsolutePath());
if (!myFile.delete()) {
throw new IOException("Failed deleting persistence file " + myFile.getAbsolutePath());
}
myFile = null;
}
};
}.init(file);
}

private void verifyCapacityAndClasses(long capacitySize, String ioclass, String mapclass)
Expand Down

0 comments on commit e03cc37

Please sign in to comment.