pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: pdewacht (@pdewacht) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3798: getNotifications() behavior does not match documentation
Date: Tue, 16 Sep 2025 15:23:26 +0000
Message-ID: <[email protected]> (raw)

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/...

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-8ee30bec696495...).


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

```


view thread (4+ 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] issue #3798: getNotifications() behavior does not match documentation
  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