bug6172: be more defensive with quitting the WebDriver, catching exception

This commit is contained in:
Axel Uhl committed 2025-10-27 15:28:10 +01:00
1 parent f1749f4671
commit 1eda5361b9
3 files changed
+11 -4

No files matched your search

@@ -589,7 +589,7 @@ public class MarkPassingCalculator {
// creation matches that of this mark passing calculator's race; load instead of compute
updateMarkPassingsFromRegistry();
queue.clear();
stop(); // ensures an end marker is written to queue to the queue.take() call in Listen.run() will always get unblocked after the queue.clear() above
stop(); // ensures an end marker is written to queue so the queue.take() call in Listen.run() will always get unblocked after the queue.clear() above
suspended = false;
} else {
suspended = false;
@@ -5,6 +5,7 @@ import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.logging.Logger;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
@@ -21,6 +22,8 @@ import org.openqa.selenium.support.ui.WebDriverWait;
* Riccardo Nimser (D049941)
*/
public class WindowManager {
private static final Logger logger = Logger.getLogger(WindowManager.class.getName());
private WebDriverWindow defaultWindow;
private final Set<WebDriverWindow> allWindows = new HashSet<>();
private WebDriver driver;
@@ -144,7 +147,13 @@ public class WindowManager {
public void closeAllWindows() {
forEachOpenedWindow(WebDriverWindow::close);
if (driver != null) {
driver.quit();
try {
driver.close();
driver.quit();
} catch (org.openqa.selenium.NoSuchSessionException e) {
logger.warning("The Selenium driver seems to have already been closed");
// Already closed — ignore
}
driver = null;
}
}
@@ -290,7 +290,6 @@ public class JumpyTrackSmootheningTest {
addFixedMarkPassingToRaceLog("2020-10-14T18:21:38Z", gallagherZelenka, 4, raceLog);
trackedRace.setStatus(new TrackedRaceStatusImpl(TrackedRaceStatusEnum.LOADING, 0.0));
final DynamicGPSFixTrack<Competitor, GPSFixMoving> competitorTrackInRace = trackedRace.getTrack(gallagherZelenka);
// TODO switch race into suspended mode to avoid updates during mass fix insertion:
competitorTrack.lockForRead();
try {
for (final GPSFixMoving fix : competitorTrack.getRawFixes()) {
@@ -300,7 +299,6 @@ public class JumpyTrackSmootheningTest {
competitorTrack.unlockAfterRead();
}
trackedRace.setStatus(new TrackedRaceStatusImpl(TrackedRaceStatusEnum.TRACKING, 1.0));
// TODO resume race
return trackedRace;
}