btp-environment-variable-access icon indicating copy to clipboard operation
btp-environment-variable-access copied to clipboard

Feat: Make `ClassLoader` optional argument for service loading

Open newtork opened this issue 2 years ago • 0 comments

Context

The method ServiceBindingAccessor.getInstancesViaServiceLoader() uses service loader pattern.

By default the class' class loader will be used: ServiceBindingAccessor.class.getClassLoader(). There is now way to customize.

Request

Allow optional parameter ClassLoader for serivce loader API usage.

Suggestions

Overload method ServiceBindingAccessor.getInstancesViaServiceLoader(ClassLoader).

Questions

  • Why?
    • For service loader pattern we've noticed issues with different class loaders and issues with casting classes between them. This method would be useful in case of troubleshooting. Otherwise, I find these problems are almost impossible to debug.
  • What are the use cases?
    • Multiple or different versions per classloader, e.g. via buildpack and via application binary.

newtork avatar Nov 14 '22 08:11 newtork