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:
parent
93251ee7a6
commit
b97ad28456
@ -57,22 +57,14 @@ public class LanLinkProviderTest extends AndroidTestCase {
|
|||||||
Mockito.when(networkPacket.serialize()).thenReturn(serialized);
|
Mockito.when(networkPacket.serialize()).thenReturn(serialized);
|
||||||
|
|
||||||
Socket channel = Mockito.mock(Socket.class);
|
Socket channel = Mockito.mock(Socket.class);
|
||||||
try {
|
|
||||||
Method method = LanLinkProvider.class.getDeclaredMethod("identityPacketReceived", NetworkPacket.class, Socket.class, LanLink.ConnectionStarted.class);
|
Method method = LanLinkProvider.class.getDeclaredMethod("identityPacketReceived", NetworkPacket.class, Socket.class, LanLink.ConnectionStarted.class);
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
method.invoke(linkProvider, networkPacket, channel, LanLink.ConnectionStarted.Locally);
|
method.invoke(linkProvider, networkPacket, channel, LanLink.ConnectionStarted.Locally);
|
||||||
} catch (Exception e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
HashMap<String, LanLink> visibleComputers;
|
HashMap<String, LanLink> visibleComputers;
|
||||||
try {
|
|
||||||
Field field = LanLinkProvider.class.getDeclaredField("visibleComputers");
|
Field field = LanLinkProvider.class.getDeclaredField("visibleComputers");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
visibleComputers = (HashMap<String, LanLink>) field.get(linkProvider);
|
visibleComputers = (HashMap<String, LanLink>) field.get(linkProvider);
|
||||||
} catch (Exception e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
assertNotNull(visibleComputers.get("testDevice"));
|
assertNotNull(visibleComputers.get("testDevice"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -130,11 +130,7 @@ public class LanLinkTest extends AndroidTestCase {
|
|||||||
socket.connect(new InetSocketAddress(address.getAddress(), tcpPort));
|
socket.connect(new InetSocketAddress(address.getAddress(), tcpPort));
|
||||||
np.setPayload(socket.getInputStream(), np.getPayloadSize());
|
np.setPayload(socket.getInputStream(), np.getPayloadSize());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
try {
|
|
||||||
socket.close();
|
socket.close();
|
||||||
} catch (Exception ignored) {
|
|
||||||
throw ignored;
|
|
||||||
}
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Log.e("KDE/LanLinkTest", "Exception connecting to remote socket");
|
Log.e("KDE/LanLinkTest", "Exception connecting to remote socket");
|
||||||
throw e;
|
throw e;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user