Skip to content

Commit 3ed9614

Browse files
authored
try-with-resources and use Results (#5)
1 parent 62e416b commit 3ed9614

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

laboratory/src/org/labkey/laboratory/LaboratoryManager.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import org.apache.commons.lang3.StringUtils;
1919
import org.apache.log4j.Logger;
2020
import org.jetbrains.annotations.Nullable;
21+
import org.labkey.api.assay.AssayProvider;
22+
import org.labkey.api.assay.AssayService;
2123
import org.labkey.api.collections.CaseInsensitiveHashMap;
2224
import org.labkey.api.collections.CaseInsensitiveHashSet;
2325
import org.labkey.api.data.Aggregate;
@@ -50,10 +52,7 @@
5052
import org.labkey.api.query.QueryUpdateServiceException;
5153
import org.labkey.api.query.UserSchema;
5254
import org.labkey.api.security.User;
53-
import org.labkey.api.assay.AssayProvider;
54-
import org.labkey.api.assay.AssayService;
5555
import org.labkey.api.util.PageFlowUtil;
56-
import org.labkey.api.util.ResultSetUtil;
5756
import org.labkey.api.view.Portal;
5857
import org.labkey.laboratory.query.ContainerIncrementingTable;
5958
import org.labkey.laboratory.query.LaboratoryWorkbooksTable;
@@ -529,19 +528,14 @@ private void processIndexes(DbSchema schema, TableInfo realTable, List<List<Stri
529528

530529
Set<String> indexNames = new CaseInsensitiveHashSet();
531530
DatabaseMetaData meta = schema.getScope().getConnection().getMetaData();
532-
ResultSet rs = null;
533-
try
531+
532+
try (ResultSet rs = meta.getIndexInfo(schema.getScope().getDatabaseName(), schema.getName(), realTable.getName(), false, false))
534533
{
535-
rs = meta.getIndexInfo(schema.getScope().getDatabaseName(), schema.getName(), realTable.getName(), false, false);
536534
while (rs.next())
537535
{
538536
indexNames.add(rs.getString("INDEX_NAME"));
539537
}
540538
}
541-
finally
542-
{
543-
ResultSetUtil.close(rs);
544-
}
545539

546540
boolean exists = indexNames.contains(indexName);
547541
if (exists && rebuildIndexes)

0 commit comments

Comments
 (0)