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

ASF GitHub Bot commented on FLINK-6606:
---------------------------------------

Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3933#discussion_r117370134
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/hooks/MasterHooks.java
 ---
    @@ -267,6 +269,112 @@ else if (!allowUnmatchedState) {
        }
     
        // 
------------------------------------------------------------------------
    +   //  hook management
    +   // 
------------------------------------------------------------------------
    +
    +   /**
    +    * Wraps a hook such that the user-code classloader is applied when the 
hook is invoked.
    +    * @param hook the hook to wrap
    +    * @param userClassLoader the classloader to use
    +    */
    +   public static <T> MasterTriggerRestoreHook<T> 
wrapHook(MasterTriggerRestoreHook<T> hook, ClassLoader userClassLoader) {
    +           return new WrappedMasterHook<T>(hook, userClassLoader);
    +   }
    +
    +   @VisibleForTesting
    +   static class WrappedMasterHook<T> implements 
MasterTriggerRestoreHook<T> {
    +
    +           private final MasterTriggerRestoreHook<T> hook;
    +           private final ClassLoader userClassLoader;
    +
    +           WrappedMasterHook(MasterTriggerRestoreHook<T> hook, ClassLoader 
userClassLoader) {
    +                   this.hook = hook;
    +                   this.userClassLoader = userClassLoader;
    +           }
    +
    +           @Override
    +           public String getIdentifier() {
    +                   Thread thread = Thread.currentThread();
    +                   ClassLoader originalClassLoader = 
thread.getContextClassLoader();
    +                   thread.setContextClassLoader(userClassLoader);
    --- End diff --
    
    Maybe we can move the `setContextClassLoader` into the `try` body. Just to 
be on the safe side that whenever something happens we will reset the original 
class loader.


> Create checkpoint hook with user classloader
> --------------------------------------------
>
>                 Key: FLINK-6606
>                 URL: https://issues.apache.org/jira/browse/FLINK-6606
>             Project: Flink
>          Issue Type: Bug
>          Components: State Backends, Checkpointing
>            Reporter: Eron Wright 
>            Assignee: Eron Wright 
>            Priority: Blocker
>             Fix For: 1.3.0
>
>
> Flink should set the thread's classloader when calling the checkpoint hook 
> factory's `create` method.   Without that, the hook is likely to fail during 
> initialization (e.g. using ServiceLoader). 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to