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

Handle DnsResolver direct exception on API 34 #8190

Merged
merged 6 commits into from
Jan 22, 2024

Conversation

yschimke
Copy link
Collaborator

@yschimke yschimke added the android Relates to usage specifically on Android label Jan 13, 2024
@yschimke yschimke marked this pull request as ready for review January 13, 2024 11:18
@yschimke
Copy link
Collaborator Author

Can't see an easy way to add a test android.net.DnsResolver is final, and no shadow for robolectric.

@yschimke yschimke changed the title Fix broken Android test on API 34 Handle DnsResolver direct exception on API 34 Jan 13, 2024
@JakeWharton
Copy link
Member

Robolectric lets you provide your own shadows if you need one it doesn't provide. Should go into @Config.

https://robolectric.org/extending/#using-a-custom-shadows

@yschimke
Copy link
Collaborator Author

yschimke commented Jan 18, 2024

@JakeWharton care to take another look? I'm keen to fix any noise on github workflows.

@JakeWharton
Copy link
Member

I can on Monday

@yschimke yschimke merged commit 296baa5 into square:master Jan 22, 2024
21 checks passed
}
},
)
} catch (e: Exception) {
Copy link
Member

Choose a reason for hiding this comment

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

Any idea what kinds of exceptions we’ll be potentially hiding here? We’re attributing an arbitrary failure like an IllegalStateException as an unknown host

Copy link
Member

Choose a reason for hiding this comment

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

I saw from the attached but report it’s gonna happen when the DNS isn't available.

IllegalArgumentException: Network.fromNetworkHandle refusing to instantiate NETID_UNSET Network.

I agree with this PR, we’ve got to be resilient to this API that doesn’t offer us a ton of good options.

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'll add a comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Relates to usage specifically on Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants