Skip to content

Session.getService does not use proper classloader in OSGI environment #631

Closed
@mnlipp

Description

@mnlipp

Describe the bug
Even after fixing service loader related issues (#630) services are not loaded in an OSGi environment.

To Reproduce
Steps to reproduce the behavior:

  1. Use patched jar(s)
  2. Attempt to connect to imap provider.

Expected behavior
Service with class name obtained from provider should load.

Cause of problem
In an OSGi environment, the provider (obtained e.g. from imap.jar) has its own (bundle) classloader. This classloader is never tried when getting the service.

The code attempts loading with the context classloader and either the Session's classloader or -- if given -- the authenticator's classloader (why?). But the obvious option, using the classloader that loaded the provider, is not used.

What's missing is an attempt like:

        try {
            serviceClass = Class.forName(provider.getClassName(), false,
                provider.getClass().getClassLoader());
        } catch (ClassNotFoundException ex) {
            // ignore it
        }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions