Bug 571990 - BuddyClassLoading with scope "global" fails with NPE for non-found clazz since Bug 570394
Summary: BuddyClassLoading with scope "global" fails with NPE for non-found clazz sinc...
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 4.19   Edit
Hardware: PC All
: P3 major with 2 votes (vote)
Target Milestone: 4.20 M1   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
: 571991 572634 (view as bug list)
Depends on:
Blocks: 572102
  Show dependency tree
 
Reported: 2021-03-16 08:39 EDT by Rhodan76 CLA
Modified: 2021-05-05 14:02 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rhodan76 CLA 2021-03-16 08:39:16 EDT
The re-factorings in org.eclipse.osgi.internal.loader.buddy.GlobalPolicy#loadClass and #loadResource done for Bug 570394 will cause a NPE when trying to load a class but no bundle found exporting the package of the requested class.


>Caused by: java.lang.NullPointerException
>	at java.base/java.util.Optional.orElseGet(Optional.java:369)
>	at org.eclipse.osgi.internal.loader.buddy.GlobalPolicy.loadResource(GlobalPolicy.java:66)
>	at org.eclipse.osgi.internal.loader.buddy.PolicyHandler.doBuddyResourceLoading(PolicyHandler.java:171)
>	at org.eclipse.osgi.internal.loader.BundleLoader.findResource(BundleLoader.java:685)
>	at org.eclipse.osgi.internal.loader.ModuleClassLoader.getResource(ModuleClassLoader.java:216)
>	at org.eclipse.osgi.internal.framework.ContextFinder.getResource(ContextFinder.java:161)


I think the cause is the wrongly use Optional.orElseGet(null) while Optional.orElse(null) would be correct to restore the previous behavior with just returning <null> in such a case.

See also https://www.eclipse.org/forums/index.php/m/1838925/#msg_1838925 for similar problem report.

This failure in BuddyPolicy:global classloading will prevent our application from running and it's a blocker to upgrade to 4.19.
Comment 1 Andrey Loskutov CLA 2021-03-16 08:44:02 EDT
(In reply to Rhodan76 from comment #0)
> I think the cause is the wrongly use Optional.orElseGet(null) while
> Optional.orElse(null) would be correct to restore the previous behavior with
> just returning <null> in such a case.

Thanks for your bug report! Would you like to provide a patch via gerrit? See https://wiki.eclipse.org/Platform/How_to_Contribute
Comment 2 Andrey Loskutov CLA 2021-03-16 09:11:42 EDT
*** Bug 571991 has been marked as a duplicate of this bug. ***
Comment 3 Eclipse Genie CLA 2021-03-16 09:16:52 EDT
New Gerrit change created: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/177841
Comment 4 Thomas Watson CLA 2021-03-16 09:17:51 EDT
(In reply to Andrey Loskutov from comment #1)
> (In reply to Rhodan76 from comment #0)
> > I think the cause is the wrongly use Optional.orElseGet(null) while
> > Optional.orElse(null) would be correct to restore the previous behavior with
> > just returning <null> in such a case.
> 
> Thanks for your bug report! Would you like to provide a patch via gerrit?
> See https://wiki.eclipse.org/Platform/How_to_Contribute

That would have been a fine idea for a good first bug fix.  I was already working on a fix and testcase as well as checking that the other usage of orElseGet method was correct in the framework.
Comment 5 Rhodan76 CLA 2021-03-16 09:30:39 EDT
Wow, already fixed by Thomas. Thank you!
Comment 7 Thomas Watson CLA 2021-03-16 10:18:22 EDT
(In reply to Rhodan76 from comment #5)
> Wow, already fixed by Thomas. Thank you!

Admittedly I was embarrassed by the incorrect usage of orElseGet that I introduced to the code.  Thanks for the report.
Comment 8 Eclipse Genie CLA 2021-03-22 12:07:31 EDT
New Gerrit change created: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/178221
Comment 10 Andrey Loskutov CLA 2021-04-08 02:39:28 EDT
*** Bug 572634 has been marked as a duplicate of this bug. ***
Comment 11 Fabio Zadrozny CLA 2021-04-08 09:17:47 EDT
Is there something planned regarding making this bugfix available to end-users?

Right now I'm having to ask users to skip this version because it breaks PyDev and I don't see any workaround...
Comment 12 Mickael Istria CLA 2021-04-08 10:15:58 EDT
(In reply to Fabio Zadrozny from comment #11)
> Is there something planned regarding making this bugfix available to
> end-users?
> 
> Right now I'm having to ask users to skip this version because it breaks
> PyDev and I don't see any workaround...

Indeed, for 4.19, it seems like this won't work at all and there is no workaround.
You can tell your users to use the Platform I-Builds instead, or Platform 4.20.M1 (to be published tomorrow).
Please reach out to the mailing-list to ask whether anyone has plans to do a 4.19.1 release of the Eclipse project with the backported patch. But I wouldn't place too much hope in that.
Comment 13 Carsten Hammer CLA 2021-05-05 14:02:03 EDT
(In reply to Mickael Istria from comment #12)
> (In reply to Fabio Zadrozny from comment #11)
> > Is there something planned regarding making this bugfix available to
> > end-users?
> > 
> > Right now I'm having to ask users to skip this version because it breaks
> > PyDev and I don't see any workaround...
> 
> Indeed, for 4.19, it seems like this won't work at all and there is no
> workaround.
> You can tell your users to use the Platform I-Builds instead, or Platform
> 4.20.M1 (to be published tomorrow).
> Please reach out to the mailing-list to ask whether anyone has plans to do a
> 4.19.1 release of the Eclipse project with the backported patch. But I
> wouldn't place too much hope in that.

Would it be possible to add a softlink in https://download.eclipse.org/releases/ to point to https://download.eclipse.org/releases/2021-06/?
"latest" points to https://download.eclipse.org/releases/2021-03/ afaik which is not usable.
Something like 

https://download.eclipse.org/releases/snapshot/

additionally to

https://download.eclipse.org/releases/latest/

would do.