diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/STFactory.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/STFactory.java index 3aa5c787a3b..dd9ec4a76f8 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/STFactory.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/STFactory.java @@ -885,6 +885,7 @@ public void voteForValueWithType( } String oldVal = dataBackedSource.getValueAtDPath(distinguishingXpath); + String oldFullPath = dataBackedSource.getFullPathAtDPath(distinguishingXpath); // sanity check, should have been caught before if (readonly) { @@ -911,7 +912,8 @@ public void voteForValueWithType( } String newVal = dataBackedSource.getValueAtDPath(distinguishingXpath); - if (newVal != null && !newVal.equals(oldVal)) { + String newFullPath = dataBackedSource.getFullPathAtDPath(distinguishingXpath); + if (newVal != null && (!newVal.equals(oldVal) || !oldFullPath.equals(newFullPath))) { dataBackedSource.notifyListeners(distinguishingXpath); } } diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java index 9b694f20f05..09f2bc38388 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java @@ -394,6 +394,7 @@ public final void init(final ServletConfig config) throws ServletException { SurveyThreadManager.getExecutorService().submit(this::doStartup); klm = new KeepLoggedInManager(null); } catch (Throwable t) { + t.printStackTrace(); SurveyLog.logException(logger, t, "Initializing SurveyTool"); SurveyMain.busted("Error initializing SurveyTool.", t); } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/test/TestCache.java b/tools/cldr-code/src/main/java/org/unicode/cldr/test/TestCache.java index 6a1ae2d3eb9..022370ad85b 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/test/TestCache.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/test/TestCache.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Logger; import org.unicode.cldr.test.CheckCLDR.CheckStatus; import org.unicode.cldr.test.CheckCLDR.Options; import org.unicode.cldr.util.CLDRConfig; @@ -25,6 +26,8 @@ * @see XMLSource#addListener(org.unicode.cldr.util.XMLSource.Listener) */ public class TestCache implements XMLSource.Listener { + private static final Logger logger = Logger.getLogger(TestCache.class.getSimpleName()); + public class TestResultBundle { private final CheckCLDR cc = CheckCLDR.getCheckAll(getFactory(), nameMatcher); final CLDRFile file; @@ -95,11 +98,8 @@ public List getPossibleProblems() { /** Get the bundle for this test */ public TestResultBundle getBundle(CheckCLDR.Options options) { TestResultBundle b = testResultCache.getIfPresent(options); - if (DEBUG) { - if (b != null) { - System.err.println("Bundle refvalid: " + options + " -> " + (b != null)); - } - System.err.println("Bundle " + b + " for " + options + " in " + this.toString()); + if (b != null) { + logger.finest(() -> this + " Bundle refvalid: " + options); } if (b == null) { // ElapsedTimer et = new ElapsedTimer("New test bundle " + locale + " opt " + options); @@ -117,10 +117,12 @@ protected Factory getFactory() { /** construct a new TestCache with this factory. Intended for use from within Factory. */ public TestCache(Factory f) { this.factory = f; + logger.fine(() -> toString() + " - init(" + f + ")"); } /** Change which checks are run. Invalidates all caches. */ public void setNameMatcher(String nameMatcher) { + logger.finest(() -> toString() + " - setNameMatcher(" + nameMatcher + ")"); this.nameMatcher = nameMatcher; invalidateAllCached(); } @@ -137,6 +139,8 @@ public String toString() { "{" + this.getClass().getSimpleName() + super.toString() + + " F=" + + factory.getClass().getSimpleName() + " Size: " + testResultCache.size() + " ("); @@ -179,9 +183,7 @@ public void valueChanged(String xpath, XMLSource source) { * @param locale the CLDRLocale */ private void valueChangedInvalidateRecursively(String xpath, final CLDRLocale locale) { - if (DEBUG) { - System.err.println("BundDelLoc " + locale + " @ " + xpath); - } + logger.finer(() -> "BundDelLoc " + locale + " @ " + xpath); /* * Call self recursively for all sub-locales */ @@ -310,6 +312,7 @@ private static void updateExampleGeneratorCache(String xpath, CLDRLocale locale) /** Public for tests. Invalidate cache. */ public void invalidateAllCached() { + logger.fine(() -> toString() + " - invalidateAllCached()"); testResultCache.invalidateAll(); exampleGeneratorCache.invalidateAll(); } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/Factory.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/Factory.java index 0fee55f919d..913fb3f5944 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/Factory.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/Factory.java @@ -1,5 +1,6 @@ package org.unicode.cldr.util; +import com.google.common.base.Suppliers; import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -7,6 +8,7 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; +import java.util.function.Supplier; import org.unicode.cldr.test.TestCache; import org.unicode.cldr.util.CLDRFile.DraftStatus; import org.unicode.cldr.util.CLDRLocale.SublocaleProvider; @@ -338,16 +340,15 @@ public Set calculateSubLocalesOf(CLDRLocale locale, Set */ public abstract List getSourceDirectoriesForLocale(String localeName); - private final TestCache testCache; + /** thread-safe lazy load of TestCache */ + private Supplier testCache = Suppliers.memoize(() -> new TestCache(this)); /** subclass contructor */ - protected Factory() { - testCache = new TestCache(this); - } + protected Factory() {} /** get the TestCache owned by this Factory */ public final TestCache getTestCache() { - return testCache; + return testCache.get(); } /**