Improve resource resolution
- Dominant language
- Java
- Stars
- 43
- Forks
- 34
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 2
Description
Jenkins [Dependencies and Class Loading](https://www.jenkins.io/doc/developer/plugin-development/dependencies-and-class-loading/) shows a classloader tree where for example JAF-API is not able to locate JakartaMail (plug-in C) mailcap.file resolved from JAF-API (plugin A) because the context classloader is `Jenkins core`. See: https://github.com/jakartaee/jaf-api/pull/145#issuecomment-1981960181
>When I removed the workaround, your new code correctly kicked in and used the calling class loader from Jenkins Jakarta Activation plugin, but since that class loader could not see the Jenkins Jakarta Mail plugin, the mailcap was empty.
Mail uses JAF but Mail jar contains the [mailcap](https://github.com/eclipse-ee4j/angus-mail/blob/master/core/src/main/resources/META-INF/mailcap) resource file.
More thought needs to be put in to this but there are some options:
1. Add constructors for MailcapCommandMap and MimetypesFileTypeMap that take a ClassLoader. Then modify mail to use the newer constructor. Need to examine call sites.
2. Use StackWalker to find the calling class loader and probe that class loader after the context class loader and before that application classloader.
3. Have mail locate and parse the mailcap file and add the entries manually.
4. Force the context classloader to the mail classloader when interacting with JAF. This would work but, I think this is the wrong approach as in some cases user might want the CCL to load the resource.
Contributor guide
Assessment
This issue has not been assessed yet.