diff --git a/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java b/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java index 6c645b8..23ba79c 100644 --- a/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java +++ b/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java @@ -218,6 +218,7 @@ public static TServerSocket getServerSocket(String hiveHost, int portNum) throws TTransportException { InetSocketAddress serverAddress; if (hiveHost == null || hiveHost.isEmpty()) { + // Wildcard bind serverAddress = new InetSocketAddress(portNum); } else { serverAddress = new InetSocketAddress(hiveHost, portNum); @@ -226,25 +227,26 @@ public static TServerSocket getServerSocket(String hiveHost, int portNum) } public static TServerSocket getServerSSLSocket(String hiveHost, int portNum, String keyStorePath, - String keyStorePassWord, List sslVersionBlacklist) - throws TTransportException, UnknownHostException { + String keyStorePassWord, List sslVersionBlacklist) throws TTransportException, + UnknownHostException { TSSLTransportFactory.TSSLTransportParameters params = - new TSSLTransportFactory.TSSLTransportParameters(); + new TSSLTransportFactory.TSSLTransportParameters(); params.setKeyStore(keyStorePath, keyStorePassWord); - - InetAddress serverAddress; + InetSocketAddress serverAddress; if (hiveHost == null || hiveHost.isEmpty()) { - serverAddress = InetAddress.getLocalHost(); + // Wildcard bind + serverAddress = new InetSocketAddress(portNum); } else { - serverAddress = InetAddress.getByName(hiveHost); + serverAddress = new InetSocketAddress(hiveHost, portNum); } - TServerSocket thriftServerSocket = TSSLTransportFactory.getServerSocket(portNum, 0, serverAddress, params); + TServerSocket thriftServerSocket = + TSSLTransportFactory.getServerSocket(portNum, 0, serverAddress.getAddress(), params); if (thriftServerSocket.getServerSocket() instanceof SSLServerSocket) { List sslVersionBlacklistLocal = new ArrayList(); for (String sslVersion : sslVersionBlacklist) { sslVersionBlacklistLocal.add(sslVersion.trim().toLowerCase()); } - SSLServerSocket sslServerSocket = (SSLServerSocket)thriftServerSocket.getServerSocket(); + SSLServerSocket sslServerSocket = (SSLServerSocket) thriftServerSocket.getServerSocket(); List enabledProtocols = new ArrayList(); for (String protocol : sslServerSocket.getEnabledProtocols()) { if (sslVersionBlacklistLocal.contains(protocol.toLowerCase())) { @@ -254,7 +256,8 @@ public static TServerSocket getServerSSLSocket(String hiveHost, int portNum, Str } } sslServerSocket.setEnabledProtocols(enabledProtocols.toArray(new String[0])); - LOG.info("SSL Server Socket Enabled Protocols: " + Arrays.toString(sslServerSocket.getEnabledProtocols())); + LOG.info("SSL Server Socket Enabled Protocols: " + + Arrays.toString(sslServerSocket.getEnabledProtocols())); } return thriftServerSocket; } diff --git a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java index cc974db..3a8ae70 100644 --- a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java +++ b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java @@ -55,7 +55,7 @@ protected static HiveAuthFactory hiveAuthFactory; protected int portNum; - protected InetAddress serverAddress; + protected InetAddress serverIPAddress; protected String hiveHost; protected TServer server; protected org.eclipse.jetty.server.Server httpServer; @@ -85,9 +85,9 @@ public synchronized void init(HiveConf hiveConf) { } try { if (hiveHost != null && !hiveHost.isEmpty()) { - serverAddress = InetAddress.getByName(hiveHost); + serverIPAddress = InetAddress.getByName(hiveHost); } else { - serverAddress = InetAddress.getLocalHost(); + serverIPAddress = InetAddress.getLocalHost(); } } catch (UnknownHostException e) { throw new ServiceException(e); @@ -153,8 +153,8 @@ public int getPortNumber() { return portNum; } - public InetAddress getServerAddress() { - return serverAddress; + public InetAddress getServerIPAddress() { + return serverIPAddress; } @Override diff --git a/service/src/java/org/apache/hive/service/server/HiveServer2.java b/service/src/java/org/apache/hive/service/server/HiveServer2.java index 4199f0f..17e1d85 100644 --- a/service/src/java/org/apache/hive/service/server/HiveServer2.java +++ b/service/src/java/org/apache/hive/service/server/HiveServer2.java @@ -249,10 +249,10 @@ private void setRegisteredWithZooKeeper(boolean registeredWithZooKeeper) { } private String getServerInstanceURI(HiveConf hiveConf) throws Exception { - if ((thriftCLIService == null) || (thriftCLIService.getServerAddress() == null)) { + if ((thriftCLIService == null) || (thriftCLIService.getServerIPAddress() == null)) { throw new Exception("Unable to get the server address; it hasn't been initialized yet."); } - return thriftCLIService.getServerAddress().getHostName() + ":" + return thriftCLIService.getServerIPAddress().getHostName() + ":" + thriftCLIService.getPortNumber(); }