Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backwards compatibility shim #13

Merged
merged 1 commit into from
Apr 17, 2024
Merged

Add backwards compatibility shim #13

merged 1 commit into from
Apr 17, 2024

Conversation

MrCreosote
Copy link
Member

This should cover most use cases currently existing in the kbase use case other than a few that are easy to handle on upgrade, and one case in the User Profile service an unused method.

This should cover most use cases currently existing in the kbase use
case other than a few that are easy to handle on upgrade, and one case
in the User Profile service an unused method.
@MrCreosote MrCreosote requested review from briehl and Xiangs18 April 12, 2024 17:07
Copy link

codecov bot commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 92.60%. Comparing base (e50e7aa) to head (070b23f).
Report is 3 commits behind head on main.

Files Patch % Lines
src/main/java/us/kbase/auth/AuthConfig.java 70.58% 10 Missing ⚠️
...in/java/us/kbase/auth/ConfigurableAuthService.java 89.47% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #13      +/-   ##
============================================
- Coverage     96.08%   92.60%   -3.49%     
- Complexity       88      107      +19     
============================================
  Files             5        7       +2     
  Lines           230      284      +54     
  Branches         44       48       +4     
============================================
+ Hits            221      263      +42     
- Misses            7       19      +12     
  Partials          2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java.net.URL was imported twice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One is URI, one is URL

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

try {
return new URL(DEFAULT_KBASE_AUTH_SERVER_URL);
} catch (MalformedURLException e) {
throw new RuntimeException("The impossible just happened");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If impossible, why use try catch? It an exception could be raised, maybe a more descriptive exception message?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I don't want to pollute the method signature with a checked exception that can never be thrown

@Xiangs18
Copy link

I got confused with new URL() vs new URI() in java. Any insights are greatly appreciated!

@MrCreosote
Copy link
Member Author

@Xiangs18
Copy link

What are you confused about?

Based on the code, one can easily converted to the other. Not sure why URI is needed.

@MrCreosote
Copy link
Member Author

MrCreosote commented Apr 17, 2024

The new auth client takes a URI, so it's needed due to that. As to why it takes a URI vs. a URL, I just copied the Jersey client: https://javadoc.io/doc/org.glassfish.jersey.bundles/jaxrs-ri/2.29.1/javax/ws/rs/client/Client.html

The backwards compatibility shim takes a URL because that's what the old client took

Copy link

@Xiangs18 Xiangs18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@MrCreosote MrCreosote merged commit 94c8b8d into main Apr 17, 2024
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants