SAP / SAP/btp-environment-variable-access

Feat: Make `ClassLoader` optional argument for service loading

Open
#73 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
24
Forks
13
Avg merge
4h 35m
Merged PRs (30d)
5

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the ServiceBindingAccessor.getInstancesViaServiceLoader() entry point and inspect its current service-loader behavior. Add the optional ClassLoader API described in the request, preserving the default behavior, and verify that callers can use either the default or supplied class loader.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.