Skip to content

Commit

Permalink
CLDR-17320 check fixes to avoid stack traces (#3947)
Browse files Browse the repository at this point in the history
  • Loading branch information
srl295 authored Aug 7, 2024
1 parent 6758e83 commit 37adba7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ public CheckCLDR handleCheck(

private void checkParse(
String path, String fullPath, String value, Options options, List<CheckStatus> result) {
if (value == null) {
CheckStatus message =
new CheckStatus()
.setCause(this)
.setMainType(CheckStatus.errorType)
.setSubtype(Subtype.badParseLenient)
.setMessage("null value");
result.add(message);
return;
}
try {
XPathParts oparts = XPathParts.getFrozenInstance(path);
// only thing we do is make sure that the sample is in the value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ private void checkListPatterns(String path, String value, List<CheckStatus> resu
// ldml/listPatterns/listPattern[@type="standard-short"]/listPatternPart[@type="2"]
if (path.startsWith("//ldml/listPatterns/listPattern")) {
XPathParts parts = XPathParts.getFrozenInstance(path);
if (parts.containsElement("alias")) return; // skip alias XPaths
// check order, {0} must be before {1}

switch (parts.getAttributeValue(-1, "type")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,26 +469,7 @@ public void TestFullErrors() {
checkLocale(test, localeID, "?", null);
}

/** adjust the logging level of checks */
public java.util.logging.Level pushCheckLevel() {
java.util.logging.Level oldLevel = null;
if (logKnownIssue(
"CLDR-17320",
"turning off CheckCLDR logging to avoid thousands of log messages, please fix internal stack traces")) {
oldLevel = CheckCLDR.setLoggerLevel(java.util.logging.Level.OFF);
}
return oldLevel;
}

/** undo the effect of a pushCheckLevel */
public void popCheckLevel(java.util.logging.Level oldLevel) {
if (oldLevel != null) {
CheckCLDR.setLoggerLevel(oldLevel);
}
}

public void TestAllLocales() {
java.util.logging.Level oldLevel = pushCheckLevel();
CheckCLDR test = CheckCLDR.getCheckAll(factory, INDIVIDUAL_TESTS);
CheckCLDR.setDisplayInformation(english);
Set<String> unique = new HashSet<>();
Expand All @@ -508,18 +489,14 @@ public void TestAllLocales() {
// (And in fact this test seems faster without it)
locales.forEach(locale -> checkLocale(test, locale, null, unique));
logln("Count:\t" + locales.size());
popCheckLevel(oldLevel);
}

public void TestA() {
final java.util.logging.Level oldLevel = pushCheckLevel();

CheckCLDR test = CheckCLDR.getCheckAll(factory, INDIVIDUAL_TESTS);
CheckCLDR.setDisplayInformation(english);
Set<String> unique = new HashSet<>();

checkLocale(test, "ko", null, unique);
popCheckLevel(oldLevel);
}

public void checkLocale(
Expand Down

0 comments on commit 37adba7

Please sign in to comment.