[ 
https://issues.apache.org/jira/browse/BEAM-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15717358#comment-15717358
 ] 

Luke Cwik commented on BEAM-682:
--------------------------------

ReflectHelpers exposes a method which figures out the correct class loader to 
use:
https://github.com/apache/incubator-beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/util/common/ReflectHelpers.java#L224

You can't assume the current threads context class loader is always available 
since it can be null.
http://stackoverflow.com/questions/3459216/can-the-thread-context-class-loader-be-null

> Invoker Class should be created in Thread Context Classloader
> -------------------------------------------------------------
>
>                 Key: BEAM-682
>                 URL: https://issues.apache.org/jira/browse/BEAM-682
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-java-core
>    Affects Versions: 0.3.0-incubating
>            Reporter: Sumit Chawla
>            Assignee: Sumit Chawla
>
> As of now the InvokerClass is being loaded in wrong classloader. It should be 
> loaded into Thread.currentThread.getContextClassLoader()
> https://github.com/apache/incubator-beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnInvokers.java#L167
> {code}
>  Class<? extends DoFnInvoker<?, ?>> res =
>         (Class<? extends DoFnInvoker<?, ?>>)
>             unloaded
>                 .load(DoFnInvokers.class.getClassLoader(), 
> ClassLoadingStrategy.Default.INJECTION)
>                 .getLoaded();
> {code}
> Fix 
> {code}
>  Class<? extends DoFnInvoker<?, ?>> res =
>         (Class<? extends DoFnInvoker<?, ?>>)
>             unloaded
>                 .load(Thread.currentThread().getContextClassLoader(),
>                         ClassLoadingStrategy.Default.INJECTION)
>                 .getLoaded();
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to