Skip to content

Commit

Permalink
CLDR-17320 check fixes to avoid stack traces
Browse files Browse the repository at this point in the history
- update CheckExemplars parseLenient to error instead of crash on null
- update CheckPlaceHolders to skip aliases instead of crashing
- remove the logknownissue which was to suppress the crash stack traces
  • Loading branch information
srl295 committed Aug 7, 2024
1 parent 7e41fa3 commit f52ec2e
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 f52ec2e

Please sign in to comment.