microsoft-authentication-library-for-java icon indicating copy to clipboard operation
microsoft-authentication-library-for-java copied to clipboard

Make getManagedIdentitySource static

Open Avery-Dunn opened this issue 1 year ago • 0 comments

Adjusts ManagedIdentityApplication to make the getManagedIdentitySource method static. This is to solve a niche issue when testing an application that uses Managed Identity, where a developer would want to test an app with multiple mocked MI sources on one machine.

Although this looks like it is adjusting public APIs, the actual change in the built package is minor and there should be no breaking change:

  • Previously, the Lombok @Getter annotation was creating a public method called getManagedIdentitySource in the final package
  • The changes in this PR create an explicit getManagedIdentitySource method that is also public, and removes the annotation for Lombok to create that same method
  • Putting those two points together, this should be no different from just changing the internals of the method to return the result of ManagedIdentityClient.getManagedIdentitySource() rather than the current value of the managedIdentitySource field
  • Because of all that, the values returned should be the same and the API should look no different in the actual package that gets built

Additionally, static methods can be access through an instance of a class just like a non-static method, so making this method static will at worst cause a minor warning in an IDE about using a static method improperly. The RevAPI plugin was used to ensure that this was the only part of the API that could be considered 'changed' when compared to the last released msal4j package.

Avery-Dunn avatar Sep 26 '24 15:09 Avery-Dunn