HADOOP-15686. Supress bogus AbstractWadlGeneratorGrammarGenerator in KMS stderr. Contributed by Wei-Chiu Chuang.

Reviewed-by: Xiaoyu Yao <xyao@apache.org>
(cherry picked from commit 9664b9c7a6)
This commit is contained in:
Wei-Chiu Chuang 2019-11-18 13:50:07 -08:00
parent 4c79e2a02b
commit bd2f79cfd8
3 changed files with 19 additions and 1 deletions

View File

@ -37,6 +37,7 @@ import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.VersionInfo; import org.apache.hadoop.util.VersionInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;
@InterfaceAudience.Private @InterfaceAudience.Private
public class KMSWebApp implements ServletContextListener { public class KMSWebApp implements ServletContextListener {
@ -80,6 +81,11 @@ public class KMSWebApp implements ServletContextListener {
private static KMSAudit kmsAudit; private static KMSAudit kmsAudit;
private static KeyProviderCryptoExtension keyProviderCryptoExtension; private static KeyProviderCryptoExtension keyProviderCryptoExtension;
static {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
}
@Override @Override
public void contextInitialized(ServletContextEvent sce) { public void contextInitialized(ServletContextEvent sce) {
try { try {

View File

@ -614,7 +614,18 @@ public class TestKMS {
@Test @Test
public void testStartStopHttpPseudo() throws Exception { public void testStartStopHttpPseudo() throws Exception {
// Make sure bogus errors don't get emitted.
GenericTestUtils.LogCapturer logs =
GenericTestUtils.LogCapturer.captureLogs(LoggerFactory.getLogger(
"com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator"));
try {
testStartStop(false, false); testStartStop(false, false);
} finally {
logs.stopCapturing();
}
assertFalse(logs.getOutput().contains(
"Couldn't find grammar element for class"));
} }
@Test @Test

View File

@ -26,6 +26,7 @@ log4j.rootLogger=INFO, stdout
log4j.logger.org.apache.hadoop.conf=ERROR log4j.logger.org.apache.hadoop.conf=ERROR
log4j.logger.org.apache.hadoop.crytpo.key.kms.server=ALL log4j.logger.org.apache.hadoop.crytpo.key.kms.server=ALL
log4j.logger.com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator=OFF log4j.logger.com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator=OFF
log4j.logger.com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator=OFF
log4j.logger.org.apache.hadoop.security=OFF log4j.logger.org.apache.hadoop.security=OFF
log4j.logger.org.apache.directory.server.core=OFF log4j.logger.org.apache.directory.server.core=OFF
log4j.logger.org.apache.hadoop.util.NativeCodeLoader=OFF log4j.logger.org.apache.hadoop.util.NativeCodeLoader=OFF