Repository navigation
fix: update executor and driver server URL state on directConnect #2500
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
Open
hoanle0126
wants to merge
7
commits into
appium:master
Choose a base branch
from
hoanle0126:fix/direct-connect-server-url-state
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6d010be
fix: update executor and driver server URL state on directConnect
hoanle0126 e4eed84
fix: address review feedback on executor client state and log broadca…
hoanle0126 8ee115c
fix: address review feedback on LogBroadcastEndpoints and DirectConne…
hoanle0126 176274b
fix: keep broadcast overload defaults and simplify scheme resolution
hoanle0126 d23b566
fix: retain initial server URL scheme for log broadcast overloads
hoanle0126 4d09c25
Merge branch 'master' into fix/direct-connect-server-url-state
hoanle0126 b6e90f5
chore: mark deprecated-only log broadcast helpers for removal
hoanle0126 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/main/java/io/appium/java_client/internal/CommandExecutorInternals.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * See the NOTICE file distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.appium.java_client.internal; | ||
|
|
||
| import io.appium.java_client.remote.AppiumCommandExecutor; | ||
| import org.jspecify.annotations.NullMarked; | ||
| import org.jspecify.annotations.Nullable; | ||
|
|
||
| import java.lang.invoke.MethodHandles; | ||
| import java.net.URL; | ||
| import java.util.concurrent.atomic.AtomicReference; | ||
| import java.util.function.Function; | ||
|
|
||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| /** | ||
| * Internal bridge exposing private command executor state without widening public API. | ||
| * | ||
| * @deprecated The logs broadcasting web socket of the Appium drivers is deprecated and will be removed | ||
| * together with this API. Subscribe to the BiDi {@code log.entryAdded} event instead, see the | ||
| * <a href="https://github.com/appium/java-client/blob/master/docs/selenium-bridge.md#bidi">Selenium | ||
| * bridge documentation</a>. | ||
| */ | ||
| @NullMarked | ||
| @Deprecated(since = "11.1.0", forRemoval = true) | ||
| @SuppressWarnings("removal") | ||
| public final class CommandExecutorInternals { | ||
| private static final AtomicReference<@Nullable Function<AppiumCommandExecutor, @Nullable URL>> | ||
| INITIAL_SERVER_URL_RESOLVER = new AtomicReference<>(); | ||
|
|
||
| private CommandExecutorInternals() { | ||
| } | ||
|
|
||
| /** | ||
| * Registers the internal resolver that reads an executor's initial server URL before any URL overrides. | ||
| * | ||
| * @param lookup a private lookup belonging to {@link AppiumCommandExecutor} | ||
| * @param resolver the function returning the initial server URL for an executor | ||
| * @throws SecurityException if {@code lookup} does not have private access to {@link AppiumCommandExecutor} | ||
| */ | ||
| @Deprecated(since = "11.1.0", forRemoval = true) | ||
| public static void registerInitialServerUrlResolver( | ||
| MethodHandles.Lookup lookup, | ||
| Function<AppiumCommandExecutor, @Nullable URL> resolver | ||
| ) { | ||
| requireNonNull(lookup, "Lookup"); | ||
| requireNonNull(resolver, "Resolver"); | ||
| if (lookup.lookupClass() != AppiumCommandExecutor.class | ||
| || (lookup.lookupModes() & MethodHandles.Lookup.PRIVATE) == 0) { | ||
| throw new SecurityException( | ||
| "Only AppiumCommandExecutor may register the initial server URL resolver" | ||
| ); | ||
| } | ||
| INITIAL_SERVER_URL_RESOLVER.compareAndSet(null, resolver); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the server URL configured on {@code executor} before any {@code directConnect} or | ||
| * {@code overrideServerUrl} override took effect. | ||
| * | ||
| * @param executor the command executor to inspect | ||
| * @return the initial server URL, or {@code null} if none was configured | ||
| */ | ||
| @Nullable | ||
| @Deprecated(since = "11.1.0", forRemoval = true) | ||
| public static URL getInitialServerUrl(AppiumCommandExecutor executor) { | ||
| requireNonNull(executor, "Command executor"); | ||
| Function<AppiumCommandExecutor, @Nullable URL> resolver = INITIAL_SERVER_URL_RESOLVER.get(); | ||
| return resolver != null ? resolver.apply(executor) : executor.getAddressOfRemoteServer(); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.