impossibl / pgjdbc-ng

A new JDBC driver for PostgreSQL aimed at supporting the advanced features of JDBC and Postgres
https://impossibl.github.io/pgjdbc-ng
Other
600 stars 108 forks source link

Second and subsequent calls to free() on PGBuffersArray throw NPE rather than being no-op #562

Open JTEgan opened 3 years ago

JTEgan commented 3 years ago

The PGBuffersArray class implements java.sql.Array, and the doc for the free() method in that interface states:

If free is called multiple times, the subsequent calls to free are treated as a no-op.

In the pgjdbc-ng implementation, the second call results in a NullPointerException:

java.lang.NullPointerException: null at com.impossibl.postgres.jdbc.PGBuffersArray.free(PGBuffersArray.java:294) at...

I have a small change to address the issue, will submit a PR shortly.