add error message when Future's outcome has no AuthenticationResult but exception
@@ -69,6 +69,8 @@ class SQLServerADAL4JUtils {
String tgtClientName = null;
try {
+ // Get Kerberos TGT ticket and retrieve client name.
+ // If KRB5CCNAME environment variable is not set, the method searches for default location
Credentials cred = Credentials.acquireTGTFromCache(null, System.getenv("KRB5CCNAME"));
if (null == cred) {
@@ -97,6 +99,11 @@ class SQLServerADAL4JUtils {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_ADALExecution"));
Object[] msgArgs = {tgtClientName, authenticationString};
+ if (null == e.getCause() || null == e.getCause().getMessage()) {
+ // the case when Future's outcome has no AuthenticationResult but exception
+ throw new SQLServerException(form.format(msgArgs), null);
+ }
+ else {
// the cause error message uses \\n\\r which does not give correct format
// change it to \r\n to provide correct format
String correctedErrorMessage = e.getCause().getMessage().replaceAll("\\\\r\\\\n", "\r\n");
@@ -109,6 +116,7 @@ class SQLServerADAL4JUtils {
throw new SQLServerException(form.format(msgArgs), null, 0, correctedExecutionException);
}
+ }
finally {
executorService.shutdown();
}
