pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: binoverfl0w (@binoverfl0w) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: Re: [pgjdbc/pgjdbc] PR #3396: SQLData Support
Date: Sun, 13 Oct 2024 14:45:39 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
I remember running into this as well. Set **enableCheckerframework** build parameter to **true** as it is false by default. https://github.com/pgjdbc/pgjdbc/blob/fcc13e70e6b6bb64b848df4b4ba6b3566b5e95a3/build-logic/build-par...
I tried to run ```./gradlew checkstyleAll``` and it gave the same error as the one reported here.
The fixes seem trivial. From a quick look, the patch below gets rid of the failures.
A helpful note on ```@Nullable byte[]``` vs ```byte @Nullable []``` that might be of interest: http://errorprone.info/bugpattern/NullablePrimitiveArray
Since ```@SupressWarnings``` cannot be applied to statements, you may consider moving the following block
```java
if ("NULL".equals(item)) {
java.lang.reflect.Array.set(results, i, null);
} else {
java.lang.reflect.Array.set(results, i, converter.apply(item));
}
```
in a separate function and annotate that with ```@SurpressWarnings("nullable")``` instead of annotating ```#getConverter``` with ```@SuppressWarnings({"unchecked", "nullness"})```
Anyway once you face the same errors locally you will be able to better reason about such details.
```
Subject: [PATCH] fix CheckerFramework failures
---
Index: pgjdbc/src/main/java/org/postgresql/jdbc/PgSQLInput.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pgjdbc/src/main/java/org/postgresql/jdbc/PgSQLInput.java b/pgjdbc/src/main/java/org/postgresql/jdbc/PgSQLInput.java
--- a/pgjdbc/src/main/java/org/postgresql/jdbc/PgSQLInput.java (revision c664b7d767951d48df94f1a84084e4d86f688e91)
+++ b/pgjdbc/src/main/java/org/postgresql/jdbc/PgSQLInput.java (date 1728829537425)
@@ -151,7 +151,7 @@
@SuppressWarnings({"override.return", "nullness.on.primitive", "return"})
@Override
- public @Nullable byte[] readBytes() throws SQLException {
+ public byte @Nullable [] readBytes() throws SQLException {
return getNextValue(bytesConv);
}
@@ -187,7 +187,8 @@
@Override
public InputStream readBinaryStream() throws SQLException {
- return new ByteArrayInputStream(readBytes());
+ byte[] bytes = readBytes();
+ return new ByteArrayInputStream(bytes == null ? new byte[0] : bytes);
}
@SuppressWarnings("override.return")
@@ -253,13 +254,13 @@
throw Driver.notImplemented(this.getClass(), "readNString()");
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "nullness"})
private <T> SQLFunction<String, T> getConverter(Class<T> type) throws SQLException {
if (type.isArray()) {
Class<?> itemType = type.getComponentType();
SQLFunction<String, ?> converter = getConverter(itemType);
return (value) -> {
- List<String> items = new SQLDataReader().parseArray(value);
+ List<@Nullable String> items = new SQLDataReader().parseArray(value);
Object results = java.lang.reflect.Array.newInstance(itemType, items.size());
for (int i = 0; i < items.size(); i++) {
String item = items.get(i);
```
view thread (67+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://pgjdbc/pgjdbc
Cc: [email protected], [email protected]
Subject: Re: [pgjdbc/pgjdbc] PR #3396: SQLData Support
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox