From 47aa19e93a89b31ae6783d2cd2ee032d6eb4d643 Mon Sep 17 00:00:00 2001 From: "terence.yoo" Date: Sat, 10 Mar 2018 11:49:41 +0900 Subject: [PATCH] Do not recreate jaas file if it exists already --- .../src/main/java/com/kakao/hbase/common/HBaseClient.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hbase0.98/hbase-common-0.98/src/main/java/com/kakao/hbase/common/HBaseClient.java b/hbase0.98/hbase-common-0.98/src/main/java/com/kakao/hbase/common/HBaseClient.java index 3460f8c..02f48bc 100644 --- a/hbase0.98/hbase-common-0.98/src/main/java/com/kakao/hbase/common/HBaseClient.java +++ b/hbase0.98/hbase-common-0.98/src/main/java/com/kakao/hbase/common/HBaseClient.java @@ -44,6 +44,11 @@ private HBaseClient() { } private static String createJaasConfigFile(Args args) throws FileNotFoundException, UnsupportedEncodingException { + // fixme hash collision may occur in args.hashStr() + final String authConfFileName = "/tmp/" + "hbase-client-" + args.hashStr() + ".jaas"; + File file = new File(authConfFileName); + if (file.exists()) return authConfFileName; + StringBuilder sb = new StringBuilder(); sb.append("Client {\n"); sb.append("com.sun.security.auth.module.Krb5LoginModule required\n"); @@ -60,7 +65,6 @@ private static String createJaasConfigFile(Args args) throws FileNotFoundExcepti } sb.append(";};"); - String authConfFileName = "/tmp/" + "hbase-client-" + args.hashStr() + ".jaas"; try (PrintWriter writer = new PrintWriter(authConfFileName, Constant.CHARSET.name())) { writer.print(sb); }