vihangk1 commented on a change in pull request #1791:
URL: https://github.com/apache/hive/pull/1791#discussion_r552274366



##########
File path: jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
##########
@@ -896,39 +946,103 @@ private void openSession() throws SQLException {
       openReq.setPassword(sessConfMap.get(JdbcConnectionParams.AUTH_PASSWD));
     }
 
+    //TODO(Vihang): This is a bit hacky. We piggy back on a dummy OpenSession 
call
+    // to get the redirect response from the server. Instead its probably 
cleaner to
+    // explicitly do a HTTP post request and get the response.
+    int numRetry = isBrowserAuthMode() ? 2 : 1;
+    for (int i=0; i<numRetry; i++) {
+      try {
+        openSession(openReq);
+      } catch (TException e) {
+        if (isSamlRedirect(e)) {
+          boolean success = doBrowserSSO();
+          if (!success) {
+            String msg = browserClient.getServerResponse() == null
+                || browserClient.getServerResponse().getMsg() == null ? ""
+                : browserClient.getServerResponse().getMsg();
+            throw new SQLException(
+                "Could not establish connection to " + jdbcUriString + ": "
+                    + msg, " 08S01", e);
+          }
+        } else {
+          throw new SQLException(
+              "Could not establish connection to " + jdbcUriString + ": " + e
+                  .getMessage(), " 08S01", e);

Review comment:
       08S01 stands for "communications link failure" which is not exactly what 
we want but arguably related to the authentication error. I can interpret it as 
"User is not authenticated and hence communications link failed". I would be 
happy to update this to a more specific error code if you know of a better one.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to