Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion java/src/org/openqa/selenium/net/UrlChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ public void waitUntilUnavailable(long timeout, TimeUnit unit, final URL url)
"Timed out waiting for %s to become unavailable after %d ms",
url, System.currentTimeMillis() - start),
e);
} catch (InterruptedException | ExecutionException e) {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
Comment on lines +157 to 161

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. waituntilunavailable missing javadoc 📘 Rule violation ✧ Quality

The modified public method waitUntilUnavailable(long timeout, TimeUnit unit, URL url) has no
Javadoc block, so its parameters and TimeoutException contract are undocumented. This violates the
requirement for complete Javadoc on changed public API methods.
Agent Prompt
## Issue description
A changed public method `waitUntilUnavailable(...)` lacks a Javadoc block and therefore does not document purpose, `@param` tags, or the `@throws` contract.

## Issue Context
This PR modifies the behavior of `UrlChecker.waitUntilUnavailable`, so it is in-scope for the “complete Javadoc on public API methods” requirement.

## Fix Focus Areas
- java/src/org/openqa/selenium/net/UrlChecker.java[108-114]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

}
}
Expand Down
29 changes: 29 additions & 0 deletions java/test/org/openqa/selenium/net/UrlCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,33 @@ public void cleanup() {
safelyCall(() -> server.stop());
safelyCall(executorService::shutdownNow);
}

@Test
void waitUntilUnavailablePreservesInterruptStatus() throws Exception {
Thread caller = Thread.currentThread();
Thread interrupter =
new Thread(
() -> {
try {
Thread.sleep(500);
} catch (InterruptedException ignored) {
}
caller.interrupt();
});
interrupter.start();

boolean threw = false;
boolean preserved = false;
try {
urlChecker.waitUntilUnavailable(10, TimeUnit.SECONDS, url);
} catch (RuntimeException expected) {
threw = true;
preserved = Thread.currentThread().isInterrupted();
Thread.interrupted();
}
interrupter.join();

assertThat(threw).isTrue();
assertThat(preserved).isTrue();
}
Comment on lines +106 to +133

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Interrupt test doesn’t block 🐞 Bug ≡ Correctness

waitUntilUnavailablePreservesInterruptStatus calls waitUntilUnavailable while the
NettyAppServer created in @BeforeEach is never started, so waitUntilUnavailable can return
immediately on IOException and never throw the expected RuntimeException. As written, the test
can fail (no exception thrown) and does not reliably validate that the interrupt status is preserved
during a blocking wait.
Agent Prompt
## Issue description
The new test intends to verify that interrupt status is preserved when `waitUntilUnavailable` is interrupted while blocked, but it calls `waitUntilUnavailable` when the server is not running. Because `waitUntilUnavailable` treats connection `IOException` as “unavailable” and returns immediately, the test often won’t block long enough to be interrupted and therefore won’t throw the expected `RuntimeException`.

## Issue Context
`@BeforeEach` creates `this.server` and `this.url` but does not start the server. In `UrlChecker.waitUntilUnavailable`, an `IOException` while connecting returns success immediately.

## Fix Focus Areas
- java/test/org/openqa/selenium/net/UrlCheckerTest.java[42-57]
- java/test/org/openqa/selenium/net/UrlCheckerTest.java[106-133]
- java/src/org/openqa/selenium/net/UrlChecker.java[112-163]

## Suggested fix
In `waitUntilUnavailablePreservesInterruptStatus`, start the server (and optionally call `waitUntilAvailable` to ensure it is serving HTTP 200) before invoking `waitUntilUnavailable`, and keep the server running so `waitUntilUnavailable` blocks until the interrupter interrupts the calling thread. Also ensure cleanup (joining interrupter and clearing interrupt) happens even if assertions fail (e.g., via `try/finally`).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

}
Loading