HIVE-12981 : ThriftCLIService uses incompatible getShortName() implementation (Bolke de Bruin, reviewed by Sergey Shelukhin)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/2f8175bd Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/2f8175bd Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/2f8175bd Branch: refs/heads/branch-1.2 Commit: 2f8175bd426945dab5b2040d387ffa3c4944b904 Parents: 194efa9 Author: Sergey Shelukhin <[email protected]> Authored: Wed Feb 17 19:36:22 2016 -0800 Committer: Sergey Shelukhin <[email protected]> Committed: Wed Feb 17 19:36:37 2016 -0800 ---------------------------------------------------------------------- .../hive/service/cli/thrift/ThriftCLIService.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/2f8175bd/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java ---------------------------------------------------------------------- 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 5a0f1c8..ae98e4a 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 @@ -31,6 +31,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; +import org.apache.hadoop.hive.shims.HadoopShims.KerberosNameShim; +import org.apache.hadoop.hive.shims.ShimLoader; import org.apache.hive.service.AbstractService; import org.apache.hive.service.ServiceException; import org.apache.hive.service.ServiceUtils; @@ -343,7 +345,7 @@ public abstract class ThriftCLIService extends AbstractService implements TCLISe * @return * @throws HiveSQLException */ - private String getUserName(TOpenSessionReq req) throws HiveSQLException { + private String getUserName(TOpenSessionReq req) throws HiveSQLException, IOException { String userName = null; // Kerberos if (isKerberosAuthMode()) { @@ -369,12 +371,12 @@ public abstract class ThriftCLIService extends AbstractService implements TCLISe return effectiveClientUser; } - private String getShortName(String userName) { + private String getShortName(String userName) throws IOException { String ret = null; + if (userName != null) { - int indexOfDomainMatch = ServiceUtils.indexOfDomainMatch(userName); - ret = (indexOfDomainMatch <= 0) ? userName : - userName.substring(0, indexOfDomainMatch); + KerberosNameShim fullKerberosName = ShimLoader.getHadoopShims().getKerberosNameShim(userName); + ret = fullKerberosName.getShortName(); } return ret;
