From 84cc3971b280c845ba3f9a959edee2ee2790834e Mon Sep 17 00:00:00 2001 From: Sahil Takiar Date: Mon, 16 Mar 2015 16:33:38 -0700 Subject: [PATCH] Fixing build and find bugs warnings --- build.gradle | 2 +- gobblin-compaction/build.gradle | 4 +++- .../gobblin/hive/util/HiveJdbcConnector.java | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index cd4cff8d848..39822a345cb 100644 --- a/build.gradle +++ b/build.gradle @@ -141,7 +141,7 @@ subprojects { } } - if (isDefaultEnvironment && !project.name.equals('gobblin-compaction')) { + if (isDefaultEnvironment) { task sourcesJar(type: Jar, dependsOn: classes) { from sourceSets.main.allSource classifier = 'sources' diff --git a/gobblin-compaction/build.gradle b/gobblin-compaction/build.gradle index 8d9145c7740..4a964ac8be3 100644 --- a/gobblin-compaction/build.gradle +++ b/gobblin-compaction/build.gradle @@ -51,4 +51,6 @@ task createCompactionTar(type: Tar) { createCompactionTar.dependsOn ':gobblin-compaction:jar' -artifacts { archives createCompactionTar } \ No newline at end of file +artifacts { + archives createCompactionTar +} diff --git a/gobblin-compaction/src/main/java/gobblin/hive/util/HiveJdbcConnector.java b/gobblin-compaction/src/main/java/gobblin/hive/util/HiveJdbcConnector.java index 7f44266f177..f115f530fee 100644 --- a/gobblin-compaction/src/main/java/gobblin/hive/util/HiveJdbcConnector.java +++ b/gobblin-compaction/src/main/java/gobblin/hive/util/HiveJdbcConnector.java @@ -14,7 +14,9 @@ import java.io.Closeable; import java.io.File; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.sql.PreparedStatement; @@ -88,7 +90,7 @@ public static HiveJdbcConnector newConnectorWithProps(Properties compactRunProps // Set the Hive Server type if (compactRunProps.containsKey(HIVESERVER_VERSION)) { - hiveJdbcConnector.withHiveServerVersion(Integer.valueOf(compactRunProps.getProperty(HIVESERVER_VERSION, DEFAULT_HIVESERVER_VERSION))); + hiveJdbcConnector.withHiveServerVersion(Integer.parseInt(compactRunProps.getProperty(HIVESERVER_VERSION, DEFAULT_HIVESERVER_VERSION))); } // Add the Hive Site Dir to the classpath @@ -189,8 +191,16 @@ private void addHiveSiteDirToClasspath(String hiveSiteDir) { Method method = urlClass.getDeclaredMethod("addURL", new Class[] { URL.class }); method.setAccessible(true); method.invoke(urlClassLoader, new Object[] { u }); - } catch (Exception e) { - throw new RuntimeException("Unable to add hive.site.dir to CLASSPATH"); + } catch (NoSuchMethodException e) { + throw new RuntimeException("Unable to add hive.site.dir to CLASSPATH", e); + } catch (IllegalArgumentException e) { + throw new RuntimeException("Unable to add hive.site.dir to CLASSPATH", e); + } catch (IllegalAccessException e) { + throw new RuntimeException("Unable to add hive.site.dir to CLASSPATH", e); + } catch (InvocationTargetException e) { + throw new RuntimeException("Unable to add hive.site.dir to CLASSPATH", e); + } catch (MalformedURLException e) { + throw new RuntimeException("Unable to add hive.site.dir to CLASSPATH", e); } }