Skip to content

Change some MockWebServer ergonomics#8861

Merged
swankjesse merged 3 commits into
masterfrom
jwilson.0617.mockwebserver_apis
Jun 18, 2025
Merged

Change some MockWebServer ergonomics#8861
swankjesse merged 3 commits into
masterfrom
jwilson.0617.mockwebserver_apis

Conversation

@swankjesse

Copy link
Copy Markdown
Collaborator

Now calling MockWebServer.port and similar functions will not implicity start the server. It is instead necessary to explicitly call the start() function.

The problem with the old behavior was that reading the port field could fail with an IOException, which is weird behavior for reading a property.

Now calling MockWebServer.port and similar functions will
not implicity start the server. It is instead necessary to
explicitly call the start() function.

The problem with the old behavior was that reading the
port field could fail with an IOException, which is weird
behavior for reading a property.
}

@JvmName("-deprecated_port")
@Deprecated(

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.

UN-deprecating stuff from the old MockWebServer. This whole package is obsolete and these deprecation warnings aren’t benefiting anyone.

public final fun setProtocolNegotiationEnabled (Z)V
public final fun setProtocols (Ljava/util/List;)V
public final fun setServerSocketFactory (Ljavax/net/ServerSocketFactory;)V
public final fun setStarted (Z)V

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.

This was bananas


this._inetSocketAddress = inetSocketAddress
val alreadyStartedAddress = socketAddress_
if (alreadyStartedAddress != null) {

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.

Start used to silently ignore calls after it was started, even if the target address had changed

@yschimke

Copy link
Copy Markdown
Collaborator

LGTM but GitHub erroring on approve

@swankjesse
swankjesse force-pushed the jwilson.0617.mockwebserver_apis branch from 5668711 to db614ed Compare June 17, 2025 23:37
@swankjesse
swankjesse merged commit b9a1a5d into master Jun 18, 2025
22 checks passed
@swankjesse
swankjesse deleted the jwilson.0617.mockwebserver_apis branch June 18, 2025 00:19
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.

2 participants