Skip to content

Commit 6004cae

Browse files
committed
CodeQL Nags
1 parent 72a21ea commit 6004cae

27 files changed

Lines changed: 242 additions & 196 deletions

src/test/java/examples/animal/data/AnimalDataTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ class AnimalDataTest {
7676
@BeforeEach
7777
void setup() throws Exception {
7878
Class.forName(JDBC_DRIVER);
79-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
80-
assert is != null;
81-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
82-
ScriptRunner sr = new ScriptRunner(connection);
83-
sr.setLogWriter(null);
84-
sr.runScript(new InputStreamReader(is));
79+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
80+
assert is != null;
81+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
82+
InputStreamReader isr = new InputStreamReader(is)) {
83+
ScriptRunner sr = new ScriptRunner(connection);
84+
sr.setLogWriter(null);
85+
sr.runScript(isr);
86+
}
8587
}
8688

8789
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

src/test/java/examples/animal/data/BindingTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,12 +50,14 @@ class BindingTest {
5050
@BeforeEach
5151
void setup() throws Exception {
5252
Class.forName(JDBC_DRIVER);
53-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
54-
assert is != null;
55-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
56-
ScriptRunner sr = new ScriptRunner(connection);
57-
sr.setLogWriter(null);
58-
sr.runScript(new InputStreamReader(is));
53+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
54+
assert is != null;
55+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
56+
InputStreamReader isr = new InputStreamReader(is)) {
57+
ScriptRunner sr = new ScriptRunner(connection);
58+
sr.setLogWriter(null);
59+
sr.runScript(isr);
60+
}
5961
}
6062

6163
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

src/test/java/examples/animal/data/CaseExpressionTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,12 +72,14 @@ class CaseExpressionTest {
7272
@BeforeEach
7373
void setup() throws Exception {
7474
Class.forName(JDBC_DRIVER);
75-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
76-
assert is != null;
77-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
78-
ScriptRunner sr = new ScriptRunner(connection);
79-
sr.setLogWriter(null);
80-
sr.runScript(new InputStreamReader(is));
75+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
76+
assert is != null;
77+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
78+
InputStreamReader isr = new InputStreamReader(is)) {
79+
ScriptRunner sr = new ScriptRunner(connection);
80+
sr.setLogWriter(null);
81+
sr.runScript(isr);
82+
}
8183
}
8284

8385
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

src/test/java/examples/animal/data/CommonSelectMapperTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,12 +54,14 @@ class CommonSelectMapperTest {
5454
@BeforeEach
5555
void setup() throws Exception {
5656
Class.forName(JDBC_DRIVER);
57-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
58-
assert is != null;
59-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
60-
ScriptRunner sr = new ScriptRunner(connection);
61-
sr.setLogWriter(null);
62-
sr.runScript(new InputStreamReader(is));
57+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
58+
assert is != null;
59+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
60+
InputStreamReader isr = new InputStreamReader(is)) {
61+
ScriptRunner sr = new ScriptRunner(connection);
62+
sr.setLogWriter(null);
63+
sr.runScript(isr);
64+
}
6365
}
6466

6567
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

src/test/java/examples/animal/data/FetchFirstTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,12 +50,14 @@ class FetchFirstTest {
5050
@BeforeEach
5151
void setup() throws Exception {
5252
Class.forName(JDBC_DRIVER);
53-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
54-
assert is != null;
55-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
56-
ScriptRunner sr = new ScriptRunner(connection);
57-
sr.setLogWriter(null);
58-
sr.runScript(new InputStreamReader(is));
53+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
54+
assert is != null;
55+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
56+
InputStreamReader isr = new InputStreamReader(is)) {
57+
ScriptRunner sr = new ScriptRunner(connection);
58+
sr.setLogWriter(null);
59+
sr.runScript(isr);
60+
}
5961
}
6062

6163
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

