Skip to content

Commit

Permalink
[FLINK-9735][tests] Potential leak in RocksDBResource
Browse files Browse the repository at this point in the history
This closes apache#6660.
  • Loading branch information
yanghua authored and StefanRRichter committed Sep 10, 2018
1 parent 5f8d91f commit 1a94c20
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.rocksdb.ReadOptions;
import org.rocksdb.RocksDB;
import org.rocksdb.WriteOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;

Expand All @@ -43,6 +45,8 @@
*/
public class RocksDBResource extends ExternalResource {

private static final Logger LOG = LoggerFactory.getLogger(RocksDBResource.class);

/** Factory for {@link DBOptions} and {@link ColumnFamilyOptions}. */
private final OptionsFactory optionsFactory;

Expand Down Expand Up @@ -74,11 +78,25 @@ public RocksDBResource() {
this(new OptionsFactory() {
@Override
public DBOptions createDBOptions(DBOptions currentOptions) {
//close it before reuse the reference.
try {
currentOptions.close();
} catch (Exception e) {
LOG.error("Close previous DBOptions's instance failed.", e);
}

return PredefinedOptions.FLASH_SSD_OPTIMIZED.createDBOptions();
}

@Override
public ColumnFamilyOptions createColumnOptions(ColumnFamilyOptions currentOptions) {
//close it before reuse the reference.
try {
currentOptions.close();
} catch (Exception e) {
LOG.error("Close previous DBOptions's instance failed.", e);
}

return PredefinedOptions.FLASH_SSD_OPTIMIZED.createColumnOptions();
}
});
Expand Down

0 comments on commit 1a94c20

Please sign in to comment.