HDFS-11050. Change log level to 'warn' when ssl initialization fails and defaults to DEFAULT_TIMEOUT_CONN_CONFIGURATOR. Contributed by Kuhu Shukla.
This commit is contained in:
parent
24a83febea
commit
ce6bbfb23c
|
@ -95,7 +95,7 @@ public class URLConnectionFactory {
|
||||||
try {
|
try {
|
||||||
conn = newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf);
|
conn = newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.debug(
|
LOG.warn(
|
||||||
"Cannot load customized ssl related configuration. Fallback to" +
|
"Cannot load customized ssl related configuration. Fallback to" +
|
||||||
" system-generic settings.",
|
" system-generic settings.",
|
||||||
e);
|
e);
|
||||||
|
|
|
@ -22,11 +22,15 @@ import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.security.authentication.client.ConnectionConfigurator;
|
import org.apache.hadoop.security.authentication.client.ConnectionConfigurator;
|
||||||
|
import org.apache.hadoop.security.ssl.SSLFactory;
|
||||||
|
import org.apache.hadoop.test.GenericTestUtils;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public final class TestURLConnectionFactory {
|
public final class TestURLConnectionFactory {
|
||||||
|
|
||||||
|
@ -47,4 +51,17 @@ public final class TestURLConnectionFactory {
|
||||||
fc.openConnection(u);
|
fc.openConnection(u);
|
||||||
Assert.assertEquals(1, conns.size());
|
Assert.assertEquals(1, conns.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSSLInitFailure() throws Exception {
|
||||||
|
Configuration conf = new Configuration();
|
||||||
|
conf.set(SSLFactory.SSL_HOSTNAME_VERIFIER_KEY, "foo");
|
||||||
|
GenericTestUtils.LogCapturer logs =
|
||||||
|
GenericTestUtils.LogCapturer.captureLogs(
|
||||||
|
LoggerFactory.getLogger(URLConnectionFactory.class));
|
||||||
|
URLConnectionFactory.newDefaultURLConnectionFactory(conf);
|
||||||
|
Assert.assertTrue("Expected log for ssl init failure not found!",
|
||||||
|
logs.getOutput().contains(
|
||||||
|
"Cannot load customized ssl related configuration"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue