Skip to content

Commit

Permalink
close query in finally
Browse files Browse the repository at this point in the history
  • Loading branch information
naknomum committed Dec 18, 2024
1 parent 1d06bb8 commit fa16a54
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/org/ecocean/Encounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3962,8 +3962,9 @@ public static void opensearchIndexPermissions() {
// we do not need full Encounter objects here to update index docs, so lets do this via sql/fields - much faster
String sql =
"SELECT \"CATALOGNUMBER\", \"SUBMITTERID\" FROM \"ENCOUNTER\" WHERE \"SUBMITTERID\" IS NOT NULL AND \"SUBMITTERID\" != '' AND \"SUBMITTERID\" != 'N/A' AND \"SUBMITTERID\" != 'public'";
Query q = null;
try {
Query q = myShepherd.getPM().newQuery("javax.jdo.query.SQL", sql);
q = myShepherd.getPM().newQuery("javax.jdo.query.SQL", sql);
List results = (List)q.execute();
Iterator it = results.iterator();
Util.mark("perm: start encs, size=" + results.size(), startT);
Expand Down Expand Up @@ -4008,6 +4009,8 @@ public static void opensearchIndexPermissions() {
} catch (Exception ex) {
System.out.println("opensearchIndexPermissions(): failed during encounter loop: " + ex);
ex.printStackTrace();
} finally {
if (q != null) q.closeAll();
}
Util.mark("perm: done encs", startT);
myShepherd.rollbackAndClose();
Expand Down

0 comments on commit fa16a54

Please sign in to comment.