Index: src/org/openstreetmap/josm/io/OsmApi.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/org/openstreetmap/josm/io/OsmApi.java b/src/org/openstreetmap/josm/io/OsmApi.java
--- a/src/org/openstreetmap/josm/io/OsmApi.java	(revision 18777)
+++ b/src/org/openstreetmap/josm/io/OsmApi.java	(date 1690143256535)
@@ -247,7 +247,6 @@
     public void initialize(ProgressMonitor monitor, boolean fastFail) throws OsmTransferCanceledException, OsmApiInitializationException {
         if (initialized)
             return;
-        cancel = false;
         try {
             CapabilitiesCache cache = new CapabilitiesCache(monitor, fastFail);
             try {
@@ -617,12 +616,17 @@
 
     private void sleepAndListen(int retry, ProgressMonitor monitor) throws OsmTransferCanceledException {
         Logging.info(tr("Waiting 10 seconds ... "));
+        if (monitor != null) {
+            monitor.addCancelListener(this::cancel);
+        }
+
         for (int i = 0; i < 10; i++) {
             if (monitor != null) {
                 monitor.setCustomText(tr("Starting retry {0} of {1} in {2} seconds ...", getMaxRetries() - retry, getMaxRetries(), 10-i));
-            }
-            if (cancel)
-                throw new OsmTransferCanceledException("Operation canceled" + (i > 0 ? " in retry #"+i : ""));
+                if (monitor.isCanceled()) {
+                    throw new OsmTransferCanceledException("Operation canceled" + (i > 0 ? " in retry #"+i : ""));
+                }
+            }
             try {
                 Thread.sleep(1000);
             } catch (InterruptedException ex) {
Index: src/org/openstreetmap/josm/io/OsmConnection.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/org/openstreetmap/josm/io/OsmConnection.java b/src/org/openstreetmap/josm/io/OsmConnection.java
--- a/src/org/openstreetmap/josm/io/OsmConnection.java	(revision 18777)
+++ b/src/org/openstreetmap/josm/io/OsmConnection.java	(date 1690142965063)
@@ -48,7 +48,6 @@
 
     private static final String BASIC_AUTH = "Basic ";
 
-    protected boolean cancel;
     protected HttpClient activeConnection;
     protected OAuthParameters oauthParameters;
     protected IOAuthParameters oAuth20Parameters;
@@ -84,7 +83,6 @@
      * Cancels the connection.
      */
     public void cancel() {
-        cancel = true;
         synchronized (this) {
             if (activeConnection != null) {
                 activeConnection.disconnect();
@@ -132,15 +130,11 @@
         } catch (CredentialsAgentException e) {
             throw new OsmTransferException(e);
         }
-        if (response != null) {
-            if (response.isCanceled()) {
-                cancel = true;
-            } else {
-                String username = response.getUsername() == null ? "" : response.getUsername();
-                String password = response.getPassword() == null ? "" : String.valueOf(response.getPassword());
-                String token = username + ':' + password;
-                con.setHeader("Authorization", BASIC_AUTH + Base64.getEncoder().encodeToString(token.getBytes(StandardCharsets.UTF_8)));
-            }
+        if (response != null && !response.isCanceled()) {
+            String username = response.getUsername() == null ? "" : response.getUsername();
+            String password = response.getPassword() == null ? "" : String.valueOf(response.getPassword());
+            String token = username + ':' + password;
+            con.setHeader("Authorization", BASIC_AUTH + Base64.getEncoder().encodeToString(token.getBytes(StandardCharsets.UTF_8)));
         }
     }
 
@@ -292,13 +286,4 @@
                 throw new OsmTransferException(msg);
         }
     }
-
-    /**
-     * Replies true if this connection is canceled
-     *
-     * @return true if this connection is canceled
-     */
-    public boolean isCanceled() {
-        return cancel;
-    }
 }
