Replace assert statements with AssertionErrors.

This commit is contained in:
akwizgran
2018-08-03 11:13:35 +01:00
parent d8ce1d75ca
commit 5a145c9eb2
3 changed files with 6 additions and 6 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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