Index: trunk/src/org/openstreetmap/josm/actions/upload/ApiPreconditionCheckerHook.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/upload/ApiPreconditionCheckerHook.java	(revision 7528)
+++ trunk/src/org/openstreetmap/josm/actions/upload/ApiPreconditionCheckerHook.java	(revision 7529)
@@ -32,8 +32,5 @@
             // should be displayed.
             api.initialize(NullProgressMonitor.INSTANCE);
-            long maxNodes = 0;
-            if (api.getCapabilities().isDefined("waynodes", "maximum")) {
-                maxNodes = api.getCapabilities().getLong("waynodes","maximum");
-            }
+            long maxNodes = api.getCapabilities().getMaxWayNodes();
             if (maxNodes > 0) {
                 if( !checkMaxNodes(apiData.getPrimitivesToAdd(), maxNodes))
Index: trunk/src/org/openstreetmap/josm/io/Capabilities.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/Capabilities.java	(revision 7528)
+++ trunk/src/org/openstreetmap/josm/io/Capabilities.java	(revision 7529)
@@ -158,4 +158,8 @@
     }
 
+    private static void warnIllegalValue(String attr, String elem, Object val) {
+        Main.warn(tr("Illegal value of attribute ''{0}'' of element ''{1}'' in server capabilities. Got ''{2}''", attr, elem, val));
+    }
+
     /**
      * Returns the max number of objects in a changeset. -1 if either the capabilities
@@ -167,16 +171,41 @@
     public int getMaxChangesetSize() {
         String v = get("changesets", "maximum_elements");
-        if (v == null) return -1;
-        try {
-            int n = Integer.parseInt(v);
-            if (n <= 0) {
-                Main.warn(tr("Illegal value of attribute ''{0}'' of element ''{1}'' in server capabilities. Got ''{2}''", "changesets", "maximum_elements", n ));
-                return -1;
-            }
-            return n;
-        } catch (NumberFormatException e) {
-            Main.warn(tr("Illegal value of attribute ''{0}'' of element ''{1}'' in server capabilities. Got ''{2}''", "changesets", "maximum_elements", v ));
-            return -1;
-        }
+        if (v != null) {
+            try {
+                int n = Integer.parseInt(v);
+                if (n <= 0) {
+                    warnIllegalValue("changesets", "maximum_elements", n);
+                } else {
+                    return n;
+                }
+            } catch (NumberFormatException e) {
+                warnIllegalValue("changesets", "maximum_elements", v);
+            }
+        }
+        return -1;
+    }
+
+    /**
+     * Returns the max number of nodes in a way. -1 if either the capabilities
+     * don't include this parameter or if the parameter value is illegal (not a number,
+     * a negative number)
+     *
+     * @return the max number of nodes in a way
+     */
+    public long getMaxWayNodes() {
+        String v = get("waynodes", "maximum");
+        if (v != null) {
+            try {
+                Long n = Long.parseLong(v);
+                if (n <= 0) {
+                    warnIllegalValue("waynodes", "maximum", n);
+                } else {
+                    return n;
+                }
+            } catch (NumberFormatException e) {
+                warnIllegalValue("waynodes", "maximum", v);
+            }
+        }
+        return -1;
     }
 
