Ignore:
Timestamp:
2018-10-03T20:39:59+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #16797 - NPE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r14284 r14290  
    4141import java.util.List;
    4242import java.util.Map;
     43import java.util.Objects;
    4344import java.util.Set;
    4445import java.util.TreeSet;
     
    277278    protected String subdir;
    278279    /** image file name */
    279     protected String name;
     280    protected final String name;
    280281    /** archive file to take image from */
    281282    protected File archive;
     
    327328     * @param name the name of the image. If it does not end with '.png' or '.svg',
    328329     * both extensions are tried.
     330     * @throws NullPointerException if name is null
    329331     */
    330332    public ImageProvider(String subdir, String name) {
    331333        this.subdir = subdir;
    332         this.name = name;
     334        this.name = Objects.requireNonNull(name, "name");
    333335    }
    334336
     
    337339     * @param name the name of the image. If it does not end with '.png' or '.svg',
    338340     * both extensions are tried.
     341     * @throws NullPointerException if name is null
    339342     */
    340343    public ImageProvider(String name) {
    341         this.name = name;
     344        this.name = Objects.requireNonNull(name, "name");
    342345    }
    343346
     
    863866            // This method is called from different thread and modifying HashMap concurrently can result
    864867            // for example in loops in map entries (ie freeze when such entry is retrieved)
    865             if (name == null)
    866                 return null;
    867868
    868869            String prefix = isDisabled ? "dis:" : "";
     
    20892090        return ("ImageProvider ["
    20902091                + (dirs != null && !dirs.isEmpty() ? "dirs=" + dirs + ", " : "") + (id != null ? "id=" + id + ", " : "")
    2091                 + (subdir != null && !subdir.isEmpty() ? "subdir=" + subdir + ", " : "") + (name != null ? "name=" + name + ", " : "")
     2092                + (subdir != null && !subdir.isEmpty() ? "subdir=" + subdir + ", " : "") + "name=" + name + ", "
    20922093                + (archive != null ? "archive=" + archive + ", " : "")
    20932094                + (inArchiveDir != null && !inArchiveDir.isEmpty() ? "inArchiveDir=" + inArchiveDir : "") + ']').replaceAll(", \\]", "]");
Note: See TracChangeset for help on using the changeset viewer.