Commit acf6a450 authored by Torsten Grote's avatar Torsten Grote

Merge branch 'replace-assert-statements' into 'master'

Replace assert statements with AssertionErrors

See merge request briar/briar!877
parents e157fdfc 5a145c9e
......@@ -91,7 +91,7 @@ class AndroidNetworkManager implements NetworkManager, Service {
public NetworkStatus getNetworkStatus() {
ConnectivityManager cm = (ConnectivityManager)
appContext.getSystemService(CONNECTIVITY_SERVICE);
assert cm != null;
if (cm == null) throw new AssertionError();
NetworkInfo net = cm.getActiveNetworkInfo();
boolean connected = net != null && net.isConnected();
boolean wifi = connected && net.getType() == TYPE_WIFI;
......
......@@ -68,7 +68,7 @@ class AndroidLanTcpPlugin extends LanTcpPlugin implements EventListener {
new PoliteExecutor("AndroidLanTcpPlugin", ioExecutor, 1);
ConnectivityManager connectivityManager = (ConnectivityManager)
appContext.getSystemService(CONNECTIVITY_SERVICE);
assert connectivityManager != null;
if (connectivityManager == null) throw new AssertionError();
this.connectivityManager = connectivityManager;
wifiManager = (WifiManager) appContext.getApplicationContext()
.getSystemService(WIFI_SERVICE);
......
......@@ -46,7 +46,7 @@ class SyncRecordReaderImpl implements SyncRecordReader {
}
private void readRecord() throws IOException {
assert nextRecord == null;
if (nextRecord != null) throw new AssertionError();
while (true) {
nextRecord = reader.readRecord();
// Check the protocol version
......@@ -62,7 +62,7 @@ class SyncRecordReaderImpl implements SyncRecordReader {
}
private byte getNextRecordType() {
assert nextRecord != null;
if (nextRecord == null) throw new AssertionError();
return nextRecord.getRecordType();
}
......@@ -100,7 +100,7 @@ class SyncRecordReaderImpl implements SyncRecordReader {
}
private List<MessageId> readMessageIds() throws IOException {
assert nextRecord != null;
if (nextRecord == null) throw new AssertionError();
byte[] payload = nextRecord.getPayload();
if (payload.length == 0) throw new FormatException();
if (payload.length % UniqueId.LENGTH != 0) throw new FormatException();
......@@ -122,7 +122,7 @@ class SyncRecordReaderImpl implements SyncRecordReader {
@Override
public Message readMessage() throws IOException {
if (!hasMessage()) throw new FormatException();
assert nextRecord != null;
if (nextRecord == null) throw new AssertionError();
byte[] payload = nextRecord.getPayload();
if (payload.length < MESSAGE_HEADER_LENGTH) throw new FormatException();
// Validate timestamp
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment