From 1b12eb719f2aeec7624182b983d79fc949d7cea2 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Tue, 05 May 2015 15:26:50 +0000
Subject: [PATCH] OPENDJ-1932 CR-6839 Improve management context API

---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
index a6e791c..4e04b7e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
@@ -38,7 +38,7 @@
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
-import java.io.IOException;
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedHashSet;
@@ -1103,11 +1103,10 @@
       final List<VLVSortOrder> sortOrder) throws OpenDsException
   {
     getInfo().initializeConfigurationFramework();
-    try
+    final File configFile = Installation.getLocal().getCurrentConfigurationFile();
+    final LDAPProfile ldapProfile = LDAPProfile.getInstance();
+    try (ManagementContext context = LDAPManagementContext.newLDIFManagementContext(configFile, ldapProfile))
     {
-      final List<IOException> exceptions = new ArrayList<>();
-      final ManagementContext context = LDAPManagementContext.newLDIFManagementContext(
-              Installation.getLocal().getCurrentConfigurationFile(), LDAPProfile.getInstance(), exceptions);
       final BackendCfgClient backend = context.getRootConfiguration().getBackend(backendName);
       if (backend instanceof LocalDBBackendCfgClient)
       {
@@ -1119,8 +1118,6 @@
         updateVLVBackendIndexOnline((PluggableBackendCfgClient) backend, vlvIndexName, indexToModify, baseDN, filter,
             searchScope, sortOrder);
       }
-      context.close();
-      Utilities.throwFirstFrom(exceptions);
     }
     catch (final Exception e)
     {

--
Gitblit v1.10.0