Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr committed Jan 24, 2025
1 parent 13a32e2 commit d0eb160
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class CustomJniDBFactory extends JniDBFactory {

@Override
public DB open(final File path, final Options options) throws IOException {
NativeDB db = null;
OptionsResourceHolder holder = new OptionsResourceHolder();
final OptionsResourceHolder holder = new OptionsResourceHolder();

NativeDB db = null;
try {
holder.init(options);
db = NativeDB.open(holder.options, path);
Expand All @@ -62,8 +62,12 @@ public DB open(final File path, final Options options) throws IOException {
NativeDB.LIBRARY.load();
String v = "unknown";

try (InputStream is = JniDBFactory.class.getResourceAsStream("version.txt")) {
v = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)).readLine();
try (final InputStream is = JniDBFactory.class.getResourceAsStream("version.txt")) {
if (is != null) {
try (final InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
v = new BufferedReader(reader).readLine();

Check warning

Code scanning / CodeQL

Potential input resource leak Warning

This BufferedReader is not always closed on method exit.
}
}
} catch (final Throwable ignored) {
}

Expand Down

0 comments on commit d0eb160

Please sign in to comment.