2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-29 13:17:43 +00:00

Don't catch and rethrow

This commit is contained in:
Nicolas Fella 2018-09-29 21:08:45 +02:00
parent 93251ee7a6
commit b97ad28456
2 changed files with 7 additions and 19 deletions

View File

@ -57,22 +57,14 @@ public class LanLinkProviderTest extends AndroidTestCase {
Mockito.when(networkPacket.serialize()).thenReturn(serialized);
Socket channel = Mockito.mock(Socket.class);
try {
Method method = LanLinkProvider.class.getDeclaredMethod("identityPacketReceived", NetworkPacket.class, Socket.class, LanLink.ConnectionStarted.class);
method.setAccessible(true);
method.invoke(linkProvider, networkPacket, channel, LanLink.ConnectionStarted.Locally);
} catch (Exception e) {
throw e;
}
Method method = LanLinkProvider.class.getDeclaredMethod("identityPacketReceived", NetworkPacket.class, Socket.class, LanLink.ConnectionStarted.class);
method.setAccessible(true);
method.invoke(linkProvider, networkPacket, channel, LanLink.ConnectionStarted.Locally);
HashMap<String, LanLink> visibleComputers;
try {
Field field = LanLinkProvider.class.getDeclaredField("visibleComputers");
field.setAccessible(true);
visibleComputers = (HashMap<String, LanLink>) field.get(linkProvider);
} catch (Exception e) {
throw e;
}
Field field = LanLinkProvider.class.getDeclaredField("visibleComputers");
field.setAccessible(true);
visibleComputers = (HashMap<String, LanLink>) field.get(linkProvider);
assertNotNull(visibleComputers.get("testDevice"));
}

View File

@ -130,11 +130,7 @@ public class LanLinkTest extends AndroidTestCase {
socket.connect(new InetSocketAddress(address.getAddress(), tcpPort));
np.setPayload(socket.getInputStream(), np.getPayloadSize());
} catch (Exception e) {
try {
socket.close();
} catch (Exception ignored) {
throw ignored;
}
socket.close();
e.printStackTrace();
Log.e("KDE/LanLinkTest", "Exception connecting to remote socket");
throw e;