This is an automated email from the ASF dual-hosted git repository.

xinyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/samza.git


The following commit(s) were added to refs/heads/master by this push:
     new b0caee8  SAMZA-2163: Add try-catch to get the version in 
MetricsSnapshotReporterFactory (#992)
b0caee8 is described below

commit b0caee8e2316b0592620d2d6dccdebe78acde2d4
Author: xinyuiscool <[email protected]>
AuthorDate: Thu Apr 11 16:55:30 2019 -0700

    SAMZA-2163: Add try-catch to get the version in 
MetricsSnapshotReporterFactory (#992)
---
 .../reporter/MetricsSnapshotReporterFactory.scala     | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git 
a/samza-core/src/main/scala/org/apache/samza/metrics/reporter/MetricsSnapshotReporterFactory.scala
 
b/samza-core/src/main/scala/org/apache/samza/metrics/reporter/MetricsSnapshotReporterFactory.scala
index 041c5c8..2191572 100644
--- 
a/samza-core/src/main/scala/org/apache/samza/metrics/reporter/MetricsSnapshotReporterFactory.scala
+++ 
b/samza-core/src/main/scala/org/apache/samza/metrics/reporter/MetricsSnapshotReporterFactory.scala
@@ -45,14 +45,17 @@ class MetricsSnapshotReporterFactory extends 
MetricsReporterFactory with Logging
     val jobId = config
       .getJobId
 
-    val taskClass = Option(new ApplicationConfig(config).getAppClass())
-      .getOrElse(config.getTaskClass.getOrElse(throw new SamzaException("No 
task or app class defined for config.")))
-
-    val version = 
Option(Class.forName(taskClass).getPackage.getImplementationVersion)
-      .getOrElse({
-        warn("Unable to find implementation version in jar's meta info. 
Defaulting to 0.0.1.")
-        "0.0.1"
-      })
+    val version =
+      try {
+        val taskClass = Option(new ApplicationConfig(config).getAppClass())
+          .orElse(config.getTaskClass).get
+        
Option(Class.forName(taskClass).getPackage.getImplementationVersion).get
+      } catch {
+        case e: Exception => {
+          warn("Unable to find implementation version in jar's meta info. 
Defaulting to 0.0.1.")
+          "0.0.1"
+        }
+      }
 
     val samzaVersion = 
Option(classOf[MetricsSnapshotReporterFactory].getPackage.getImplementationVersion)
       .getOrElse({

Reply via email to