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

Convert HttpClient to Kotlin #1215

Merged
merged 4 commits into from
Nov 18, 2024
Merged

Convert HttpClient to Kotlin #1215

merged 4 commits into from
Nov 18, 2024

Conversation

tdchow
Copy link
Collaborator

@tdchow tdchow commented Nov 15, 2024

Summary of changes

  • Convert HttpClient and SynchronusHttpClient to Kotlin

Checklist

  • Added a changelog entry
  • Relevant test coverage

Authors

List GitHub usernames for everyone who contributed to this pull request.

@tdchow tdchow requested a review from a team as a code owner November 15, 2024 20:31
@tdchow tdchow marked this pull request as draft November 15, 2024 21:43
@tdchow tdchow marked this pull request as ready for review November 15, 2024 21:53
Copy link
Contributor

@jaxdesmarais jaxdesmarais left a comment

Choose a reason for hiding this comment

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

Just a few general questions, but none of them blockers.

Comment on lines +70 to +72
} catch (ignore: MalformedURLException) {
} catch (ignore: URISyntaxException) {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we able to add a comment or something in there blocks to indicate why we ignore these? To me they seem like something we wouldn't want to ignore, but I see we were also doing this previously.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not too sure why we're catching these 😅 but from a quick look, HttpRequest.getURL() can throw these exceptions and it feels like we don't want to crash due to those.

I think a lot of the networking code can be refactored to remove the ambiguity, but I wanted to keep the actual code changes to a minimum other than the java to kotlin conversion.

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds good, yeah it's not blocking was more for my general understanding.

}
}

private fun getNumRetriesSoFar(url: URL): Int {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if getCurrentRetryCount would be a better name for this. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That makes sense to me! Although I feel the rename should be done in a separate PR since we wouldn't have git history of the change since we're converting from java to kotlin in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can do that in a separate PR if that will make the history easier. Are you able to make a ticket for that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep! I'll create a ticket for tracking the rename.

Comment on lines +96 to +98
} catch (ignore: MalformedURLException) {
} catch (ignore: URISyntaxException) {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here as above, are we able to add a comment in these blocks for why we ignore these?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's calling the same HttpRequest.getUrl() function which can throw both of those exceptions.

@@ -137,36 +115,6 @@ public void request_whenConnectionIsHttps_setsSSLSocketFactory() throws Exceptio
verify(connection).setSSLSocketFactory(sslSocketFactory);
}

@Test
public void request_whenConnectionIsHttps_andSSLSocketFactoryIsNull_throwsSSLException()
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these tests no longer relevant with the updated logic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, these tests are no longer relevant since SSLSocketFactory is now non-null in Kotlin.

…s/SynchronousHttpClient.kt

Co-authored-by: Jax DesMarais-Leder <[email protected]>
@tdchow tdchow merged commit 9966290 into main Nov 18, 2024
3 checks passed
@tdchow tdchow deleted the convert-httpclient-to-kotlin branch November 18, 2024 21:00
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