Skip to content

Change how we test DnsOverHttps#9549

Merged
swankjesse merged 2 commits into
masterfrom
jwilson.0715.dns_server_
Jul 16, 2026
Merged

Change how we test DnsOverHttps#9549
swankjesse merged 2 commits into
masterfrom
jwilson.0715.dns_server_

Conversation

@swankjesse

Copy link
Copy Markdown
Collaborator

Rather than returning opaque hard-coded response bodies, use our new message encoder so we can test with real value objects.

Rather than returning opaque hard-coded response bodies, use our
new message encoder so we can test with real value objects.
@@ -79,75 +85,68 @@ class DnsOverHttpsTest {

@Test
fun getOne() {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The previous opaque hex values made it difficult to tell that the query was for google.com and the result was for star.c10r.facebook.com.

In a forthcoming PR I’ll replace both with lysine.dev

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

(It was a bug that the query and result domain names didn’t match)

@RequiresOptIn(level = ERROR, message = "Internal APIs for OkHttp's own modules")
@Retention(BINARY)
@Target(CLASS, FUNCTION, PROPERTY)
annotation class OkHttpInternalApi

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Keen to hear feedback on this thing I’m sneaking in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems fine until https://github.com/Kotlin/KEEP/blob/main/proposals/KEEP-0451-shared-internals.md. Just so long as we remember to ensure they're all hidden from Java.

@RequiresOptIn(level = ERROR, message = "Internal APIs for OkHttp's own modules")
@Retention(BINARY)
@Target(CLASS, FUNCTION, PROPERTY)
annotation class OkHttpInternalApi

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems fine until https://github.com/Kotlin/KEEP/blob/main/proposals/KEEP-0451-shared-internals.md. Just so long as we remember to ensure they're all hidden from Java.

* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:OptIn(OkHttpInternalApi::class)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Alternately we could enable it module-wide in the compiler options

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yep, coming up.

*/
internal tailrec fun <T> AtomicReference<T>.testAndSet(
@OkHttpInternalApi
tailrec fun <T> AtomicReference<T>.testAndSet(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We could also just copy since it's small.

/**
* Handles DNS calls using in-memory records.
*/
internal class DnsOverHttpsServer : Dispatcher() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nice!

@swankjesse
swankjesse merged commit 8bf87e8 into master Jul 16, 2026
66 of 70 checks passed
@swankjesse
swankjesse deleted the jwilson.0715.dns_server_ branch July 16, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants