Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log the exception? And we should document why we need to catch exception here (anonymous class..), so that we don't lose context in the codes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the warning line should be good here, since mostly likely it will be NoSuchElementException if no class is found or no version is found. Currently we are mostly getting 0.0.1 right now.

"0.0.1"
}
}

val samzaVersion = Option(classOf[MetricsSnapshotReporterFactory].getPackage.getImplementationVersion)
.getOrElse({
Expand Down