[apex] Really fix ApexLexer logging

The fix introduced with #503 (fba00843bb523cbeb06157c4793ffc29bd9a6ee7)
was incomplete and didn't work:
* The logger uses the full class name insteand of simple name
* After we changed the log level of the logger, the logger
  could be garbage collected before ApexLexer retrieves it and
  thus the configuration could be lost
This commit is contained in:
Andreas Dangel
2019-11-02 08:18:10 +01:00
parent bfa2d1e872
commit c75e2bd000
3 changed files with 10 additions and 2 deletions

View File

@ -16,6 +16,9 @@ This is a {{ site.pmd.release_type }} release.
### Fixed Issues
* apex
* [#2092](https://github.com/pmd/pmd/issues/2092): \[apex] ApexLexer logs visible when Apex is the selected language upon starting the designer
### API Changes
### External Contributions

View File

@ -10,6 +10,9 @@ import java.util.logging.Logger;
import apex.jorje.parser.impl.BaseApexLexer;
public final class ApexJorjeLogging {
// note: that's a static/strong reference in order to avoid that the logger is garbage collected
private static final Logger APEX_LOGGER = Logger.getLogger(BaseApexLexer.class.getName());
private ApexJorjeLogging() {
// this is a utility class
}
@ -19,7 +22,6 @@ public final class ApexJorjeLogging {
// Jul 16, 2017 8:49:56 PM apex.jorje.parser.impl.BaseApexLexer dedupe
// INFORMATION: Deduped array ApexLexer.DFA23_transition. Found 7927114 shorts which is 15MB not
// including array overhead. Removed 7204963 shorts which is 13MB not counting array overhead. Took 18ms.
Logger log = Logger.getLogger(BaseApexLexer.class.getSimpleName());
log.setLevel(Level.WARNING);
APEX_LOGGER.setLevel(Level.WARNING);
}
}

View File

@ -42,5 +42,8 @@ public class AllRulesIT extends AbstractBinaryDistributionTest {
result.assertNoError("Use of deprecated attribute");
result.assertNoErrorInReport("Error while processing");
result.assertNoErrorInReport("Error while parsing");
// See bug #2092: [apex] ApexLexer logs visible when Apex is the selected language upon starting the designer
result.assertNoError("Deduped array ApexLexer");
}
}