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