gnodet-bot commented on code in PR #30148:
URL: https://github.com/apache/camel/pull/30148#discussion_r4583247134
##########
components/camel-oauth/src/test/java/org/apache/camel/test/oauth/SSLCertTrustTest.java:
##########
@@ -45,10 +46,19 @@ class SSLCertTrustTest extends AbstractKeycloakTest {
private static final int CONNECT_TIMEOUT_MS = 10_000;
private static final int READ_TIMEOUT_MS = 10_000;
+ // Required by abstract contract in AbstractKeycloakTest; not used by this
test (localHttpsPort is used instead).
+ static final AvailablePortFinder.Port SERVER_PORT =
AvailablePortFinder.find();
+ static final int PORT = SERVER_PORT.getPort();
+
private static SSLServerSocket serverSocket;
private static Thread serverThread;
private static int localHttpsPort;
+ @Override
+ protected int getPort() {
+ return PORT;
+ }
Review Comment:
💡 **Nit:** `getPort()` returns `PORT` from a dedicated
`AvailablePortFinder.find()` allocation, but this test never calls
`setupKeycloakRealm()` / `getAppBaseUrl()` / `getPort()` — `localHttpsPort`
(bound to port `0`) is used exclusively. The `SERVER_PORT` / `PORT` fields are
dead weight that waste a port reservation.
Consider returning `localHttpsPort` instead and removing the two fields:
```java
// Remove SERVER_PORT and PORT fields, then:
@Override
protected int getPort() {
return localHttpsPort;
}
```
(Note: `localHttpsPort` is set in `@BeforeAll startLocalHttpsServer()`
before any test accesses it, so this is safe — `getPort()` is never called
before the server starts, since `setupKeycloakRealm()` is not invoked by this
test at all.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]