Skip to content

Commit

Permalink
[java] Small code improvement in ProxyWebsocketsIntoGrid
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Jan 12, 2024
1 parent c0ddca6 commit ec523b2
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.logging.Logger;
import org.openqa.selenium.NoSuchSessionException;
import org.openqa.selenium.grid.sessionmap.SessionMap;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.remote.HttpSessionId;
import org.openqa.selenium.remote.SessionId;
import org.openqa.selenium.remote.http.BinaryMessage;
Expand All @@ -53,11 +54,12 @@ public ProxyWebsocketsIntoGrid(HttpClient.Factory clientFactory, SessionMap sess

@Override
public Optional<Consumer<Message>> apply(String uri, Consumer<Message> downstream) {
Objects.requireNonNull(uri);
Objects.requireNonNull(downstream);
Require.nonNull("uri", uri);
Require.nonNull("downstream", downstream);

Optional<SessionId> sessionId = HttpSessionId.getSessionId(uri).map(SessionId::new);
if (!sessionId.isPresent()) {
if (sessionId.isEmpty()) {
LOG.warning("Session not found for uri " + uri);
return Optional.empty();
}

Expand All @@ -72,7 +74,7 @@ public Optional<Consumer<Message>> apply(String uri, Consumer<Message> downstrea
return Optional.of(upstream::send);

} catch (NoSuchSessionException e) {
LOG.info("Attempt to connect to non-existent session: " + uri);
LOG.warning("Attempt to connect to non-existent session: " + uri);
return Optional.empty();
}
}
Expand Down

0 comments on commit ec523b2

Please sign in to comment.