Skip to content

Commit

Permalink
Using context in init without try-with-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
kshepherd committed Sep 26, 2024
1 parent 41cf572 commit 1234754
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ public class AuthorityVirtualMetadataServiceImpl implements AuthorityVirtualMeta
public void init() {
validVirtualFieldNames = new HashMap<>();
authorityVirtualMaps = new HashMap<>();
Context context = null;
// Obtain new context and initialise lists and maps
try (Context context = new Context(Context.Mode.READ_ONLY)) {
try {
context = new Context(Context.Mode.READ_ONLY);
// Get field maps configured in virtual metadata spring configuration
authorityVirtualMaps = authorityVirtualMetadataPopulator.getMap();
// Iterate map of maps, just to check each virtual field name (key of 2nd-level map) exists
Expand All @@ -72,6 +74,10 @@ public void init() {
} catch (SQLException e) {
log.error("Could not obtain context" + e.getMessage(), e);
throw new RuntimeException(e);
} finally {
if (context != null) {
context.close();
}
}
}

Expand Down

0 comments on commit 1234754

Please sign in to comment.