From db80a1d4b2c4941a29dee494fc7c748093e0e124 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 12 Jun 2019 22:05:29 +0000 Subject: [PATCH 1/4] Bump jackson.version from 2.6.0 to 2.9.9 Bumps `jackson.version` from 2.6.0 to 2.9.9. Updates `jackson-databind` from 2.6.0 to 2.9.9 - [Release notes](https://github.com/FasterXML/jackson/releases) - [Commits](https://github.com/FasterXML/jackson/commits) Updates `jackson-core` from 2.6.0 to 2.9.9 - [Release notes](https://github.com/FasterXML/jackson-core/releases) - [Commits](https://github.com/FasterXML/jackson-core/compare/jackson-core-2.6.0...jackson-core-2.9.9) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0c6bdf9..7d7873e 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 1.8 2.75 - 2.6.0 + 2.9.9 4.3.8.RELEASE 1.3.1 0.1.54 From a63b5dc8ac3502155fb11494e763f4e94dd2ea15 Mon Sep 17 00:00:00 2001 From: Sakari Rautiainen Date: Wed, 12 Jun 2019 15:19:45 -0700 Subject: [PATCH 2/4] 0.3.3 SNAPSHOT release --- pom.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 7d7873e..bcf8d48 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,5 @@ - + 4.0.0 Bitbar Remote Device Client @@ -10,7 +8,7 @@ com.bitbar remote-device-client - 0.3.2 + 0.3.3-SNAPSHOT jar From e13b3ec81e6f54cbcbae52b726ee14bb23e04d65 Mon Sep 17 00:00:00 2001 From: Adrian Zybala Date: Wed, 16 Oct 2019 14:50:06 +0200 Subject: [PATCH 3/4] Updated dependencies Better messaging for device not found --- pom.xml | 6 +++--- .../bitbar/remotedevice/api/APIClientManager.java | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 40e5813..ef35cd8 100644 --- a/pom.xml +++ b/pom.xml @@ -15,11 +15,11 @@ 1.8 - 2.78 + 2.83 2.9.9 1.3.1 - 0.1.54 - 2.0.4.RELEASE + 0.1.55 + 2.0.9.RELEASE 1.7.13 diff --git a/src/main/java/com/bitbar/remotedevice/api/APIClientManager.java b/src/main/java/com/bitbar/remotedevice/api/APIClientManager.java index 33f4e7d..db9a5c6 100644 --- a/src/main/java/com/bitbar/remotedevice/api/APIClientManager.java +++ b/src/main/java/com/bitbar/remotedevice/api/APIClientManager.java @@ -11,6 +11,8 @@ import com.testdroid.api.filter.NumberFilterEntry; import com.testdroid.api.filter.StringFilterEntry; import com.testdroid.api.model.*; +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.HashSetValuedHashMap; import org.apache.commons.lang3.StringUtils; import java.util.*; @@ -61,8 +63,11 @@ public List getSupportedDevices() throws APIException { Context ctx = new Context<>(APIDevice.class); ctx.getFilters().add(new ListStringFilterEntry(MappingKey.OS_TYPE, Operand.IN, Arrays.asList(APIDevice.OsType.ANDROID.getDisplayName(), APIDevice.OsType.IOS.getDisplayName()))); - getRemoteSessionsLabelId().ifPresent(val -> - ctx.setExtraParams(Collections.singletonMap(MappingKey.LABEL_IDS_ARR, val))); + getRemoteSessionsLabelId().ifPresent(val -> { + MultiValuedMap map = new HashSetValuedHashMap<>(); + map.put(MappingKey.LABEL_IDS_ARR, val); + ctx.setExtraParams(map); + }); ctx.setLimit(0); List sortItems = new ArrayList<>(); sortItems.add(new APISort.SortItem(MappingKey.DISPLAY_NAME, APISort.Type.ASC)); @@ -75,6 +80,9 @@ public APIDevice getDevice(Long id) throws APIException { List filters = ctx.getFilters(); filters.add(new NumberFilterEntry(MappingKey.ID, Operand.EQ, id)); APIList devices = apiClient.getDevices(ctx).getEntity(); + if (devices.isEmpty()) { + throw new APIException(String.format("Could not find device with id %d", id)); + } return devices.get(0); } From b00318c83a433cbb624e536936d2bc842690dcca Mon Sep 17 00:00:00 2001 From: Adrian Zybala Date: Thu, 17 Oct 2019 12:04:03 +0200 Subject: [PATCH 4/4] Version 0.3.5 Fixed rare cases of tunnel connection reset --- pom.xml | 2 +- .../android/ADBPortForwarding.java | 26 +++++++++++++++++-- .../android/RemoteAndroidDeviceSession.java | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index ef35cd8..f102e65 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.bitbar remote-device-client - 0.3.4 + 0.3.5 jar diff --git a/src/main/java/com/bitbar/remotedevice/android/ADBPortForwarding.java b/src/main/java/com/bitbar/remotedevice/android/ADBPortForwarding.java index 85b097d..74eaf2d 100644 --- a/src/main/java/com/bitbar/remotedevice/android/ADBPortForwarding.java +++ b/src/main/java/com/bitbar/remotedevice/android/ADBPortForwarding.java @@ -12,6 +12,12 @@ public class ADBPortForwarding { private static final Logger LOGGER = LoggerFactory.getLogger(ADBPortForwarding.class); + private static final String CONNECTION_RESET_MESSAGE = "SocketException: Connection reset"; + + private static final long CONNECTION_RETRY_DELAY = 1000; + + private static final int MAX_CONNECTION_TRIES = 10; + private Session daemonSession; ADBPortForwarding(JSch jsch, String daemonHost, Integer daemonPort) throws JSchException { @@ -21,8 +27,21 @@ public class ADBPortForwarding { daemonSession.setPortForwardingL(LOCAL_PORT, REMOTE_ADB_HOST, REMOTE_FORWARDED_PORT); } - public void connect() throws JSchException { - daemonSession.connect(); + public void connect() throws JSchException, InterruptedException { + int tries = 1; + while (!daemonSession.isConnected()) { + try { + daemonSession.connect(); + } catch (JSchException e) { + if (tries < MAX_CONNECTION_TRIES && shouldBeRetried(e)) { + Thread.sleep(CONNECTION_RETRY_DELAY); + tries++; + } else { + throw e; + } + } + } + LOGGER.debug("SSH tunnel connected after {} tries", tries); daemonSession.openChannel(CONNECTION_CHANNEL); if (daemonSession.isConnected()) { LOGGER.info("ADB forwarding has started"); @@ -41,4 +60,7 @@ public void disconnect() { } } + private boolean shouldBeRetried(JSchException exception) { + return exception.getMessage().contains(CONNECTION_RESET_MESSAGE); + } } diff --git a/src/main/java/com/bitbar/remotedevice/android/RemoteAndroidDeviceSession.java b/src/main/java/com/bitbar/remotedevice/android/RemoteAndroidDeviceSession.java index 7592398..72dba86 100644 --- a/src/main/java/com/bitbar/remotedevice/android/RemoteAndroidDeviceSession.java +++ b/src/main/java/com/bitbar/remotedevice/android/RemoteAndroidDeviceSession.java @@ -34,7 +34,7 @@ public void handleAPIConnection(APIConnection connection) { adbPortForwarding = new ADBPortForwarding(jsch, connection.getHost(), connection.getPort()); adbPortForwarding.connect(); connected = true; - } catch (JSchException e) { + } catch (JSchException | InterruptedException e) { LOGGER.error("Problem occurred while trying to forward ADB port", e); stop(); }