mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-24 08:39:53 +01:00
Avoid NoSuchElementException if the connection stalls.
This commit is contained in:
@@ -19,6 +19,7 @@ abstract class BluetoothTest {
|
||||
out.println(CHALLENGE);
|
||||
System.out.println("Sent challenge: " + CHALLENGE);
|
||||
Scanner in = new Scanner(s.getInputStream());
|
||||
if(in.hasNextLine()) {
|
||||
String response = in.nextLine();
|
||||
System.out.println("Received response: " + response);
|
||||
if(BluetoothClientTest.RESPONSE.equals(response)) {
|
||||
@@ -26,6 +27,9 @@ abstract class BluetoothTest {
|
||||
} else {
|
||||
System.out.println("Incorrect response");
|
||||
}
|
||||
} else {
|
||||
System.out.println("No response");
|
||||
}
|
||||
s.dispose(true);
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -36,6 +40,7 @@ abstract class BluetoothTest {
|
||||
void receiveChallengeAndSendResponse(StreamTransportConnection s) {
|
||||
try {
|
||||
Scanner in = new Scanner(s.getInputStream());
|
||||
if(in.hasNextLine()) {
|
||||
String challenge = in.nextLine();
|
||||
System.out.println("Received challenge: " + challenge);
|
||||
if(BluetoothServerTest.CHALLENGE.equals(challenge)) {
|
||||
@@ -45,6 +50,9 @@ abstract class BluetoothTest {
|
||||
} else {
|
||||
System.out.println("Incorrect challenge");
|
||||
}
|
||||
} else {
|
||||
System.out.println("No challenge");
|
||||
}
|
||||
s.dispose(true);
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user