Message-ID: From: "pdewacht (@pdewacht)" To: "pgjdbc/pgjdbc" Date: Tue, 16 Sep 2025 15:23:26 +0000 Subject: [pgjdbc/pgjdbc] issue #3798: getNotifications() behavior does not match documentation List-Id: X-GitHub-Author-Id: 223495 X-GitHub-Author-Login: pdewacht X-GitHub-Issue: 3798 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: closed X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3798 Content-Type: text/plain; charset=utf-8 The two variants of the `PGNotification.getNotifications()` method are documented to return null if there are no notifications: https://github.com/pgjdbc/pgjdbc/blob/a3be9d5ec7efe18e88e44f1637c459eb2bb4cc15/pgjdbc/src/main/java/org/postgresql/PGConnection.java#L54-L76 In fact they return an empty array. It seems the code to implement the 'return null' behavior was unintentionally removed in [529e5dc3a](https://github.com/pgjdbc/pgjdbc/commit/529e5dc3a8f071ad4946daf3bde1422c21a99524#diff-8ee30bec696495ec5763a3e1c1b216776efc124729f72e18dbaa35064af0aef0R1109). Since this has been broken for a while, it might be better to just update the documentation to match the current behavior. **Driver Version?** 42.7.7 **To Reproduce** ``` import java.sql.Connection; import java.sql.DriverManager; import java.util.Properties; import org.postgresql.PGConnection; public class TestGetNotificationsNullResult { public static void main(String []args) throws Exception { String url = "jdbc:postgresql://localhost:5432/test"; Properties props = new Properties(); props.setProperty("user", "test"); props.setProperty("password", "test"); try (Connection conn = DriverManager.getConnection(url, props)) { var notifications = conn.unwrap(PGConnection.class).getNotifications(); System.out.println("Expecting null: " + notifications); } } } ```