prateekm commented on a change in pull request #1070: SAMZA-2226: Migrate
Class.forName usage to inject classloader
URL: https://github.com/apache/samza/pull/1070#discussion_r292137224
##########
File path: samza-core/src/main/scala/org/apache/samza/util/Util.scala
##########
@@ -79,9 +79,20 @@ object Util extends Logging {
def getTaskClassVersion(config: Config, classLoader: ClassLoader): String = {
try {
- val taskClass = Option(new ApplicationConfig(config).getAppClass())
- .orElse(new TaskConfig(config).getTaskClass).get
- Class.forName(taskClass, true,
classLoader).getPackage.getImplementationVersion
+ val appClass = Option(new ApplicationConfig(config).getAppClass)
+ if (appClass.isDefined) {
+ Option.apply(Class.forName(appClass.get, true,
classLoader).getPackage.getImplementationVersion)
+ .getOrElse(FALLBACK_VERSION)
+ } else {
+ val taskClass = new TaskConfig(config).getTaskClass
+ if (taskClass.isPresent) {
+ Option.apply(Class.forName(taskClass.get(), true,
classLoader).getPackage.getImplementationVersion)
Review comment:
Don't need option.apply
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services