Changeset 6472 in josm for trunk


Ignore:
Timestamp:
2013-12-11T20:56:11+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #9417 - Validator tests are initialized trice

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r6370 r6472  
    6363
    6464/**
    65  *
    66  * A OSM data validator
     65 * A OSM data validator.
    6766 *
    6867 * @author Francisco R. Santos <frsantos@gmail.com>
     
    117116        OpeningHourTest.class // 2901 .. 2999
    118117    };
     118   
     119    private static Map<String, Test> allTestsMap;
     120    static {
     121        allTestsMap = new HashMap<String, Test>();
     122        for (Class<Test> testClass : allAvailableTests) {
     123            try {
     124                allTestsMap.put(testClass.getSimpleName(), testClass.newInstance());
     125            } catch (Exception e) {
     126                Main.error(e);
     127                continue;
     128            }
     129        }
     130    }
    119131
    120132    /**
     
    133145     * @return The directory of the plugin
    134146     */
    135     public static String getValidatorDir()
    136     {
     147    public static String getValidatorDir() {
    137148        return Main.pref.getPreferencesDir() + "validator/";
    138149    }
     
    202213    }
    203214
    204     /** Gets a map from simple names to all tests. */
     215    /**
     216     * Gets a map from simple names to all tests.
     217     * @return A map of all tests, indexed by the simple name of their Java class
     218     */
    205219    public static Map<String, Test> getAllTestsMap() {
    206         Map<String, Test> tests = new HashMap<String, Test>();
    207         for (Class<Test> testClass : allAvailableTests) {
    208             try {
    209                 Test test = testClass.newInstance();
    210                 tests.put(testClass.getSimpleName(), test);
    211             } catch (Exception e) {
    212                 e.printStackTrace();
    213                 continue;
    214             }
    215         }
    216         applyPrefs(tests, false);
    217         applyPrefs(tests, true);
    218         return tests;
     220        applyPrefs(allTestsMap, false);
     221        applyPrefs(allTestsMap, true);
     222        return new HashMap<String, Test>(allTestsMap);
    219223    }
    220224
Note: See TracChangeset for help on using the changeset viewer.