Subject: [pgjdbc/pgjdbc] PR #3493: chore: add ErrorProne verification to catch bugs ealier

From: "vlsi (@vlsi)" <[email-masked]>
Date: Wed, 22 Jan 2025 10:03:01 +0000

This adds verifications from error-prone so we could catch errors earlier.
I suggest we fail the build on javac warnings as well.

However, we could probably live with warnings in the test code. Otherwise there will be a lot of warnings when testing deprecated classes. As we deprecate method, the test code should better be intact so it ensures the behavior is kept.

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Wed, 22 Jan 2025 13:52:15 +0000

cool, great idea

---

From: "vlsi (@vlsi)" <[email-masked]>
Date: Fri, 24 Jan 2025 13:37:36 +0000

It looks like this is finalized.

In practice, errorprone does not significantly increase the build time, so it might be worth running it on every build. WDYT?

Currently, I configured it so it executes errorpone only when explicitly asked (e.g. `./gradlew -PenableErrorprone classes` or `./gradlew style`)

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Fri, 24 Jan 2025 14:02:22 +0000

Thanks, this looks like it will clean up a lot of things.

---

From: "vlsi (@vlsi)" <[email-masked]>
Date: Fri, 24 Jan 2025 14:53:48 +0000

> it will clean up a lot of things.

Just for the reference, ErrorProne does not fix issues. It only reports them and suggests fixes.

For example:

```
> Task :postgresql:compileJava
pgjdbc/pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java:1741: Note: [MethodCanBeStatic] A private method that does not reference the enclosing instance can be static
  private void checkPermission(SQLPermission sqlPermissionNetworkTimeout) {
  ^
    (see https://errorprone.info/bugpattern/MethodCanBeStatic)
  Did you mean 'private static void checkPermission(SQLPermission sqlPermissionNetworkTimeout) {'?
```

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Sat, 25 Jan 2025 12:05:38 +0000

That's a lot of work! Thanks