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

Refactor OkHttp interceptors and turn them into Kotlin #32

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

bidetofevil
Copy link
Collaborator

@bidetofevil bidetofevil commented Oct 27, 2023

Goal

Convert to Kotlin. I had to do a few things in order for this to work, and I'll point it out in the review via comments.

Testing

Existing tests passes

Copy link
Collaborator Author

bidetofevil commented Oct 27, 2023

@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #32 (c2a10a6) into master (8065b03) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #32   +/-   ##
=======================================
  Coverage   72.66%   72.67%           
=======================================
  Files         305      305           
  Lines        9992     9990    -2     
  Branches     1440     1438    -2     
=======================================
- Hits         7261     7260    -1     
  Misses       2162     2162           
+ Partials      569      568    -1     
Files Coverage Δ
...android/embracesdk/EmbraceInternalInterfaceImpl.kt 92.30% <100.00%> (+0.09%) ⬆️
...id/embracesdk/internal/EmbraceInternalInterface.kt 40.00% <100.00%> (+4.28%) ⬆️
...network/http/EmbraceHttpUrlConnectionOverride.java 40.00% <ø> (ø)
...ndroid/embracesdk/internal/utils/ThrowableUtils.kt 100.00% <ø> (+12.50%) ⬆️

@bidetofevil bidetofevil marked this pull request as ready for review October 27, 2023 21:35
* Return the canonical name of the cause of a [Throwable]. Handles null elements throughout,
* including the throwable and its cause, in which case [defaultName] is returned
*/
internal fun causeName(throwable: Throwable?, defaultName: String = ""): String {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These methods and their tests were moved from ThrowableUtils.kt in the main module. They were only used here and its seems weird to have them in a different module, so I effectively inline it.

val realResponseBody = RealResponseBody(
contentType,
-1L,
GzipSource(body.source()).buffer()
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 was using a RealBufferedSource before as that's what the internal OkHttp implementation did, but because that's an internal class, I changed the implementation to not depend on that. This is basically what the implementation did prior to my refactoring of it in 5.25, so this should be fine.


import io.embrace.android.embracesdk.InternalApi;

@InternalApi
public interface HttpPathOverrideRequest {

@NonNull
@Nullable
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should've been @Nullable all along

@@ -132,6 +132,8 @@
* not change after the SDK has started.
*/
public fun getSdkCurrentTime(): Long

public fun isInternalNetworkCaptureDisabled(): Boolean
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This new method returns the value set on ApkToolsConfig, which lives in the main module. Having a internal API method means I can cross the module bounds as well as mock this for a test

Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

LGTM

@bidetofevil bidetofevil merged commit 8cf8db4 into master Oct 30, 2023
6 checks passed
@bidetofevil bidetofevil deleted the hho/okhttp-cleanup branch October 30, 2023 15:12
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.

2 participants