Skip to content

Commit 60d5f24

Browse files
authored
chore: Bump minimum Selenium version to 4.19.0 (#2142)
1 parent a60a7cc commit 60d5f24

File tree

3 files changed

+18
-35
lines changed

3 files changed

+18
-35
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ dependencies {
9595
### Compatibility Matrix
9696
Appium Java Client | Selenium client
9797
---------------------------|-----------------
98+
| `4.19.0`
9899
`9.1.0`, `9.2.0` | `4.17.0`, `4.18.0`, `4.18.1`
99100
`9.0.0` | `4.14.1`, `4.15.0`, `4.16.0` (partially [corrupted](https://github.com/SeleniumHQ/selenium/issues/13256)), `4.16.1`
100101
N/A | `4.14.0`

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
org.gradle.daemon=true
22

3-
selenium.version=4.17.0
3+
selenium.version=4.19.0
44
# Please increment the value in a release
55
appiumClient.version=9.2.0

src/main/java/io/appium/java_client/remote/AppiumProtocolHandshake.java

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package io.appium.java_client.remote;
1818

19-
import com.google.common.io.CountingOutputStream;
20-
import com.google.common.io.FileBackedOutputStream;
2119
import org.openqa.selenium.Capabilities;
2220
import org.openqa.selenium.ImmutableCapabilities;
2321
import org.openqa.selenium.SessionNotCreatedException;
@@ -28,21 +26,17 @@
2826
import org.openqa.selenium.remote.Command;
2927
import org.openqa.selenium.remote.NewSessionPayload;
3028
import org.openqa.selenium.remote.ProtocolHandshake;
29+
import org.openqa.selenium.remote.http.Contents;
3130
import org.openqa.selenium.remote.http.HttpHandler;
3231

3332
import java.io.IOException;
34-
import java.io.InputStream;
35-
import java.io.OutputStreamWriter;
36-
import java.io.Writer;
33+
import java.io.StringWriter;
3734
import java.lang.reflect.InvocationTargetException;
3835
import java.lang.reflect.Method;
3936
import java.util.Map;
4037
import java.util.Set;
41-
import java.util.function.Supplier;
4238
import java.util.stream.Stream;
4339

44-
import static java.nio.charset.StandardCharsets.UTF_8;
45-
4640
@SuppressWarnings("UnstableApiUsage")
4741
public class AppiumProtocolHandshake extends ProtocolHandshake {
4842
private static void writeJsonPayload(NewSessionPayload srcPayload, Appendable destination) {
@@ -108,34 +102,22 @@ public Result createSession(HttpHandler client, Command command) throws IOExcept
108102
}
109103

110104
@Override
111-
public Either<SessionNotCreatedException, Result> createSession(
112-
HttpHandler client, NewSessionPayload payload) throws IOException {
113-
int threshold = (int) Math.min(Runtime.getRuntime().freeMemory() / 10, Integer.MAX_VALUE);
114-
FileBackedOutputStream os = new FileBackedOutputStream(threshold, true);
105+
public Either<SessionNotCreatedException, Result> createSession(HttpHandler client, NewSessionPayload payload) {
115106

116-
try (CountingOutputStream counter = new CountingOutputStream(os);
117-
Writer writer = new OutputStreamWriter(counter, UTF_8)) {
118-
writeJsonPayload(payload, writer);
107+
StringWriter stringWriter = new StringWriter();
108+
writeJsonPayload(payload, stringWriter);
119109

120-
Supplier<InputStream> contentSupplier = () -> {
121-
try {
122-
return os.asByteSource().openBufferedStream();
123-
} catch (IOException e) {
124-
throw new RuntimeException(e);
125-
}
126-
};
127-
try {
128-
Method createSessionMethod = ProtocolHandshake.class.getDeclaredMethod(
129-
"createSession", HttpHandler.class, Supplier.class, long.class
130-
);
131-
createSessionMethod.setAccessible(true);
132-
//noinspection unchecked
133-
return (Either<SessionNotCreatedException, Result>) createSessionMethod.invoke(
134-
this, client, contentSupplier, counter.getCount()
135-
);
136-
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
137-
throw new WebDriverException(e);
138-
}
110+
try {
111+
Method createSessionMethod = ProtocolHandshake.class.getDeclaredMethod(
112+
"createSession", HttpHandler.class, Contents.Supplier.class
113+
);
114+
createSessionMethod.setAccessible(true);
115+
//noinspection unchecked
116+
return (Either<SessionNotCreatedException, Result>) createSessionMethod.invoke(
117+
this, client, Contents.utf8String(stringWriter.toString())
118+
);
119+
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
120+
throw new WebDriverException(e);
139121
}
140122
}
141123
}

0 commit comments

Comments
 (0)