You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Ding Yuan (JIRA)" <ji...@apache.org> on 2014/02/17 20:33:19 UTC
[jira] [Created] (HIVE-6451) Exception handling improvements
Ding Yuan created HIVE-6451:
-------------------------------
Summary: Exception handling improvements
Key: HIVE-6451
URL: https://issues.apache.org/jira/browse/HIVE-6451
Project: Hive
Issue Type: Improvement
Components: HCatalog, JDBC
Affects Versions: 0.12.0
Reporter: Ding Yuan
Priority: Trivial
Attachments: hive-6451.patch
I am reporting a few cases where the exception handling could be improved. Attaching a proposed patch against trunk for review. Below are some explanations for two of the cases. Other cases are trivial by looking at the patch.
=========================
Case 1:
The code below might throw many kinds of exceptions. While some reflection-related
exceptions such as ClassNotFoundException are expected to occur, some others, such
as InvocationTargetException, should be silently swallowed. A good practice is
to differentiate different exceptions.
Line: 1463, File: "org/apache/hive/beeline/BeeLine.java"
{noformat}
1450: try {
1451: Class c = Class.forName(className, false,
1452: Thread.currentThread().getContextClassLoader());
1453: if (!Driver.class.isAssignableFrom(c)) {
1454: continue;
1455: }
1456:
1457: if (Modifier.isAbstract(c.getModifiers())) {
1458: continue;
1459: }
1460:
1461: // now instantiate and initialize it
1462: driverClasses.add(c.newInstance());
1463: } catch (Throwable t) {
1464: }
{noformat}
A similar snippet is at line 1522.
=========================
=========================
Case 2:
getField(String name) will not thrown IOException, but is declared with throws IOException.
hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/JobState.java (revision 1568587)
{noformat}
- public String getField(String name)
- throws IOException {
+ public String getField(String name) {
return storage.getField(type, id, name);
}
{noformat}
=========================
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)