You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/09/23 07:12:19 UTC

[GitHub] [flink] sunhaibotb opened a new pull request #9744: [FLINK-13515][test] Fix ClassLoaderITCase fails on Java 11

sunhaibotb opened a new pull request #9744: [FLINK-13515][test] Fix ClassLoaderITCase fails on Java 11
URL: https://github.com/apache/flink/pull/9744
 
 
   ## What is the purpose of the change
   
   This pull request fixes the failure of `ClassLoaderITCase` on Java 11. For a nested class instance `x`, `x.getCanonicalName()` finds and loads the enclosing class of `x` by calling the methods of the classloader where `x` resides. Thus, It is incorrect to use `candidate.getClass().getCanonicalName()` to test whether there is `SuccessException` in the classpath of the class loader where the `ClassLoaderITCase` class resides, because `candidate.getClass().getCanonicalName()` will not find and load the related classes in the classloader where the `ClassLoaderITCase` class resides. We should use `Class.forName(...)` to test the expected result.
   
   
   In addition, when calling `getCanonicalName()` , `NoClassDefFoundError` is reported in Java 8, not in Java 11,  for the following reason:
   
   In Java 8, a class named `CheckpointedStreamingProgram$1` is generated at compiling ( because there are nested classes) , and when the nested classes are loaded, the dependent class loaded is `CheckpointedStreamingProgram$1` rather than `CheckpointedStreamingProgram`. Therefore, when `getCanonicalName()` is called in `ClassLoaderITCase`, the `CheckpointedStreamingProgram` class needs to be loaded, but at this time the `ChildFirstClassloader` (an `URLClassloader`) is closed and cannot load it, so `NoClassDefFoundError` is reported. But in Java 11, the `CheckpointedStreamingProgram$1` class is not generated and the `CheckpointedStreamingProgram` class is used directly (that is the `CheckpointedStreamingProgram` class has been loaded into `ChildFirstClassloader` before closing `ChildFirstClassloader`), so no errors are reported.
   
   
   ## Brief change log
   
     - Change the expected detection logic in `ClassLoaderITCase#testCheckpointedStreamingClassloaderJobWithCustomClassLoader`
   
   
   ## Verifying this change
   
   This change is already covered by existing test.
   
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
     - If yes, how is the feature documented? (**not applicable** / docs / JavaDocs / not documented)
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services