Index: /trunk/src/org/openstreetmap/josm/io/OsmApi.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 18531)
+++ /trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 18532)
@@ -13,4 +13,7 @@
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
+import java.net.NoRouteToHostException;
+import java.net.PortUnreachableException;
+import java.net.SocketException;
 import java.net.SocketTimeoutException;
 import java.net.URL;
@@ -769,6 +772,16 @@
                     throw new OsmApiException(retCode, errorHeader, errorBody);
                 }
-            } catch (SocketTimeoutException | ConnectException e) {
-                if (retries-- > 0) {
+            } catch (SocketException | SocketTimeoutException e) {
+                /*
+                 * See #22160. While it is only thrown once in JDK sources, it does have subclasses.
+                 * We check for those first, the explicit non-child exception, and then for the message.
+                 */
+                boolean validException = e instanceof SocketTimeoutException
+                        || e instanceof ConnectException
+                        || e instanceof NoRouteToHostException
+                        || e instanceof PortUnreachableException
+                        || (e.getClass().equals(SocketException.class) &&
+                            "Unexpected end of file from server".equals(e.getMessage()));
+                if (retries-- > 0 && validException) {
                     continue;
                 }
