[ 
https://issues.apache.org/jira/browse/HIVE-6451?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ashutosh Chauhan updated HIVE-6451:
-----------------------------------

    Assignee: Ding Yuan

> 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
>            Assignee: Ding Yuan
>            Priority: Trivial
>         Attachments: HIVE-6451.patch, 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.2#6252)

Reply via email to