Skip to content

Commit 5385e40

Browse files
committed
DriverSessions: Remove methods that would never work
Since the only production implementation of DriverSessions is the PretendDriverSessions and this no-ops or throws exceptions with many methods, it's best to clean things up. Removing the methods from the interface, and any implementations that might be hanging from it.
1 parent fa9371d commit 5385e40

File tree

7 files changed

+5
-279
lines changed

7 files changed

+5
-279
lines changed

java/server/src/org/openqa/selenium/remote/server/DriverSessions.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,13 @@
1818

1919
package org.openqa.selenium.remote.server;
2020

21-
import org.openqa.selenium.Capabilities;
22-
import org.openqa.selenium.WebDriver;
2321
import org.openqa.selenium.remote.SessionId;
2422

2523
import java.util.Set;
26-
import java.util.stream.Stream;
2724

2825
public interface DriverSessions {
29-
SessionId newSession(Stream<Capabilities> desiredCapabilities) throws Exception;
3026

3127
Session get(SessionId sessionId);
3228

33-
void deleteSession(SessionId sessionId);
34-
35-
void registerDriver(Capabilities capabilities, Class<? extends WebDriver> implementation);
36-
3729
Set<SessionId> getSessions();
38-
3930
}

java/server/src/org/openqa/selenium/remote/server/InMemorySession.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import java.util.Set;
4040
import java.util.UUID;
4141
import java.util.logging.Logger;
42-
import java.util.stream.Stream;
4342

4443
class InMemorySession implements ActiveSession {
4544

@@ -52,8 +51,7 @@ class InMemorySession implements ActiveSession {
5251
private final TemporaryFilesystem filesystem;
5352
private final JsonHttpCommandHandler handler;
5453

55-
private InMemorySession(WebDriver driver, Capabilities capabilities, Dialect downstream)
56-
throws IOException {
54+
private InMemorySession(WebDriver driver, Capabilities capabilities, Dialect downstream) {
5755
this.driver = Preconditions.checkNotNull(driver);
5856

5957
Capabilities caps;
@@ -132,7 +130,7 @@ public Optional<ActiveSession> apply(Set<Dialect> downstreamDialects, Capabiliti
132130
// Assume the blob fits in the available memory.
133131
try {
134132
if (!provider.canCreateDriverInstanceFor(caps)) {
135-
return null;
133+
return Optional.empty();
136134
}
137135

138136
WebDriver driver = provider.newInstance(caps);
@@ -142,7 +140,7 @@ public Optional<ActiveSession> apply(Set<Dialect> downstreamDialects, Capabiliti
142140
Dialect.OSS :
143141
downstreamDialects.iterator().next();
144142
return Optional.of(new InMemorySession(driver, caps, downstream));
145-
} catch (IOException | IllegalStateException e) {
143+
} catch (IllegalStateException e) {
146144
return Optional.empty();
147145
}
148146
}
@@ -158,32 +156,15 @@ private class PretendDriverSessions implements DriverSessions {
158156

159157
private final Session session;
160158

161-
private PretendDriverSessions() throws IOException {
159+
private PretendDriverSessions() {
162160
this.session = new ActualSession();
163161
}
164162

165-
@Override
166-
public SessionId newSession(Stream<Capabilities> desiredCapabilities) throws Exception {
167-
throw new UnsupportedOperationException("newSession");
168-
}
169-
170163
@Override
171164
public Session get(SessionId sessionId) {
172165
return getId().equals(sessionId) ? session : null;
173166
}
174167

175-
@Override
176-
public void deleteSession(SessionId sessionId) {
177-
// no-op
178-
}
179-
180-
@Override
181-
public void registerDriver(
182-
Capabilities capabilities,
183-
Class<? extends WebDriver> implementation) {
184-
throw new UnsupportedOperationException("registerDriver");
185-
}
186-
187168
@Override
188169
public Set<SessionId> getSessions() {
189170
return ImmutableSet.of(getId());
@@ -195,7 +176,7 @@ private class ActualSession implements Session {
195176
private final KnownElements knownElements;
196177
private volatile String screenshot;
197178

198-
private ActualSession() throws IOException {
179+
private ActualSession() {
199180
knownElements = new KnownElements();
200181
}
201182

java/server/src/org/openqa/selenium/remote/server/JsonHttpCommandHandler.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.openqa.selenium.remote.server;
1919

2020
import static org.openqa.selenium.remote.DriverCommand.*;
21-
import static org.openqa.selenium.remote.http.HttpMethod.POST;
2221

2322
import org.openqa.selenium.UnsupportedCommandException;
2423
import org.openqa.selenium.remote.Command;
@@ -33,7 +32,6 @@
3332
import org.openqa.selenium.remote.http.JsonHttpResponseCodec;
3433
import org.openqa.selenium.remote.http.W3CHttpCommandCodec;
3534
import org.openqa.selenium.remote.server.handler.AcceptAlert;
36-
import org.openqa.selenium.remote.server.handler.AddConfig;
3735
import org.openqa.selenium.remote.server.handler.AddCookie;
3836
import org.openqa.selenium.remote.server.handler.CaptureScreenshot;
3937
import org.openqa.selenium.remote.server.handler.ChangeUrl;
@@ -90,7 +88,6 @@
9088
import org.openqa.selenium.remote.server.handler.ImeIsActivated;
9189
import org.openqa.selenium.remote.server.handler.ImplicitlyWait;
9290
import org.openqa.selenium.remote.server.handler.MaximizeWindow;
93-
import org.openqa.selenium.remote.server.handler.NewSession;
9491
import org.openqa.selenium.remote.server.handler.RefreshPage;
9592
import org.openqa.selenium.remote.server.handler.Rotate;
9693
import org.openqa.selenium.remote.server.handler.SendKeys;
@@ -150,8 +147,6 @@
150147

151148
public class JsonHttpCommandHandler {
152149

153-
private static final String ADD_CONFIG_COMMAND_NAME = "-selenium-add-config";
154-
155150
private final DriverSessions sessions;
156151
private final Logger log;
157152
private final Set<CommandCodec<HttpRequest>> commandCodecs;
@@ -229,15 +224,8 @@ private Command decode(HttpRequest request) {
229224
}
230225

231226
private void setUpMappings() {
232-
for (CommandCodec<HttpRequest> codec : commandCodecs) {
233-
codec.defineCommand(ADD_CONFIG_COMMAND_NAME, POST, "/config/drivers");
234-
}
235-
236-
addNewMapping(ADD_CONFIG_COMMAND_NAME, AddConfig.class);
237-
238227
addNewMapping(STATUS, Status.class);
239228
addNewMapping(GET_ALL_SESSIONS, GetAllSessions.class);
240-
addNewMapping(NEW_SESSION, NewSession.class);
241229
addNewMapping(GET_CAPABILITIES, GetSessionCapabilities.class);
242230
addNewMapping(QUIT, DeleteSession.class);
243231

java/server/src/org/openqa/selenium/remote/server/handler/AddConfig.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

java/server/src/org/openqa/selenium/remote/server/handler/NewSession.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

java/server/src/org/openqa/selenium/remote/server/rest/ResultConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ public Response handle(Command command) throws Exception {
148148
final PerSessionLogHandler logHandler = LoggingManager.perSessionLogHandler();
149149
logHandler.transferThreadTempLogsToSessionLogs(sessionId);
150150
logHandler.removeSessionLogs(sessionId);
151-
sessions.deleteSession(sessionId);
152151
}
153152
return response;
154153
}

java/server/test/org/openqa/testing/TestSessions.java

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)