Skip to content

Commit 504cd8f

Browse files
committed
update
1 parent 237983d commit 504cd8f

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

instrumentation/jdbc/testing/src/main/java/io/opentelemetry/instrumentation/jdbc/TestConnection.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,30 @@
3030
public class TestConnection implements Connection {
3131

3232
private final String url;
33-
Consumer<String> sqlConsumer = unused -> {};
33+
private final Consumer<String> sqlConsumer;
3434

35-
public TestConnection() {}
35+
public TestConnection() {
36+
this(null, unused -> {});
37+
}
3638

3739
public TestConnection(String url) {
38-
this.url = url;
40+
this(url, unused -> {});
3941
}
4042

4143
public TestConnection(Consumer<String> sqlConsumer) {
42-
this.sqlConsumer = sqlConsumer;
44+
this(null, sqlConsumer);
4345
}
4446

4547
public TestConnection(boolean throwException) {
48+
this(null, unused -> {});
4649
if (throwException) {
4750
throw new IllegalStateException("connection exception");
4851
}
4952
}
5053

51-
public TestConnection(String url, boolean throwException) {
52-
this(throwException);
54+
private TestConnection(String url, Consumer<String> sqlConsumer) {
5355
this.url = url;
56+
this.sqlConsumer = sqlConsumer;
5457
}
5558

5659
@Override

instrumentation/jdbc/testing/src/main/java/io/opentelemetry/instrumentation/jdbc/testing/AbstractJdbcInstrumentationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ void testGetConnection(
11251125
@DisplayName("test getClientInfo exception")
11261126
@ValueSource(strings = "testing 123")
11271127
void testGetClientInfoException(String query) throws SQLException {
1128-
TestConnection rawConnection = new TestConnection("jdbc:testdb://localhost", false);
1128+
TestConnection rawConnection = new TestConnection("jdbc:testdb://localhost");
11291129
Connection connection = wrap(rawConnection);
11301130
cleanup.deferCleanup(connection);
11311131

instrumentation/jdbc/testing/src/main/java/io/opentelemetry/instrumentation/jdbc/testing/DbCallingConnection.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@
1010
import java.sql.SQLException;
1111

1212
class DbCallingConnection extends TestConnection {
13-
final boolean usePreparedStatement;
14-
15-
DbCallingConnection(boolean usePreparedStatement) {
16-
this(usePreparedStatement, null);
17-
}
13+
private final boolean usePreparedStatement;
1814

1915
DbCallingConnection(boolean usePreparedStatement, String url) {
20-
super(url, false);
16+
super(url);
2117
this.usePreparedStatement = usePreparedStatement;
2218
}
2319

0 commit comments

Comments
 (0)