Skip to content

Commit 6bc7da7

Browse files
authored
chore(jdbc): suppress expected compiler warnings (#248)
## Why The build runs `-Xlint:all`, so every run reports expected warnings. Two tests exercise the deprecated Unicode stream API on purpose, the vendored xerial tree uses deprecated JDK methods, and the parameter metadata view triggers a `this` escape that it cannot actually cause. The noise makes a new warning hard to see. ## What changed - Suppress `deprecation` on the two tests that exercise the deprecated Unicode stream methods. - Suppress the deprecation detail and javac's summary note for the `libsql-conformance` test compile, which includes the vendored xerial sources. - Suppress `this-escape` on the `LibsqlPreparedStatement` constructor and document why the view is safe. ## Scope No behavior change. The deprecated calls stay in the tests, and the vendored tree stays untouched. Only the compiler diagnostics are suppressed, and only where the warning is expected. ## Tradeoffs `-XDsuppressNotes` is an internal javac option. It is scoped to the conformance test compile, and the build pins the JDK. ## Blast Radius Compiler diagnostics only. The driver and its tests are unchanged, and the `libsql-conformance` main sources keep the full lint set. ## Verification - `clean verify`: 2,006 tests, 0 failures, 7 skipped, `BUILD SUCCESS`. - `libsql-jdbc` clean test: 1,510 tests, 0 failures, with no `deprecated` or `this-escape` warning. - Conformance test compile: no deprecation detail and no summary note. - `spotless:check` passes. The JDK's `sun.misc.Unsafe` warning from ByteBuddy is unrelated and remains.
1 parent e41cac1 commit 6bc7da7

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎libsql-conformance/pom.xml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,23 @@
163163
</execution>
164164
</executions>
165165
</plugin>
166+
<plugin>
167+
<!-- The vendored xerial tests use deprecated JDBC API on purpose.
168+
Suppress the deprecation detail and javac's summary note for the test compile. -->
169+
<groupId>org.apache.maven.plugins</groupId>
170+
<artifactId>maven-compiler-plugin</artifactId>
171+
<executions>
172+
<execution>
173+
<id>default-testCompile</id>
174+
<configuration>
175+
<compilerArgs combine.children="append">
176+
<arg>-Xlint:-deprecation</arg>
177+
<arg>-XDsuppressNotes</arg>
178+
</compilerArgs>
179+
</configuration>
180+
</execution>
181+
</executions>
182+
</plugin>
166183
<plugin>
167184
<groupId>org.apache.maven.plugins</groupId>
168185
<artifactId>maven-surefire-plugin</artifactId>

‎libsql-jdbc/src/main/java/com/github/magnusp/libsql/jdbc/LibsqlPreparedStatement.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class LibsqlPreparedStatement extends LibsqlStatement implements Prepared
5252
// Sequential list indexed by JDBC parameter position; no map or boxing overhead.
5353
private final List<Value> parameters = new ArrayList<>();
5454

55+
// ParameterMetaDataView only stores this reference and calls checkClosed() after construction,
56+
// so no subclass method can run against a half-built statement.
57+
@SuppressWarnings("this-escape")
5558
public LibsqlPreparedStatement(LibsqlConnection connection, String sql) {
5659
super(connection);
5760
this.sql = sql;

‎libsql-jdbc/src/test/java/com/github/magnusp/libsql/jdbc/LibsqlPreparedStatementTest.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ void unsetParametersBindNullArguments() throws SQLException {
409409
.containsExactly(Value.of(7L), Value.ofNull());
410410
}
411411

412+
// The deprecated Unicode stream setter is part of the local-conversion contract.
413+
@SuppressWarnings("deprecation")
412414
@Test
413415
void streamSettersBindLocalConversions() throws SQLException {
414416
RecordingConnection connection = new RecordingConnection(NO_ROWS);

‎libsql-jdbc/src/test/java/com/github/magnusp/libsql/jdbc/LibsqlResultSetTest.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ void findColumnRejectsNullLabel() {
457457
.hasMessageContaining("null");
458458
}
459459

460+
// The deprecated Unicode stream getters are part of the unsupported-method contract.
461+
@SuppressWarnings("deprecation")
460462
@Test
461463
void everyUnsupportedMethodThrowsSqlFeatureNotSupportedException() throws SQLException {
462464
LibsqlResultSet rs = resultSet(new Value.Integer(1));

0 commit comments

Comments
 (0)