[crac] RFR: Fix NPE on ZipFile$Source access [v2]

Anton Kozlov akozlov at openjdk.java.net
Mon Apr 11 17:55:22 UTC 2022


On Fri, 8 Apr 2022 19:14:10 GMT, Anton Kozlov <akozlov at openjdk.org> wrote:

>> A race between ZipFile$CleanableResource.run() and ZipFile$Resource.beforeCheckpoint() can lead to NullPointerException when zsrc == null. This is observed on some runs of JavaCompilerCRaC.java from #16. The change aligns beforeCheckpoint() with the run(), providing the zsrc check and the proper locking.
>> 
>> The exception looks like below:
>> 
>> java.lang.reflect.InvocationTargetException
>> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
>> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
>> 	at java.base/jdk.internal.loader.URLClassPath$JarLoader$ClassLoaderJarFile.beforeCheckpoint(URLClassPath.java:837)
>> 	at java.base/jdk.crac.impl.AbstractContextImpl.beforeCheckpoint(AbstractContextImpl.java:66)
>> 	at java.base/jdk.crac.impl.AbstractContextImpl.beforeCheckpoint(AbstractContextImpl.java:66)
>> 	at java.base/jdk.crac.Core.checkpointRestore1(Core.java:108)
>> 	at java.base/jdk.crac.Core.checkpointRestore(Core.java:182)
>> 	at JavaCompilerCRaC.main(JavaCompilerCRaC.java:27)
>> Caused by: java.lang.NullPointerException: Cannot invoke "java.util.zip.ZipFile$Source.getFile()" because the return value of "java.util.zip.ZipFile$CleanableResource.getSource()" is null
>> 	at java.base/java.util.zip.ZipFile.beforeCheckpoint(ZipFile.java:1088)
>> 	... 10 more
>
> Anton Kozlov has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Merge branch 'zip-fix' of https://github.com/AntonKozlov/crac into zip-fix
>  - Fix NPE on ZipFile$Source access

Thanks for reviews!

-------------

PR: https://git.openjdk.java.net/crac/pull/17


More information about the crac-dev mailing list