Skip to content

SAMZA-2163: Add try-catch to get the version in MetricsSnapshotReporterFactory#992

Merged
xinyuiscool merged 1 commit into
apache:masterfrom
xinyuiscool:SAMZA-2163
Apr 11, 2019
Merged

SAMZA-2163: Add try-catch to get the version in MetricsSnapshotReporterFactory#992
xinyuiscool merged 1 commit into
apache:masterfrom
xinyuiscool:SAMZA-2163

Conversation

@xinyuiscool
Copy link
Copy Markdown
Contributor

Currently we relying on app.class or task.class to get the version. For beam the app.class is anonymous class which caused exception when loading the class of it. This patch will do a try catch for this exception and use 0.0.1 as default.

@xinyuiscool
Copy link
Copy Markdown
Contributor Author

@lhaiesp : please take a look!

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.

@xinyuiscool xinyuiscool merged commit b0caee8 into apache:master Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants