### Eclipse Workspace Patch 1.0
#P josm
diff --git src/org/openstreetmap/josm/gui/layer/geoimage/WikimediaCommonsEntry.java src/org/openstreetmap/josm/gui/layer/geoimage/WikimediaCommonsEntry.java
index 8df45ae..8aa4e61 100644
--- src/org/openstreetmap/josm/gui/layer/geoimage/WikimediaCommonsEntry.java
+++ src/org/openstreetmap/josm/gui/layer/geoimage/WikimediaCommonsEntry.java
@@ -3,38 +3,42 @@
 
 import java.net.MalformedURLException;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Objects;
 
 import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.tools.JosmRuntimeException;
 import org.openstreetmap.josm.tools.Mediawiki;
 
 /**
  * A geocoded image from <a href="https://commons.wikimedia.org/">Wikimedia Commons</a>
  */
 class WikimediaCommonsEntry extends ImageEntry {
+    private static final String COMMONS_BASE_URL = "https://upload.wikimedia.org/wikipedia/commons";
     private final String title;
 
     WikimediaCommonsEntry(String title, LatLon latLon) {
-        this.title = title.replaceFirst("^File:", "").replace(" ", "_");
-        setPos(latLon);
+        Objects.requireNonNull(title, "Title must not be null");
+        this.title = title.trim()
+                .replaceFirst("^(?i)File:", "")
+                .replace("\\s+", "_");
+        
+        if (latLon != null) {
+            setPos(latLon);
+        }
     }
 
     @Override
     protected URL getImageUrl() throws MalformedURLException {
-        return new URL(Mediawiki.getImageUrl("https://upload.wikimedia.org/wikipedia/commons", title));
+        try {
+            return getImageURI().toURL();
+        } catch (IllegalArgumentException | MalformedURLException e) {
+            throw new MalformedURLException("Invalid Commons URL for '" + title + "': " + e.getMessage());
+        }
     }
 
     @Override
     public URI getImageURI() {
-        try {
-            return new URI(Mediawiki.getImageUrl("https://upload.wikimedia.org/wikipedia/commons", this.title));
-        } catch (URISyntaxException e) {
-            // This should never happen.
-            throw new JosmRuntimeException(this.toString(), e);
-        }
+        return URI.create(Mediawiki.getImageUrl(COMMONS_BASE_URL, title));
     }
 
     @Override
@@ -44,21 +48,29 @@
 
     @Override
     public String toString() {
-        return "File:" + title;
+        return getDisplayName();
     }
 
     @Override
     public int hashCode() {
-        return 31 * super.hashCode() + Objects.hash(title);
+        return 31 * super.hashCode() + Objects.hash(title);
     }
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-        if (!super.equals(obj) || getClass() != obj.getClass())
+        if (this == obj) {
+            return true;
+        }
+        
+        if (obj == null || getClass() != obj.getClass()) {
             return false;
-        WikimediaCommonsEntry other = (WikimediaCommonsEntry) obj;
+        }
+        
+        if (!super.equals(obj)) {
+            return false;
+        }
+        
+        final WikimediaCommonsEntry other = (WikimediaCommonsEntry) obj;
         return Objects.equals(title, other.title);
     }
 }
