diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java index 90eaed3d8a..f358a22cee 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java @@ -1903,10 +1903,11 @@ static void deleteRMConfStore(Configuration conf) throws Exception { } if (scheduler instanceof MutableConfScheduler && isConfigurationMutable) { - YarnConfigurationStore confStore = YarnConfigurationStoreFactory - .getStore(conf); - confStore.initialize(conf, conf, rmContext); - confStore.format(); + try (YarnConfigurationStore confStore = YarnConfigurationStoreFactory + .getStore(conf)) { + confStore.initialize(conf, conf, rmContext); + confStore.format(); + } } else { System.out.println(String.format("Scheduler Configuration format only " + "supported by %s.", MutableConfScheduler.class.getSimpleName())); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/YarnConfigurationStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/YarnConfigurationStore.java index 0f44f43905..2ec2ea442a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/YarnConfigurationStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/YarnConfigurationStore.java @@ -44,7 +44,7 @@ * {@code getPendingMutations}, and replay/confirm them via * {@code confirmMutation} as in the normal case. */ -public abstract class YarnConfigurationStore { +public abstract class YarnConfigurationStore implements AutoCloseable { public static final Logger LOG = LoggerFactory.getLogger(YarnConfigurationStore.class);