src/test/java/examples/animal/data/LimitAndOffsetTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,12 +49,14 @@ class LimitAndOffsetTest {
4949
@BeforeEach
5050
void setup() throws Exception {
5151
Class.forName(JDBC_DRIVER);
52-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
53-
assert is != null;
54-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
55-
ScriptRunner sr = new ScriptRunner(connection);
56-
sr.setLogWriter(null);
57-
sr.runScript(new InputStreamReader(is));
52+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
53+
assert is != null;
54+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
55+
InputStreamReader isr = new InputStreamReader(is)) {
56+
ScriptRunner sr = new ScriptRunner(connection);
57+
sr.setLogWriter(null);
58+
sr.runScript(isr);
59+
}
5860
}
5961

6062
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

src/test/java/examples/animal/data/OptionalConditionsAnimalDataTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,12 +51,14 @@ class OptionalConditionsAnimalDataTest {
5151
@BeforeEach
5252
void setup() throws Exception {
5353
Class.forName(JDBC_DRIVER);
54-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
55-
assert is != null;
56-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
57-
ScriptRunner sr = new ScriptRunner(connection);
58-
sr.setLogWriter(null);
59-
sr.runScript(new InputStreamReader(is));
54+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
55+
assert is != null;
56+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
57+
InputStreamReader isr = new InputStreamReader(is)) {
58+
ScriptRunner sr = new ScriptRunner(connection);
59+
sr.setLogWriter(null);
60+
sr.runScript(isr);
61+
}
6062
}
6163

6264
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

src/test/java/examples/animal/data/OptionalConditionsWithPredicatesAnimalDataTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,12 +57,14 @@ class OptionalConditionsWithPredicatesAnimalDataTest {
5757
@BeforeEach
5858
void setup() throws Exception {
5959
Class.forName(JDBC_DRIVER);
60-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
61-
assert is != null;
62-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
63-
ScriptRunner sr = new ScriptRunner(connection);
64-
sr.setLogWriter(null);
65-
sr.runScript(new InputStreamReader(is));
60+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
61+
assert is != null;
62+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
63+
InputStreamReader isr = new InputStreamReader(is)) {
64+
ScriptRunner sr = new ScriptRunner(connection);
65+
sr.setLogWriter(null);
66+
sr.runScript(isr);
67+
}
6668
}
6769

6870
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

src/test/java/examples/animal/data/SubQueryTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,12 +51,14 @@ class SubQueryTest {
5151
@BeforeEach
5252
void setup() throws Exception {
5353
Class.forName(JDBC_DRIVER);
54-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
55-
assert is != null;
56-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
57-
ScriptRunner sr = new ScriptRunner(connection);
58-
sr.setLogWriter(null);
59-
sr.runScript(new InputStreamReader(is));
54+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
55+
assert is != null;
56+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
57+
InputStreamReader isr = new InputStreamReader(is)) {
58+
ScriptRunner sr = new ScriptRunner(connection);
59+
sr.setLogWriter(null);
60+
sr.runScript(isr);
61+
}
6062
}
6163

6264
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

src/test/java/examples/animal/data/VariousListConditionsTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2025 the original author or authors.
2+
* Copyright 2016-2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,12 +64,14 @@ class VariousListConditionsTest {
6464
@BeforeEach
6565
void setup() throws Exception {
6666
Class.forName(JDBC_DRIVER);
67-
InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql");
68-
assert is != null;
69-
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "")) {
70-
ScriptRunner sr = new ScriptRunner(connection);
71-
sr.setLogWriter(null);
72-
sr.runScript(new InputStreamReader(is));
67+
try (InputStream is = getClass().getResourceAsStream("/examples/animal/data/CreateAnimalData.sql")) {
68+
assert is != null;
69+
try (Connection connection = DriverManager.getConnection(JDBC_URL, "sa", "");
70+
InputStreamReader isr = new InputStreamReader(is)) {
71+
ScriptRunner sr = new ScriptRunner(connection);
72+
sr.setLogWriter(null);
73+
sr.runScript(isr);
74+
}
7375
}
7476

7577
UnpooledDataSource ds = new UnpooledDataSource(JDBC_DRIVER, JDBC_URL, "sa", "");

0 commit comments

Comments
 (0)