BELUGA BEHR created HIVE-16966: ---------------------------------- Summary: Remove String Checks For Error Handling Key: HIVE-16966 URL: https://issues.apache.org/jira/browse/HIVE-16966 Project: Hive Issue Type: Improvement Components: Metastore Affects Versions: 3.0.0 Reporter: BELUGA BEHR Priority: Minor
{code:title=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; } {code} 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. -- This message was sent by Atlassian JIRA (v6.4.14#64029)