Skip to content

Increase resiliencey against service loading failure #26

Closed

Description

@infeo

We locate and load load service providers with the IntegrationsLoader:

public static <T> Stream<T> loadAll(Class<T> clazz) {
return ServiceLoader.load(clazz, ClassLoaderFactory.forPluginDir())
.stream()
.peek(service -> logFoundService(clazz, service.type()))
.filter(IntegrationsLoader::isSupportedOperatingSystem)
.filter(IntegrationsLoader::passesStaticAvailabilityCheck)
.sorted(Comparator.comparingInt(IntegrationsLoader::getPriority).reversed())
.map(ServiceLoader.Provider::get)
.filter(IntegrationsLoader::passesInstanceAvailabilityCheck)
.peek(impl -> logServiceIsAvailable(clazz, impl.getClass()));
}

We stream all possible services, check their availability by invoking isSupported and instantiate an instance. But as soon as an exceptions is thrown (wether during support check or instantiation), the whole loading stream collapses and fails with ServiceConfigurationException. Even worse, this error is not documented, tearing down lib consumers (as can be seen in cryptomator/cryptomator#3279)

We should refactor the loading in such a way, that failure on a single service does not affect loading of other services.

Activity

  1. added
    enhancement
    on Feb 20, 2024
  2. added this to the 1.3.1 milestone on Feb 20, 2024
  3. self-assigned this
    on Feb 20, 2024
  4. added a commit that references this issue on Feb 20, 2024
    928c9a1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions