Skip to content

Commit

Permalink
test: fix API usage in NotifyTest
Browse files Browse the repository at this point in the history
Previously the test waited for a non-null getNotifications() array,
however, the method never return null values.
The test should wait for a non-empty array instead.
  • Loading branch information
vlsi committed Jun 9, 2022
1 parent 67fda95 commit 3b13db2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pgjdbc/src/test/java/org/postgresql/test/jdbc2/NotifyTest.java
Expand Up @@ -81,13 +81,13 @@ public void testAsyncNotify() throws Exception {
// Wait a bit to let the notify come through... Changed this so the test takes ~2 seconds
// less to run and is still as effective.
PGNotification[] notifications = null;
try {
int retries = 300;
while (retries-- > 0
&& (notifications = conn.unwrap(PGConnection.class).getNotifications()) == null ) {
Thread.sleep(100);
PGConnection connection = conn.unwrap(PGConnection.class);
for (int i = 0; i < 3000; i++) {
notifications = connection.getNotifications();
if (notifications.length > 0) {
break;
}
} catch (InterruptedException ie) {
Thread.sleep(10);
}

assertNotNull("Notification is expected to be delivered when subscription was created"
Expand Down

0 comments on commit 3b13db2

Please sign in to comment.