8000 Fix NullPointerException in array conversion · emrul/postgres-async-driver@070aac1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 070aac1

Browse files
committed
Fix NullPointerException in array conversion
1 parent f1e99b1 commit 070aac1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/main/java/com/github/pgasync/impl/conversion/ArrayConversions.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ public static <T> T toArray(Class<T> type, Oid oid, byte[] value, BiFunction<Oid
6060
throw new IllegalArgumentException("Primitive arrays are not supported due to possible NULL values");
6161
}
6262

63+
if (value == null) {
64+
return null;
65+
}
66+
6367
char[] text = new String(value, UTF_8).toCharArray();
6468
List<List<Object>> holder = new ArrayList<>(1);
6569

src/test/java/com/github/pgasync/impl/ArrayConversionsTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ public void selectTimestamp() {
127127
getRow().getArray("TIMESTAMPA", Timestamp[].class));
128128
}
129129

130+
@Test
131+
public void selectNull() {
132+
dbr.query("INSERT INTO CA_TEST (TEXTA) VALUES (NULL);");
133+
134+
assertArrayEquals(null, getRow().getArray("TEXTA", String[].class));
135+
}
136+
130137
@Test
131138
public void roundtripInt() {
132139
Integer[][] a = new Integer[][]{

0 commit comments

Comments
 (0)
0