databricks-sdk-java icon indicating copy to clipboard operation
databricks-sdk-java copied to clipboard

[FEATURE] Expensive DefaultCredentialsProvider instantiated always even if not needed

Open antonireus opened this issue 11 months ago • 0 comments

Problem Statement The bootstrap of the API is unnecessarily slow due to the instantiation in DatabricksConfig of the DefaultCredentialsProvider in line 18:

private CredentialsProvider credentialsProvider = new DefaultCredentialsProvider();

The DefaultCredentialsProvider instantiates all 11 available CredentialsProvider implementation triggering a lot of class loading and objects instantiation.

The DatabricksConfig object has a setter for the CredentialsProvider, so user of the API can choose and set his/her provider, but even if that case the DefaultCredentialsProvider will be instantiated as part of the field initialization.

Proposed Solution Only create an instance of DefaultCredentialsProvider inside the authenticate method if the credentalasProvider field has not been set.

Alternatively, inside the DefaultCredentailsProvider, the different providerClasses could be instantiated lazily instead of inside the constructor.

antonireus avatar Dec 20 '24 14:12 antonireus