Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-16966

Remove String Checks For Error Handling

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.0.0
    • None
    • Metastore
    • None

    Description

      org.apache.hadoop.hive.metastore.RetryingMetaStoreClient
            } catch (UndeclaredThrowableException e) {
              throw e.getCause();
            } catch (InvocationTargetException e) {
              Throwable t = e.getCause();
              if (t instanceof TApplicationException) {
                TApplicationException tae = (TApplicationException)t;
                switch (tae.getType()) {
                case TApplicationException.UNSUPPORTED_CLIENT_TYPE:
                case TApplicationException.UNKNOWN_METHOD:
                case TApplicationException.WRONG_METHOD_NAME:
                case TApplicationException.INVALID_PROTOCOL:
                  throw t;
                default:
                  // TODO: most other options are probably unrecoverable... throw?
                  caughtException = tae;
                }
              } else if ((t instanceof TProtocolException) || (t instanceof TTransportException)) {
                // TODO: most protocol exceptions are probably unrecoverable... throw?
                caughtException = (TException)t;
              } else if ((t instanceof MetaException) && t.getMessage().matches(
                  "(?s).*(JDO[a-zA-Z]*|TProtocol|TTransport)Exception.*") &&
                  !t.getMessage().contains("java.sql.SQLIntegrityConstraintViolationException")) {
                caughtException = (MetaException)t;
              } else {
                throw t;
              }
            } catch (MetaException e) {
              if (e.getMessage().matches("(?s).*(IO|TTransport)Exception.*") &&
                  !e.getMessage().contains("java.sql.SQLIntegrityConstraintViolationException")) {
                caughtException = e;
              } else {
                throw e;
              }
      

      Using these magic string checks is very fragile. The Metastore should be throwing tailored exceptions instead of relying on string checking in the client code that bubble up from third-party libraries. Metastore should control the underlying libraries and their specific exceptions.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              belugabehr David Mollitor
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: