Skip to content

Commit

Permalink
Do not recreate jaas file if it exists already
Browse files Browse the repository at this point in the history
  • Loading branch information
terence-yoo committed Mar 10, 2018
1 parent e0f8c24 commit 47aa19e
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
}
Expand Down

0 comments on commit 47aa19e

Please sign in to comment.