Subject: [pgjdbc/pgjdbc] issue #3798: getNotifications() behavior does not match documentation

From: "pdewacht (@pdewacht)" <[email-masked]>
Date: Tue, 16 Sep 2025 15:23:26 +0000

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);
        }
    }
}

```

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Tue, 16 Sep 2025 18:25:39 +0000

could you provide a PR ?

---

From: "pdewacht (@pdewacht)" <[email-masked]>
Date: Tue, 16 Sep 2025 18:59:21 +0000

A PR to fix the documentation, or a PR to fix the code? Either way is fine for me.

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Tue, 16 Sep 2025 19:20:56 +0000

Documentation, as you say it's been like that for a while.