@Override
  public WMValidateResourcePlanResponse validateResourcePlan(String name, String ns)
      throws NoSuchObjectException, InvalidObjectException, MetaException {
    name = normalizeIdentifier(name);
    boolean committed = false;
    Query query = null;
    try {
      query = createGetResourcePlanQuery();
      MWMResourcePlan mResourcePlan = (MWMResourcePlan) query.execute(name, ns);
      if (mResourcePlan == null) {
        throw new NoSuchObjectException("Cannot find resourcePlan: " + name + " in " + ns);
      }
      WMValidateResourcePlanResponse result = getResourcePlanErrors(mResourcePlan);
      committed = commitTransaction();
      return result;
    } finally {
      rollbackAndCleanup(committed, query);
    }
  }
This is a cleanup method which is used to rollback a active transaction
if the success flag is false and close the associated Query object. This method is used
internally and visible for testing purposes only
@param success Rollback the current active transaction if false
@param query Query object which needs to be closed
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java