Skip to content

Commit a542fee

Browse files
TikhomirovSergeySrinivasanTarget
authored andcommitted
Addition to #846 and #855: (#869)
* Addition to #846 and #855: - OkHttpClient instead of ApacheHttpClient - fix of java.lang.IllegalArgumentException: Input byte array has incorrect ending byte at... * Addition to #846 and #855: - using of mime encoder/decoder
1 parent 0b2c407 commit a542fee

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/main/java/io/appium/java_client/clipboard/HasClipboard.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ default String getClipboard(ClipboardContentType contentType) {
6161
*/
6262
default void setClipboardText(String text) {
6363
setClipboard(ClipboardContentType.PLAINTEXT, Base64
64-
.getEncoder()
64+
.getMimeEncoder()
6565
.encode(text.getBytes(StandardCharsets.UTF_8)));
6666
}
6767

@@ -72,7 +72,7 @@ default void setClipboardText(String text) {
7272
*/
7373
default String getClipboardText() {
7474
byte[] base64decodedBytes = Base64
75-
.getDecoder()
75+
.getMimeDecoder()
7676
.decode(getClipboard(ClipboardContentType.PLAINTEXT));
7777
return new String(base64decodedBytes, StandardCharsets.UTF_8);
7878
}

src/main/java/io/appium/java_client/ios/HasIOSClipboard.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ default void setClipboardImage(BufferedImage img) throws IOException {
4242
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
4343
ImageIO.write(checkNotNull(img), "png", os);
4444
setClipboard(ClipboardContentType.IMAGE, Base64
45-
.getEncoder()
45+
.getMimeEncoder()
4646
.encode(os.toByteArray()));
4747
}
4848
}
@@ -55,7 +55,7 @@ default void setClipboardImage(BufferedImage img) throws IOException {
5555
*/
5656
default BufferedImage getClipboardImage() throws IOException {
5757
final byte[] base64decodedBytes = Base64
58-
.getDecoder()
58+
.getMimeDecoder()
5959
.decode(getClipboard(ClipboardContentType.IMAGE));
6060
return ImageIO.read(new ByteArrayInputStream(base64decodedBytes));
6161
}
@@ -67,7 +67,7 @@ default BufferedImage getClipboardImage() throws IOException {
6767
*/
6868
default void setClipboardUrl(URL url) {
6969
setClipboard(ClipboardContentType.URL, Base64
70-
.getEncoder()
70+
.getMimeEncoder()
7171
.encode(checkNotNull(url).toString().getBytes(StandardCharsets.UTF_8)));
7272
}
7373

@@ -79,7 +79,7 @@ default void setClipboardUrl(URL url) {
7979
*/
8080
default URL getClipboardUrl() throws MalformedURLException {
8181
final byte[] base64decodedBytes = Base64
82-
.getDecoder()
82+
.getMimeDecoder()
8383
.decode(getClipboard(ClipboardContentType.URL));
8484
return new URL(new String(base64decodedBytes, StandardCharsets.UTF_8));
8585
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.openqa.selenium.remote.http.HttpClient;
3434
import org.openqa.selenium.remote.http.HttpRequest;
3535
import org.openqa.selenium.remote.http.W3CHttpCommandCodec;
36-
import org.openqa.selenium.remote.internal.ApacheHttpClient;
36+
import org.openqa.selenium.remote.internal.OkHttpClient;
3737
import org.openqa.selenium.remote.service.DriverService;
3838

3939
import java.io.IOException;
@@ -70,12 +70,12 @@ public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
7070

7171
public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
7272
URL addressOfRemoteServer) {
73-
this(additionalCommands, addressOfRemoteServer, new ApacheHttpClient.Factory());
73+
this(additionalCommands, addressOfRemoteServer, new OkHttpClient.Factory());
7474
}
7575

7676
public AppiumCommandExecutor(Map<String, CommandInfo> additionalCommands,
7777
DriverService service) {
78-
this(additionalCommands, service, new ApacheHttpClient.Factory());
78+
this(additionalCommands, service, new OkHttpClient.Factory());
7979
}
8080

8181
private <B> B getPrivateFieldValue(String fieldName, Class<B> fieldType) {

0 commit comments

Comments
 (0)