Removed unnecessary conditionals from logging statements.

Very important stuff.
This commit is contained in:
akwizgran
2014-03-12 21:00:14 +00:00
parent 375a597dd2
commit b99a503f24
33 changed files with 165 additions and 240 deletions

View File

@@ -2,7 +2,6 @@ package org.briarproject.android;
import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION; import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION;
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP; import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
import static java.util.logging.Level.INFO;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -88,12 +87,11 @@ public class BriarActivity extends RoboFragmentActivity {
BriarService service = ((BriarBinder) binder).getService(); BriarService service = ((BriarBinder) binder).getService();
service.waitForStartup(); service.waitForStartup();
// Shut down the service and wait for it to shut down // Shut down the service and wait for it to shut down
if(LOG.isLoggable(INFO)) LOG.info("Shutting down service"); LOG.info("Shutting down service");
service.shutdown(); service.shutdown();
service.waitForShutdown(); service.waitForShutdown();
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while waiting for service");
LOG.info("Interrupted while waiting for service");
} }
finishAndExit(); finishAndExit();
} }
@@ -104,7 +102,7 @@ public class BriarActivity extends RoboFragmentActivity {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
finish(); finish();
if(LOG.isLoggable(INFO)) LOG.info("Exiting"); LOG.info("Exiting");
System.exit(0); System.exit(0);
} }
}); });
@@ -117,8 +115,7 @@ public class BriarActivity extends RoboFragmentActivity {
lifecycleManager.waitForDatabase(); lifecycleManager.waitForDatabase();
task.run(); task.run();
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while waiting for database");
LOG.info("Interrupted while waiting for database");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }

View File

@@ -3,7 +3,6 @@ package org.briarproject.android;
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP; import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP; import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
@@ -61,14 +60,14 @@ public class BriarService extends RoboService implements EventListener {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
if(LOG.isLoggable(INFO)) LOG.info("Created"); LOG.info("Created");
if(created.getAndSet(true)) { if(created.getAndSet(true)) {
if(LOG.isLoggable(INFO)) LOG.info("Already created"); LOG.info("Already created");
stopSelf(); stopSelf();
return; return;
} }
if(databaseConfig.getEncryptionKey() == null) { if(databaseConfig.getEncryptionKey() == null) {
if(LOG.isLoggable(INFO)) LOG.info("No database key"); LOG.info("No database key");
stopSelf(); stopSelf();
return; return;
} }
@@ -92,7 +91,7 @@ public class BriarService extends RoboService implements EventListener {
db.addListener(BriarService.this); db.addListener(BriarService.this);
started = true; started = true;
} else { } else {
if(LOG.isLoggable(INFO)) LOG.info("Startup failed"); LOG.info("Startup failed");
showStartupFailureNotification(); showStartupFailureNotification();
stopSelf(); stopSelf();
} }
@@ -130,7 +129,7 @@ public class BriarService extends RoboService implements EventListener {
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
if(LOG.isLoggable(INFO)) LOG.info("Destroyed"); LOG.info("Destroyed");
stopForeground(true); stopForeground(true);
notificationManager.clearNotifications(); notificationManager.clearNotifications();
// Stop the services in a background thread // Stop the services in a background thread
@@ -167,8 +166,7 @@ public class BriarService extends RoboService implements EventListener {
if(LOG.isLoggable(WARNING)) if(LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e); LOG.log(WARNING, e.toString(), e);
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.info("Interruped while waiting for database");
LOG.info("Interruped while waiting for database");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }

View File

@@ -61,7 +61,7 @@ public class DashboardActivity extends BriarActivity {
long handle = i.getLongExtra("briar.LOCAL_AUTHOR_HANDLE", -1); long handle = i.getLongExtra("briar.LOCAL_AUTHOR_HANDLE", -1);
if(failed) { if(failed) {
finish(); finish();
if(LOG.isLoggable(INFO)) LOG.info("Exiting"); LOG.info("Exiting");
System.exit(0); System.exit(0);
} else if(handle == -1) { } else if(handle == -1) {
// The activity has been launched before // The activity has been launched before

View File

@@ -64,7 +64,7 @@ public class SplashScreenActivity extends RoboSplashActivity {
if(LOG.isLoggable(INFO)) if(LOG.isLoggable(INFO))
LOG.info("Guice startup took " + duration + " ms"); LOG.info("Guice startup took " + duration + " ms");
if(System.currentTimeMillis() >= EXPIRY_DATE) { if(System.currentTimeMillis() >= EXPIRY_DATE) {
if(LOG.isLoggable(INFO)) LOG.info("Expired"); LOG.info("Expired");
startActivity(new Intent(this, ExpiredActivity.class)); startActivity(new Intent(this, ExpiredActivity.class));
} else { } else {
SharedPreferences prefs = getSharedPreferences("db", MODE_PRIVATE); SharedPreferences prefs = getSharedPreferences("db", MODE_PRIVATE);

View File

@@ -233,15 +233,15 @@ ConnectionListener {
loadContacts(); loadContacts();
} else if(e instanceof ContactRemovedEvent) { } else if(e instanceof ContactRemovedEvent) {
// Reload the conversation, expecting NoSuchContactException // Reload the conversation, expecting NoSuchContactException
if(LOG.isLoggable(INFO)) LOG.info("Contact removed, reloading"); LOG.info("Contact removed, reloading");
reloadContact(((ContactRemovedEvent) e).getContactId()); reloadContact(((ContactRemovedEvent) e).getContactId());
} else if(e instanceof MessageAddedEvent) { } else if(e instanceof MessageAddedEvent) {
if(LOG.isLoggable(INFO)) LOG.info("Message added, reloading"); LOG.info("Message added, reloading");
ContactId source = ((MessageAddedEvent) e).getContactId(); ContactId source = ((MessageAddedEvent) e).getContactId();
if(source == null) loadContacts(); if(source == null) loadContacts();
else reloadContact(source); else reloadContact(source);
} else if(e instanceof MessageExpiredEvent) { } else if(e instanceof MessageExpiredEvent) {
if(LOG.isLoggable(INFO)) LOG.info("Message expired, reloading"); LOG.info("Message expired, reloading");
loadContacts(); loadContacts();
} }
} }

View File

@@ -369,17 +369,17 @@ implements EventListener, OnClickListener, OnItemClickListener {
if(e instanceof ContactRemovedEvent) { if(e instanceof ContactRemovedEvent) {
ContactRemovedEvent c = (ContactRemovedEvent) e; ContactRemovedEvent c = (ContactRemovedEvent) e;
if(c.getContactId().equals(contactId)) { if(c.getContactId().equals(contactId)) {
if(LOG.isLoggable(INFO)) LOG.info("Contact removed"); LOG.info("Contact removed");
finishOnUiThread(); finishOnUiThread();
} }
} else if(e instanceof MessageAddedEvent) { } else if(e instanceof MessageAddedEvent) {
GroupId g = ((MessageAddedEvent) e).getGroup().getId(); GroupId g = ((MessageAddedEvent) e).getGroup().getId();
if(g.equals(groupId)) { if(g.equals(groupId)) {
if(LOG.isLoggable(INFO)) LOG.info("Message added, reloading"); LOG.info("Message added, reloading");
loadHeaders(); loadHeaders();
} }
} else if(e instanceof MessageExpiredEvent) { } else if(e instanceof MessageExpiredEvent) {
if(LOG.isLoggable(INFO)) LOG.info("Message expired, reloading"); LOG.info("Message expired, reloading");
loadHeaders(); loadHeaders();
} }
} }

View File

@@ -299,16 +299,16 @@ OnClickListener, OnItemClickListener {
public void eventOccurred(Event e) { public void eventOccurred(Event e) {
if(e instanceof MessageAddedEvent) { if(e instanceof MessageAddedEvent) {
if(((MessageAddedEvent) e).getGroup().getId().equals(groupId)) { if(((MessageAddedEvent) e).getGroup().getId().equals(groupId)) {
if(LOG.isLoggable(INFO)) LOG.info("Message added, reloading"); LOG.info("Message added, reloading");
loadHeaders(); loadHeaders();
} }
} else if(e instanceof MessageExpiredEvent) { } else if(e instanceof MessageExpiredEvent) {
if(LOG.isLoggable(INFO)) LOG.info("Message expired, reloading"); LOG.info("Message expired, reloading");
loadHeaders(); loadHeaders();
} else if(e instanceof SubscriptionRemovedEvent) { } else if(e instanceof SubscriptionRemovedEvent) {
SubscriptionRemovedEvent s = (SubscriptionRemovedEvent) e; SubscriptionRemovedEvent s = (SubscriptionRemovedEvent) e;
if(s.getGroup().getId().equals(groupId)) { if(s.getGroup().getId().equals(groupId)) {
if(LOG.isLoggable(INFO)) LOG.info("Subscription removed"); LOG.info("Subscription removed");
finishOnUiThread(); finishOnUiThread();
} }
} }

View File

@@ -262,24 +262,23 @@ implements EventListener, OnClickListener, OnItemClickListener {
if(e instanceof MessageAddedEvent) { if(e instanceof MessageAddedEvent) {
Group g = ((MessageAddedEvent) e).getGroup(); Group g = ((MessageAddedEvent) e).getGroup();
if(groups.containsKey(g.getId())) { if(groups.containsKey(g.getId())) {
if(LOG.isLoggable(INFO)) LOG.info("Message added, reloading"); LOG.info("Message added, reloading");
loadHeaders(g); loadHeaders(g);
} }
} else if(e instanceof MessageExpiredEvent) { } else if(e instanceof MessageExpiredEvent) {
if(LOG.isLoggable(INFO)) LOG.info("Message expired, reloading"); LOG.info("Message expired, reloading");
loadHeaders(); loadHeaders();
} else if(e instanceof RemoteSubscriptionsUpdatedEvent) { } else if(e instanceof RemoteSubscriptionsUpdatedEvent) {
if(LOG.isLoggable(INFO)) LOG.info("Remote subscriptions changed, reloading");
LOG.info("Remote subscriptions changed, reloading");
loadAvailable(); loadAvailable();
} else if(e instanceof SubscriptionAddedEvent) { } else if(e instanceof SubscriptionAddedEvent) {
if(LOG.isLoggable(INFO)) LOG.info("Group added, reloading"); LOG.info("Group added, reloading");
loadHeaders(); loadHeaders();
} else if(e instanceof SubscriptionRemovedEvent) { } else if(e instanceof SubscriptionRemovedEvent) {
Group g = ((SubscriptionRemovedEvent) e).getGroup(); Group g = ((SubscriptionRemovedEvent) e).getGroup();
if(groups.containsKey(g.getId())) { if(groups.containsKey(g.getId())) {
// Reload the group, expecting NoSuchSubscriptionException // Reload the group, expecting NoSuchSubscriptionException
if(LOG.isLoggable(INFO)) LOG.info("Group removed, reloading"); LOG.info("Group removed, reloading");
loadHeaders(g); loadHeaders(g);
} }
} }

View File

@@ -116,14 +116,13 @@ implements EventListener, OnItemClickListener {
public void eventOccurred(Event e) { public void eventOccurred(Event e) {
if(e instanceof RemoteSubscriptionsUpdatedEvent) { if(e instanceof RemoteSubscriptionsUpdatedEvent) {
if(LOG.isLoggable(INFO)) LOG.info("Remote subscriptions changed, reloading");
LOG.info("Remote subscriptions changed, reloading");
loadGroups(); loadGroups();
} else if(e instanceof SubscriptionAddedEvent) { } else if(e instanceof SubscriptionAddedEvent) {
if(LOG.isLoggable(INFO)) LOG.info("Group added, reloading"); LOG.info("Group added, reloading");
loadGroups(); loadGroups();
} else if(e instanceof SubscriptionRemovedEvent) { } else if(e instanceof SubscriptionRemovedEvent) {
if(LOG.isLoggable(INFO)) LOG.info("Group removed, reloading"); LOG.info("Group removed, reloading");
loadGroups(); loadGroups();
} }
} }

View File

@@ -115,7 +115,7 @@ class DroidtoothPlugin implements DuplexPlugin {
throw new IOException(e.toString()); throw new IOException(e.toString());
} }
if(adapter == null) { if(adapter == null) {
if(LOG.isLoggable(INFO)) LOG.info("Bluetooth is not supported"); LOG.info("Bluetooth is not supported");
return false; return false;
} }
running = true; running = true;
@@ -156,12 +156,12 @@ class DroidtoothPlugin implements DuplexPlugin {
private boolean enableBluetooth() { private boolean enableBluetooth() {
if(adapter.isEnabled()) return true; if(adapter.isEnabled()) return true;
if(!callback.getConfig().getBoolean("enable", true)) { if(!callback.getConfig().getBoolean("enable", true)) {
if(LOG.isLoggable(INFO)) LOG.info("Not enabling Bluetooth"); LOG.info("Not enabling Bluetooth");
return false; return false;
} }
wasDisabled = true; wasDisabled = true;
// Try to enable the adapter and wait for the result // Try to enable the adapter and wait for the result
if(LOG.isLoggable(INFO)) LOG.info("Enabling Bluetooth"); LOG.info("Enabling Bluetooth");
IntentFilter filter = new IntentFilter(ACTION_STATE_CHANGED); IntentFilter filter = new IntentFilter(ACTION_STATE_CHANGED);
BluetoothStateReceiver receiver = new BluetoothStateReceiver(); BluetoothStateReceiver receiver = new BluetoothStateReceiver();
appContext.registerReceiver(receiver, filter); appContext.registerReceiver(receiver, filter);
@@ -171,12 +171,11 @@ class DroidtoothPlugin implements DuplexPlugin {
if(LOG.isLoggable(INFO)) LOG.info("Enabled: " + enabled); if(LOG.isLoggable(INFO)) LOG.info("Enabled: " + enabled);
return enabled; return enabled;
} else { } else {
if(LOG.isLoggable(INFO)) LOG.info("Could not enable Bluetooth"); LOG.info("Could not enable Bluetooth");
return false; return false;
} }
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while enabling Bluetooth");
LOG.info("Interrupted while enabling Bluetooth");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
return false; return false;
} }
@@ -233,7 +232,7 @@ class DroidtoothPlugin implements DuplexPlugin {
private void disableBluetooth() { private void disableBluetooth() {
if(!adapter.isEnabled()) return; if(!adapter.isEnabled()) return;
// Try to disable the adapter and wait for the result // Try to disable the adapter and wait for the result
if(LOG.isLoggable(INFO)) LOG.info("Disabling Bluetooth"); LOG.info("Disabling Bluetooth");
IntentFilter filter = new IntentFilter(ACTION_STATE_CHANGED); IntentFilter filter = new IntentFilter(ACTION_STATE_CHANGED);
BluetoothStateReceiver receiver = new BluetoothStateReceiver(); BluetoothStateReceiver receiver = new BluetoothStateReceiver();
appContext.registerReceiver(receiver, filter); appContext.registerReceiver(receiver, filter);
@@ -242,12 +241,10 @@ class DroidtoothPlugin implements DuplexPlugin {
boolean enabled = receiver.waitForStateChange(); boolean enabled = receiver.waitForStateChange();
if(LOG.isLoggable(INFO)) LOG.info("Enabled: " + enabled); if(LOG.isLoggable(INFO)) LOG.info("Enabled: " + enabled);
} else { } else {
if(LOG.isLoggable(INFO)) LOG.info("Could not disable Bluetooth");
LOG.info("Could not disable Bluetooth");
} }
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while disabling Bluetooth");
LOG.info("Interrupted while disabling Bluetooth");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }
@@ -372,8 +369,7 @@ class DroidtoothPlugin implements DuplexPlugin {
BluetoothSocket s = socketLatch.waitForReference(timeout); BluetoothSocket s = socketLatch.waitForReference(timeout);
if(s != null) return new DroidtoothTransportConnection(this, s); if(s != null) return new DroidtoothTransportConnection(this, s);
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while exchanging invitations");
LOG.info("Interrupted while exchanging invitations");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} finally { } finally {
// Closing the socket will terminate the listener thread // Closing the socket will terminate the listener thread
@@ -425,13 +421,12 @@ class DroidtoothPlugin implements DuplexPlugin {
long end = now + timeout; long end = now + timeout;
while(now < end && running && !socketLatch.isSet()) { while(now < end && running && !socketLatch.isSet()) {
// Discover nearby devices // Discover nearby devices
if(LOG.isLoggable(INFO)) LOG.info("Discovering nearby devices"); LOG.info("Discovering nearby devices");
List<String> addresses; List<String> addresses;
try { try {
addresses = discoverDevices(end - now); addresses = discoverDevices(end - now);
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while discovering devices");
LOG.info("Interrupted while discovering devices");
return; return;
} }
// Connect to any device with the right UUID // Connect to any device with the right UUID
@@ -440,11 +435,9 @@ class DroidtoothPlugin implements DuplexPlugin {
if(now < end && running && !socketLatch.isSet()) { if(now < end && running && !socketLatch.isSet()) {
BluetoothSocket s = connect(address, uuid); BluetoothSocket s = connect(address, uuid);
if(s == null) continue; if(s == null) continue;
if(LOG.isLoggable(INFO)) LOG.info("Outgoing connection");
LOG.info("Outgoing connection");
if(!socketLatch.set(s)) { if(!socketLatch.set(s)) {
if(LOG.isLoggable(INFO)) LOG.info("Closing redundant connection");
LOG.info("Closing redundant connection");
tryToClose(s); tryToClose(s);
} }
return; return;
@@ -505,10 +498,9 @@ class DroidtoothPlugin implements DuplexPlugin {
public void run() { public void run() {
try { try {
BluetoothSocket s = serverSocket.accept(); BluetoothSocket s = serverSocket.accept();
if(LOG.isLoggable(INFO)) LOG.info("Incoming connection"); LOG.info("Incoming connection");
if(!socketLatch.set(s)) { if(!socketLatch.set(s)) {
if(LOG.isLoggable(INFO)) LOG.info("Closing redundant connection");
LOG.info("Closing redundant connection");
s.close(); s.close();
} }
} catch(IOException e) { } catch(IOException e) {

View File

@@ -1,7 +1,5 @@
package org.briarproject.plugins.droidtooth; package org.briarproject.plugins.droidtooth;
import static java.util.logging.Level.INFO;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@@ -33,12 +31,12 @@ class InsecureBluetooth {
static BluetoothServerSocket listen(BluetoothAdapter adapter, String name, static BluetoothServerSocket listen(BluetoothAdapter adapter, String name,
UUID uuid) throws IOException { UUID uuid) throws IOException {
if(Build.VERSION.SDK_INT >= 10) { if(Build.VERSION.SDK_INT >= 10) {
if(LOG.isLoggable(INFO)) LOG.info("Listening with new API"); LOG.info("Listening with new API");
return adapter.listenUsingInsecureRfcommWithServiceRecord(name, return adapter.listenUsingInsecureRfcommWithServiceRecord(name,
uuid); uuid);
} }
try { try {
if(LOG.isLoggable(INFO)) LOG.info("Listening via reflection"); LOG.info("Listening via reflection");
// Find an available channel // Find an available channel
String className = BluetoothAdapter.class.getCanonicalName() String className = BluetoothAdapter.class.getCanonicalName()
+ ".RfcommChannelPicker"; + ".RfcommChannelPicker";
@@ -144,11 +142,11 @@ class InsecureBluetooth {
static BluetoothSocket createSocket(BluetoothDevice device, UUID uuid) static BluetoothSocket createSocket(BluetoothDevice device, UUID uuid)
throws IOException { throws IOException {
if(Build.VERSION.SDK_INT >= 10) { if(Build.VERSION.SDK_INT >= 10) {
if(LOG.isLoggable(INFO)) LOG.info("Creating socket with new API"); LOG.info("Creating socket with new API");
return device.createInsecureRfcommSocketToServiceRecord(uuid); return device.createInsecureRfcommSocketToServiceRecord(uuid);
} }
try { try {
if(LOG.isLoggable(INFO)) LOG.info("Creating socket via reflection"); LOG.info("Creating socket via reflection");
Constructor<BluetoothSocket> constructor = Constructor<BluetoothSocket> constructor =
BluetoothSocket.class.getDeclaredConstructor(int.class, BluetoothSocket.class.getDeclaredConstructor(int.class,
int.class, boolean.class, boolean.class, int.class, boolean.class, boolean.class,

View File

@@ -122,23 +122,23 @@ class TorPlugin implements DuplexPlugin, EventHandler {
boolean startProcess = false; boolean startProcess = false;
try { try {
controlSocket = new Socket("127.0.0.1", CONTROL_PORT); controlSocket = new Socket("127.0.0.1", CONTROL_PORT);
if(LOG.isLoggable(INFO)) LOG.info("Tor is already running"); LOG.info("Tor is already running");
if(readPidFile() == -1) { if(readPidFile() == -1) {
controlSocket.close(); controlSocket.close();
killZombieProcess(); killZombieProcess();
startProcess = true; startProcess = true;
} }
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(INFO)) LOG.info("Tor is not running"); LOG.info("Tor is not running");
startProcess = true; startProcess = true;
} }
if(startProcess) { if(startProcess) {
// Install the binary, GeoIP database and config file if necessary // Install the binary, GeoIP database and config file if necessary
if(!isInstalled() && !install()) { if(!isInstalled() && !install()) {
if(LOG.isLoggable(INFO)) LOG.info("Could not install Tor"); LOG.info("Could not install Tor");
return false; return false;
} }
if(LOG.isLoggable(INFO)) LOG.info("Starting Tor"); LOG.info("Starting Tor");
// Watch for the auth cookie file being created/updated // Watch for the auth cookie file being created/updated
cookieFile.getParentFile().mkdirs(); cookieFile.getParentFile().mkdirs();
cookieFile.createNewFile(); cookieFile.createNewFile();
@@ -172,14 +172,12 @@ class TorPlugin implements DuplexPlugin, EventHandler {
} }
// Wait for the auth cookie file to be created/updated // Wait for the auth cookie file to be created/updated
if(!latch.await(COOKIE_TIMEOUT, MILLISECONDS)) { if(!latch.await(COOKIE_TIMEOUT, MILLISECONDS)) {
if(LOG.isLoggable(WARNING)) LOG.warning("Auth cookie not created");
LOG.warning("Auth cookie not created");
listFiles(torDirectory); listFiles(torDirectory);
return false; return false;
} }
} catch(InterruptedException e1) { } catch(InterruptedException e1) {
if(LOG.isLoggable(WARNING)) LOG.warning("Interrupted while starting Tor");
LOG.warning("Interrupted while starting Tor");
return false; return false;
} }
// Now we should be able to connect to the new process // Now we should be able to connect to the new process
@@ -236,8 +234,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
copy(in, out); copy(in, out);
// Make the Tor binary executable // Make the Tor binary executable
if(!setExecutable(torFile)) { if(!setExecutable(torFile)) {
if(LOG.isLoggable(WARNING)) LOG.warning("Could not make Tor executable");
LOG.warning("Could not make Tor executable");
return false; return false;
} }
// Create a file to indicate that installation succeeded // Create a file to indicate that installation succeeded
@@ -291,8 +288,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Interrupted while executing chmod");
LOG.warning("Interrupted while executing chmod");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} catch(SecurityException e) { } catch(SecurityException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -343,9 +339,9 @@ class TorPlugin implements DuplexPlugin, EventHandler {
try { try {
return Integer.parseInt(new String(read(pidFile), "UTF-8").trim()); return Integer.parseInt(new String(read(pidFile), "UTF-8").trim());
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Could not read PID file"); LOG.warning("Could not read PID file");
} catch(NumberFormatException e) { } catch(NumberFormatException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Could not parse PID file"); LOG.warning("Could not parse PID file");
} }
return -1; return -1;
} }
@@ -383,20 +379,18 @@ class TorPlugin implements DuplexPlugin, EventHandler {
found = true; found = true;
} }
} }
if(!found) if(LOG.isLoggable(INFO)) LOG.info("No zombies found"); if(!found) LOG.info("No zombies found");
scanner.close(); scanner.close();
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Could not parse ps output");
LOG.warning("Could not parse ps output");
} catch(SecurityException e) { } catch(SecurityException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Could not execute ps"); LOG.warning("Could not execute ps");
} }
} }
private void killTorProcess() { private void killTorProcess() {
if(tor != null) { if(tor != null) {
if(LOG.isLoggable(INFO)) LOG.info("Killing Tor via destroy()");
LOG.info("Killing Tor via destroy()");
tor.destroy(); tor.destroy();
} }
if(pid != -1) { if(pid != -1) {
@@ -452,7 +446,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
private void publishHiddenService(final String port) { private void publishHiddenService(final String port) {
if(!running) return; if(!running) return;
if(!hostnameFile.exists()) { if(!hostnameFile.exists()) {
if(LOG.isLoggable(INFO)) LOG.info("Creating hidden service"); LOG.info("Creating hidden service");
try { try {
// Watch for the hostname file being created/updated // Watch for the hostname file being created/updated
hostnameFile.getParentFile().mkdirs(); hostnameFile.getParentFile().mkdirs();
@@ -468,8 +462,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
controlConnection.saveConf(); controlConnection.saveConf();
// Wait for the hostname file to be created/updated // Wait for the hostname file to be created/updated
if(!latch.await(HOSTNAME_TIMEOUT, MILLISECONDS)) { if(!latch.await(HOSTNAME_TIMEOUT, MILLISECONDS)) {
if(LOG.isLoggable(WARNING)) LOG.warning("Hidden service not created");
LOG.warning("Hidden service not created");
listFiles(torDirectory); listFiles(torDirectory);
return; return;
} }
@@ -477,8 +470,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Interrupted while creating hidden service");
LOG.warning("Interrupted while creating hidden service");
} }
} }
// Publish the hidden service's onion hostname in transport properties // Publish the hidden service's onion hostname in transport properties
@@ -504,7 +496,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
tryToClose(ss); tryToClose(ss);
return; return;
} }
if(LOG.isLoggable(INFO)) LOG.info("Connection received"); LOG.info("Connection received");
TorTransportConnection conn = new TorTransportConnection(this, s); TorTransportConnection conn = new TorTransportConnection(this, s);
callback.incomingConnectionCreated(conn); callback.incomingConnectionCreated(conn);
if(!running) return; if(!running) return;
@@ -524,7 +516,7 @@ class TorPlugin implements DuplexPlugin, EventHandler {
if(networkStateReceiver != null) if(networkStateReceiver != null)
appContext.unregisterReceiver(networkStateReceiver); appContext.unregisterReceiver(networkStateReceiver);
try { try {
if(LOG.isLoggable(INFO)) LOG.info("Stopping Tor"); LOG.info("Stopping Tor");
if(controlSocket == null) if(controlSocket == null)
controlSocket = new Socket("127.0.0.1", CONTROL_PORT); controlSocket = new Socket("127.0.0.1", CONTROL_PORT);
if(controlConnection == null) { if(controlConnection == null) {

View File

@@ -1,6 +1,5 @@
package org.briarproject.db; package org.briarproject.db;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
import java.util.TimerTask; import java.util.TimerTask;
@@ -39,11 +38,11 @@ class DatabaseCleanerImpl extends TimerTask implements DatabaseCleaner {
if(callback == null) throw new IllegalStateException(); if(callback == null) throw new IllegalStateException();
try { try {
if(callback.shouldCheckFreeSpace()) { if(callback.shouldCheckFreeSpace()) {
if(LOG.isLoggable(INFO)) LOG.info("Checking free space"); LOG.info("Checking free space");
callback.checkFreeSpaceAndClean(); callback.checkFreeSpaceAndClean();
} }
} catch(DbClosedException e) { } catch(DbClosedException e) {
if(LOG.isLoggable(INFO)) LOG.info("Database closed, exiting"); LOG.info("Database closed, exiting");
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
throw new Error(e); // Kill the application throw new Error(e); // Kill the application

View File

@@ -2,7 +2,6 @@ package org.briarproject.db;
import static java.sql.Types.BINARY; import static java.sql.Types.BINARY;
import static java.sql.Types.VARCHAR; import static java.sql.Types.VARCHAR;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
import static org.briarproject.api.Author.Status.ANONYMOUS; import static org.briarproject.api.Author.Status.ANONYMOUS;
import static org.briarproject.api.Author.Status.UNKNOWN; import static org.briarproject.api.Author.Status.UNKNOWN;
@@ -544,8 +543,7 @@ abstract class JdbcDatabase implements Database<Connection> {
try { try {
connections.wait(); connections.wait();
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while closing connections");
LOG.info("Interrupted while closing connections");
interrupted = true; interrupted = true;
} }
for(Connection c : connections) c.close(); for(Connection c : connections) c.close();

View File

@@ -113,8 +113,7 @@ class AliceConnector extends Connector {
tryToClose(conn, true); tryToClose(conn, true);
return; return;
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Interrupted while waiting for confirmation");
LOG.warning("Interrupted while waiting for confirmation");
group.remoteConfirmationFailed(); group.remoteConfirmationFailed();
tryToClose(conn, true); tryToClose(conn, true);
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();

View File

@@ -113,8 +113,7 @@ class BobConnector extends Connector {
tryToClose(conn, true); tryToClose(conn, true);
return; return;
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Interrupted while waiting for confirmation");
LOG.warning("Interrupted while waiting for confirmation");
group.remoteConfirmationFailed(); group.remoteConfirmationFailed();
tryToClose(conn, true); tryToClose(conn, true);
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();

View File

@@ -310,7 +310,7 @@ abstract class Connector extends Thread {
protected void tryToClose(DuplexTransportConnection conn, protected void tryToClose(DuplexTransportConnection conn,
boolean exception) { boolean exception) {
try { try {
if(LOG.isLoggable(INFO)) LOG.info("Closing connection"); LOG.info("Closing connection");
conn.dispose(exception, true); conn.dispose(exception, true);
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -158,8 +158,7 @@ class ConnectorGroup extends Thread implements InvitationTask {
try { try {
for(Connector c : connectors) c.join(); for(Connector c : connectors) c.join();
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Interrupted while waiting for connectors");
LOG.warning("Interrupted while waiting for connectors");
} }
// If none of the threads connected, inform the listeners // If none of the threads connected, inform the listeners
if(!connected.get()) { if(!connected.get()) {

View File

@@ -53,7 +53,7 @@ class LifecycleManagerImpl implements LifecycleManager {
public boolean startServices() { public boolean startServices() {
try { try {
if(LOG.isLoggable(INFO)) LOG.info("Starting"); LOG.info("Starting");
long start = clock.currentTimeMillis(); long start = clock.currentTimeMillis();
boolean reopened = db.open(); boolean reopened = db.open();
long duration = clock.currentTimeMillis() - start; long duration = clock.currentTimeMillis() - start;
@@ -92,7 +92,7 @@ class LifecycleManagerImpl implements LifecycleManager {
public void stopServices() { public void stopServices() {
try { try {
if(LOG.isLoggable(INFO)) LOG.info("Shutting down"); LOG.info("Shutting down");
for(Service s : services) { for(Service s : services) {
boolean stopped = s.stop(); boolean stopped = s.stop();
if(LOG.isLoggable(INFO)) { if(LOG.isLoggable(INFO)) {
@@ -105,7 +105,7 @@ class LifecycleManagerImpl implements LifecycleManager {
if(LOG.isLoggable(INFO)) if(LOG.isLoggable(INFO))
LOG.info(executors.size() + " executors shut down"); LOG.info(executors.size() + " executors shut down");
db.close(); db.close();
if(LOG.isLoggable(INFO)) LOG.info("Database closed"); LOG.info("Database closed");
shutdownLatch.countDown(); shutdownLatch.countDown();
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -162,58 +162,53 @@ abstract class DuplexConnection implements EventListener {
try { try {
InputStream in = createConnectionReader().getInputStream(); InputStream in = createConnectionReader().getInputStream();
PacketReader reader = packetReaderFactory.createPacketReader(in); PacketReader reader = packetReaderFactory.createPacketReader(in);
if(LOG.isLoggable(INFO)) LOG.info("Starting to read"); LOG.info("Starting to read");
while(!reader.eof()) { while(!reader.eof()) {
if(reader.hasAck()) { if(reader.hasAck()) {
Ack a = reader.readAck(); Ack a = reader.readAck();
if(LOG.isLoggable(INFO)) LOG.info("Received ack"); LOG.info("Received ack");
dbExecutor.execute(new ReceiveAck(a)); dbExecutor.execute(new ReceiveAck(a));
} else if(reader.hasMessage()) { } else if(reader.hasMessage()) {
UnverifiedMessage m = reader.readMessage(); UnverifiedMessage m = reader.readMessage();
if(LOG.isLoggable(INFO)) LOG.info("Received message"); LOG.info("Received message");
cryptoExecutor.execute(new VerifyMessage(m)); cryptoExecutor.execute(new VerifyMessage(m));
} else if(reader.hasOffer()) { } else if(reader.hasOffer()) {
Offer o = reader.readOffer(); Offer o = reader.readOffer();
if(LOG.isLoggable(INFO)) LOG.info("Received offer"); LOG.info("Received offer");
dbExecutor.execute(new ReceiveOffer(o)); dbExecutor.execute(new ReceiveOffer(o));
} else if(reader.hasRequest()) { } else if(reader.hasRequest()) {
Request r = reader.readRequest(); Request r = reader.readRequest();
if(LOG.isLoggable(INFO)) LOG.info("Received request"); LOG.info("Received request");
dbExecutor.execute(new ReceiveRequest(r)); dbExecutor.execute(new ReceiveRequest(r));
} else if(reader.hasRetentionAck()) { } else if(reader.hasRetentionAck()) {
RetentionAck a = reader.readRetentionAck(); RetentionAck a = reader.readRetentionAck();
if(LOG.isLoggable(INFO)) LOG.info("Received retention ack"); LOG.info("Received retention ack");
dbExecutor.execute(new ReceiveRetentionAck(a)); dbExecutor.execute(new ReceiveRetentionAck(a));
} else if(reader.hasRetentionUpdate()) { } else if(reader.hasRetentionUpdate()) {
RetentionUpdate u = reader.readRetentionUpdate(); RetentionUpdate u = reader.readRetentionUpdate();
if(LOG.isLoggable(INFO)) LOG.info("Received retention update");
LOG.info("Received retention update");
dbExecutor.execute(new ReceiveRetentionUpdate(u)); dbExecutor.execute(new ReceiveRetentionUpdate(u));
} else if(reader.hasSubscriptionAck()) { } else if(reader.hasSubscriptionAck()) {
SubscriptionAck a = reader.readSubscriptionAck(); SubscriptionAck a = reader.readSubscriptionAck();
if(LOG.isLoggable(INFO)) LOG.info("Received subscription ack");
LOG.info("Received subscription ack");
dbExecutor.execute(new ReceiveSubscriptionAck(a)); dbExecutor.execute(new ReceiveSubscriptionAck(a));
} else if(reader.hasSubscriptionUpdate()) { } else if(reader.hasSubscriptionUpdate()) {
SubscriptionUpdate u = reader.readSubscriptionUpdate(); SubscriptionUpdate u = reader.readSubscriptionUpdate();
if(LOG.isLoggable(INFO)) LOG.info("Received subscription update");
LOG.info("Received subscription update");
dbExecutor.execute(new ReceiveSubscriptionUpdate(u)); dbExecutor.execute(new ReceiveSubscriptionUpdate(u));
} else if(reader.hasTransportAck()) { } else if(reader.hasTransportAck()) {
TransportAck a = reader.readTransportAck(); TransportAck a = reader.readTransportAck();
if(LOG.isLoggable(INFO)) LOG.info("Received transport ack");
LOG.info("Received transport ack");
dbExecutor.execute(new ReceiveTransportAck(a)); dbExecutor.execute(new ReceiveTransportAck(a));
} else if(reader.hasTransportUpdate()) { } else if(reader.hasTransportUpdate()) {
TransportUpdate u = reader.readTransportUpdate(); TransportUpdate u = reader.readTransportUpdate();
if(LOG.isLoggable(INFO)) LOG.info("Received transport update");
LOG.info("Received transport update");
dbExecutor.execute(new ReceiveTransportUpdate(u)); dbExecutor.execute(new ReceiveTransportUpdate(u));
} else { } else {
throw new FormatException(); throw new FormatException();
} }
} }
if(LOG.isLoggable(INFO)) LOG.info("Finished reading"); LOG.info("Finished reading");
writerTasks.add(CLOSE); writerTasks.add(CLOSE);
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -227,7 +222,7 @@ abstract class DuplexConnection implements EventListener {
try { try {
OutputStream out = createConnectionWriter().getOutputStream(); OutputStream out = createConnectionWriter().getOutputStream();
writer = packetWriterFactory.createPacketWriter(out, true); writer = packetWriterFactory.createPacketWriter(out, true);
if(LOG.isLoggable(INFO)) LOG.info("Starting to write"); LOG.info("Starting to write");
// Send the initial packets // Send the initial packets
dbExecutor.execute(new GenerateTransportAcks()); dbExecutor.execute(new GenerateTransportAcks());
dbExecutor.execute(new GenerateTransportUpdates()); dbExecutor.execute(new GenerateTransportUpdates());
@@ -242,13 +237,12 @@ abstract class DuplexConnection implements EventListener {
// Main loop // Main loop
Runnable task = null; Runnable task = null;
while(true) { while(true) {
if(LOG.isLoggable(INFO)) LOG.info("Waiting for something to write");
LOG.info("Waiting for something to write");
task = writerTasks.take(); task = writerTasks.take();
if(task == CLOSE || task == DIE) break; if(task == CLOSE || task == DIE) break;
task.run(); task.run();
} }
if(LOG.isLoggable(INFO)) LOG.info("Finished writing"); LOG.info("Finished writing");
if(task == CLOSE) { if(task == CLOSE) {
writer.flush(); writer.flush();
writer.close(); writer.close();
@@ -257,8 +251,7 @@ abstract class DuplexConnection implements EventListener {
dispose(true, true); dispose(true, true);
} }
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while waiting for task");
LOG.info("Interrupted while waiting for task");
dispose(true, true); dispose(true, true);
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -292,7 +285,7 @@ abstract class DuplexConnection implements EventListener {
public void run() { public void run() {
try { try {
db.receiveAck(contactId, ack); db.receiveAck(contactId, ack);
if(LOG.isLoggable(INFO)) LOG.info("DB received ack"); LOG.info("DB received ack");
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -311,7 +304,7 @@ abstract class DuplexConnection implements EventListener {
public void run() { public void run() {
try { try {
Message m = messageVerifier.verifyMessage(message); Message m = messageVerifier.verifyMessage(message);
if(LOG.isLoggable(INFO)) LOG.info("Verified message"); LOG.info("Verified message");
dbExecutor.execute(new ReceiveMessage(m)); dbExecutor.execute(new ReceiveMessage(m));
} catch(GeneralSecurityException e) { } catch(GeneralSecurityException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -331,7 +324,7 @@ abstract class DuplexConnection implements EventListener {
public void run() { public void run() {
try { try {
db.receiveMessage(contactId, message); db.receiveMessage(contactId, message);
if(LOG.isLoggable(INFO)) LOG.info("DB received message"); LOG.info("DB received message");
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -350,7 +343,7 @@ abstract class DuplexConnection implements EventListener {
public void run() { public void run() {
try { try {
db.receiveOffer(contactId, offer); db.receiveOffer(contactId, offer);
if(LOG.isLoggable(INFO)) LOG.info("DB received offer"); LOG.info("DB received offer");
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -369,7 +362,7 @@ abstract class DuplexConnection implements EventListener {
public void run() { public void run() {
try { try {
db.receiveRequest(contactId, request); db.receiveRequest(contactId, request);
if(LOG.isLoggable(INFO)) LOG.info("DB received request"); LOG.info("DB received request");
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -388,7 +381,7 @@ abstract class DuplexConnection implements EventListener {
public void run() { public void run() {
try { try {
db.receiveRetentionAck(contactId, ack); db.receiveRetentionAck(contactId, ack);
if(LOG.isLoggable(INFO)) LOG.info("DB received retention ack"); LOG.info("DB received retention ack");
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -407,8 +400,7 @@ abstract class DuplexConnection implements EventListener {
public void run() { public void run() {
try { try {
db.receiveRetentionUpdate(contactId, update); db.receiveRetentionUpdate(contactId, update);
if(LOG.isLoggable(INFO)) LOG.info("DB received retention update");
LOG.info("DB received retention update");
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -427,8 +419,7 @@ abstract class DuplexConnection implements EventListener {
public void run() { public void run() {
try { try {
db.receiveSubscriptionAck(contactId, ack); db.receiveSubscriptionAck(contactId, ack);
if(LOG.isLoggable(INFO)) LOG.info("DB received subscription ack");
LOG.info("DB received subscription ack");
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -447,8 +438,7 @@ abstract class DuplexConnection implements EventListener {
public void run() { public void run() {
try { try {
db.receiveSubscriptionUpdate(contactId, update); db.receiveSubscriptionUpdate(contactId, update);
if(LOG.isLoggable(INFO)) LOG.info("DB received subscription update");
LOG.info("DB received subscription update");
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -467,7 +457,7 @@ abstract class DuplexConnection implements EventListener {
public void run() { public void run() {
try { try {
db.receiveTransportAck(contactId, ack); db.receiveTransportAck(contactId, ack);
if(LOG.isLoggable(INFO)) LOG.info("DB received transport ack"); LOG.info("DB received transport ack");
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -486,8 +476,7 @@ abstract class DuplexConnection implements EventListener {
public void run() { public void run() {
try { try {
db.receiveTransportUpdate(contactId, update); db.receiveTransportUpdate(contactId, update);
if(LOG.isLoggable(INFO)) LOG.info("DB received transport update");
LOG.info("DB received transport update");
} catch(DbException e) { } catch(DbException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
} }
@@ -524,7 +513,7 @@ abstract class DuplexConnection implements EventListener {
assert writer != null; assert writer != null;
try { try {
writer.writeAck(ack); writer.writeAck(ack);
if(LOG.isLoggable(INFO)) LOG.info("Sent ack"); LOG.info("Sent ack");
dbExecutor.execute(new GenerateAck()); dbExecutor.execute(new GenerateAck());
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -563,7 +552,7 @@ abstract class DuplexConnection implements EventListener {
assert writer != null; assert writer != null;
try { try {
for(byte[] raw : batch) writer.writeMessage(raw); for(byte[] raw : batch) writer.writeMessage(raw);
if(LOG.isLoggable(INFO)) LOG.info("Sent batch"); LOG.info("Sent batch");
dbExecutor.execute(new GenerateBatch()); dbExecutor.execute(new GenerateBatch());
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -602,7 +591,7 @@ abstract class DuplexConnection implements EventListener {
assert writer != null; assert writer != null;
try { try {
writer.writeOffer(offer); writer.writeOffer(offer);
if(LOG.isLoggable(INFO)) LOG.info("Sent offer"); LOG.info("Sent offer");
dbExecutor.execute(new GenerateOffer()); dbExecutor.execute(new GenerateOffer());
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -641,7 +630,7 @@ abstract class DuplexConnection implements EventListener {
assert writer != null; assert writer != null;
try { try {
writer.writeRequest(request); writer.writeRequest(request);
if(LOG.isLoggable(INFO)) LOG.info("Sent request"); LOG.info("Sent request");
dbExecutor.execute(new GenerateRequest()); dbExecutor.execute(new GenerateRequest());
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -678,7 +667,7 @@ abstract class DuplexConnection implements EventListener {
assert writer != null; assert writer != null;
try { try {
writer.writeRetentionAck(ack); writer.writeRetentionAck(ack);
if(LOG.isLoggable(INFO)) LOG.info("Sent retention ack"); LOG.info("Sent retention ack");
dbExecutor.execute(new GenerateRetentionAck()); dbExecutor.execute(new GenerateRetentionAck());
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -716,7 +705,7 @@ abstract class DuplexConnection implements EventListener {
assert writer != null; assert writer != null;
try { try {
writer.writeRetentionUpdate(update); writer.writeRetentionUpdate(update);
if(LOG.isLoggable(INFO)) LOG.info("Sent retention update"); LOG.info("Sent retention update");
dbExecutor.execute(new GenerateRetentionUpdate()); dbExecutor.execute(new GenerateRetentionUpdate());
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -753,7 +742,7 @@ abstract class DuplexConnection implements EventListener {
assert writer != null; assert writer != null;
try { try {
writer.writeSubscriptionAck(ack); writer.writeSubscriptionAck(ack);
if(LOG.isLoggable(INFO)) LOG.info("Sent subscription ack"); LOG.info("Sent subscription ack");
dbExecutor.execute(new GenerateSubscriptionAck()); dbExecutor.execute(new GenerateSubscriptionAck());
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -791,7 +780,7 @@ abstract class DuplexConnection implements EventListener {
assert writer != null; assert writer != null;
try { try {
writer.writeSubscriptionUpdate(update); writer.writeSubscriptionUpdate(update);
if(LOG.isLoggable(INFO)) LOG.info("Sent subscription update"); LOG.info("Sent subscription update");
dbExecutor.execute(new GenerateSubscriptionUpdate()); dbExecutor.execute(new GenerateSubscriptionUpdate());
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -829,7 +818,7 @@ abstract class DuplexConnection implements EventListener {
assert writer != null; assert writer != null;
try { try {
for(TransportAck a : acks) writer.writeTransportAck(a); for(TransportAck a : acks) writer.writeTransportAck(a);
if(LOG.isLoggable(INFO)) LOG.info("Sent transport acks"); LOG.info("Sent transport acks");
dbExecutor.execute(new GenerateTransportAcks()); dbExecutor.execute(new GenerateTransportAcks());
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
@@ -867,7 +856,7 @@ abstract class DuplexConnection implements EventListener {
assert writer != null; assert writer != null;
try { try {
for(TransportUpdate u : updates) writer.writeTransportUpdate(u); for(TransportUpdate u : updates) writer.writeTransportUpdate(u);
if(LOG.isLoggable(INFO)) LOG.info("Sent transport updates"); LOG.info("Sent transport updates");
dbExecutor.execute(new GenerateTransportUpdates()); dbExecutor.execute(new GenerateTransportUpdates());
} catch(IOException e) { } catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);

View File

@@ -1,7 +1,5 @@
package org.briarproject.messaging.duplex; package org.briarproject.messaging.duplex;
import static java.util.logging.Level.WARNING;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -83,8 +81,7 @@ class DuplexConnectionFactoryImpl implements DuplexConnectionFactory {
DuplexTransportConnection transport) { DuplexTransportConnection transport) {
ConnectionContext ctx = keyManager.getConnectionContext(c, t); ConnectionContext ctx = keyManager.getConnectionContext(c, t);
if(ctx == null) { if(ctx == null) {
if(LOG.isLoggable(WARNING)) LOG.warning("Could not create outgoing connection context");
LOG.warning("Could not create outgoing connection context");
return; return;
} }
final DuplexConnection conn = new OutgoingDuplexConnection(dbExecutor, final DuplexConnection conn = new OutgoingDuplexConnection(dbExecutor,

View File

@@ -1,7 +1,5 @@
package org.briarproject.messaging.simplex; package org.briarproject.messaging.simplex;
import static java.util.logging.Level.WARNING;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -77,8 +75,7 @@ class SimplexConnectionFactoryImpl implements SimplexConnectionFactory {
SimplexTransportWriter w) { SimplexTransportWriter w) {
ConnectionContext ctx = keyManager.getConnectionContext(c, t); ConnectionContext ctx = keyManager.getConnectionContext(c, t);
if(ctx == null) { if(ctx == null) {
if(LOG.isLoggable(WARNING)) LOG.warning("Could not create outgoing connection context");
LOG.warning("Could not create outgoing connection context");
return; return;
} }
final OutgoingSimplexConnection conn = new OutgoingSimplexConnection(db, final OutgoingSimplexConnection conn = new OutgoingSimplexConnection(db,

View File

@@ -82,14 +82,14 @@ class PluginManagerImpl implements PluginManager {
public synchronized boolean start() { public synchronized boolean start() {
// Instantiate and start the simplex plugins // Instantiate and start the simplex plugins
if(LOG.isLoggable(INFO)) LOG.info("Starting simplex plugins"); LOG.info("Starting simplex plugins");
Collection<SimplexPluginFactory> sFactories = Collection<SimplexPluginFactory> sFactories =
simplexPluginConfig.getFactories(); simplexPluginConfig.getFactories();
final CountDownLatch sLatch = new CountDownLatch(sFactories.size()); final CountDownLatch sLatch = new CountDownLatch(sFactories.size());
for(SimplexPluginFactory factory : sFactories) for(SimplexPluginFactory factory : sFactories)
pluginExecutor.execute(new SimplexPluginStarter(factory, sLatch)); pluginExecutor.execute(new SimplexPluginStarter(factory, sLatch));
// Instantiate and start the duplex plugins // Instantiate and start the duplex plugins
if(LOG.isLoggable(INFO)) LOG.info("Starting duplex plugins"); LOG.info("Starting duplex plugins");
Collection<DuplexPluginFactory> dFactories = Collection<DuplexPluginFactory> dFactories =
duplexPluginConfig.getFactories(); duplexPluginConfig.getFactories();
final CountDownLatch dLatch = new CountDownLatch(dFactories.size()); final CountDownLatch dLatch = new CountDownLatch(dFactories.size());
@@ -100,13 +100,12 @@ class PluginManagerImpl implements PluginManager {
sLatch.await(); sLatch.await();
dLatch.await(); dLatch.await();
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Interrupted while starting plugins");
LOG.warning("Interrupted while starting plugins");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
return false; return false;
} }
// Start the poller // Start the poller
if(LOG.isLoggable(INFO)) LOG.info("Starting poller"); LOG.info("Starting poller");
List<Plugin> start = new ArrayList<Plugin>(plugins.values()); List<Plugin> start = new ArrayList<Plugin>(plugins.values());
poller.start(Collections.unmodifiableList(start)); poller.start(Collections.unmodifiableList(start));
return true; return true;
@@ -114,15 +113,15 @@ class PluginManagerImpl implements PluginManager {
public synchronized boolean stop() { public synchronized boolean stop() {
// Stop the poller // Stop the poller
if(LOG.isLoggable(INFO)) LOG.info("Stopping poller"); LOG.info("Stopping poller");
poller.stop(); poller.stop();
final CountDownLatch latch = new CountDownLatch(plugins.size()); final CountDownLatch latch = new CountDownLatch(plugins.size());
// Stop the simplex plugins // Stop the simplex plugins
if(LOG.isLoggable(INFO)) LOG.info("Stopping simplex plugins"); LOG.info("Stopping simplex plugins");
for(SimplexPlugin plugin : simplexPlugins) for(SimplexPlugin plugin : simplexPlugins)
pluginExecutor.execute(new PluginStopper(plugin, latch)); pluginExecutor.execute(new PluginStopper(plugin, latch));
// Stop the duplex plugins // Stop the duplex plugins
if(LOG.isLoggable(INFO)) LOG.info("Stopping duplex plugins"); LOG.info("Stopping duplex plugins");
for(DuplexPlugin plugin : duplexPlugins) for(DuplexPlugin plugin : duplexPlugins)
pluginExecutor.execute(new PluginStopper(plugin, latch)); pluginExecutor.execute(new PluginStopper(plugin, latch));
plugins.clear(); plugins.clear();
@@ -132,8 +131,7 @@ class PluginManagerImpl implements PluginManager {
try { try {
latch.await(); latch.await();
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Interrupted while stopping plugins");
LOG.warning("Interrupted while stopping plugins");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
return false; return false;
} }

View File

@@ -59,7 +59,7 @@ class PollerImpl implements Poller, Runnable {
while(true) { while(true) {
synchronized(this) { synchronized(this) {
if(pollTimes.isEmpty()) { if(pollTimes.isEmpty()) {
if(LOG.isLoggable(INFO)) LOG.info("Finished polling"); LOG.info("Finished polling");
return; return;
} }
long now = clock.currentTimeMillis(); long now = clock.currentTimeMillis();
@@ -83,8 +83,7 @@ class PollerImpl implements Poller, Runnable {
try { try {
wait(p.time - now); wait(p.time - now);
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while waiting to poll");
LOG.info("Interrupted while waiting to poll");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
return; return;
} }

View File

@@ -87,7 +87,7 @@ abstract class TcpPlugin implements DuplexPlugin {
} }
} }
if(!found) { if(!found) {
if(LOG.isLoggable(INFO)) LOG.info("Could not bind server socket"); LOG.info("Could not bind server socket");
return; return;
} }
if(!running) { if(!running) {

View File

@@ -70,8 +70,7 @@ class ReliabilityLayerImpl implements ReliabilityLayer, WriteHandler {
} }
} }
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Interrupted while waiting to write");
LOG.warning("Interrupted while waiting to write");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
running = false; running = false;
} catch(IOException e) { } catch(IOException e) {

View File

@@ -42,7 +42,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
} }
public void registerConnection(ContactId c, TransportId t) { public void registerConnection(ContactId c, TransportId t) {
if(LOG.isLoggable(INFO)) LOG.info("Connection registered"); LOG.info("Connection registered");
boolean firstConnection = false; boolean firstConnection = false;
synchronized(this) { synchronized(this) {
Map<ContactId, Integer> m = connections.get(t); Map<ContactId, Integer> m = connections.get(t);
@@ -62,13 +62,13 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
} }
} }
if(firstConnection) { if(firstConnection) {
if(LOG.isLoggable(INFO)) LOG.info("Contact connected"); LOG.info("Contact connected");
for(ConnectionListener l : listeners) l.contactConnected(c); for(ConnectionListener l : listeners) l.contactConnected(c);
} }
} }
public void unregisterConnection(ContactId c, TransportId t) { public void unregisterConnection(ContactId c, TransportId t) {
if(LOG.isLoggable(INFO)) LOG.info("Connection unregistered"); LOG.info("Connection unregistered");
boolean lastConnection = false; boolean lastConnection = false;
synchronized(this) { synchronized(this) {
Map<ContactId, Integer> m = connections.get(t); Map<ContactId, Integer> m = connections.get(t);
@@ -90,7 +90,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
} }
} }
if(lastConnection) { if(lastConnection) {
if(LOG.isLoggable(INFO)) LOG.info("Contact disconnected"); LOG.info("Contact disconnected");
for(ConnectionListener l : listeners) l.contactDisconnected(c); for(ConnectionListener l : listeners) l.contactDisconnected(c);
} }
} }

View File

@@ -1,6 +1,5 @@
package org.briarproject.transport; package org.briarproject.transport;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
import static org.briarproject.api.transport.TransportConstants.MAX_CLOCK_DIFFERENCE; import static org.briarproject.api.transport.TransportConstants.MAX_CLOCK_DIFFERENCE;
@@ -116,7 +115,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
// Discard the secret if the transport has been removed // Discard the secret if the transport has been removed
Long maxLatency = maxLatencies.get(s.getTransportId()); Long maxLatency = maxLatencies.get(s.getTransportId());
if(maxLatency == null) { if(maxLatency == null) {
if(LOG.isLoggable(INFO)) LOG.info("Discarding obsolete secret"); LOG.info("Discarding obsolete secret");
ByteUtils.erase(s.getSecret()); ByteUtils.erase(s.getSecret());
continue; continue;
} }
@@ -234,14 +233,14 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
TransportId t) { TransportId t) {
TemporarySecret s = currentSecrets.get(new EndpointKey(c, t)); TemporarySecret s = currentSecrets.get(new EndpointKey(c, t));
if(s == null) { if(s == null) {
if(LOG.isLoggable(INFO)) LOG.info("No secret for endpoint"); LOG.info("No secret for endpoint");
return null; return null;
} }
long connection; long connection;
try { try {
connection = db.incrementConnectionCounter(c, t, s.getPeriod()); connection = db.incrementConnectionCounter(c, t, s.getPeriod());
if(connection == -1) { if(connection == -1) {
if(LOG.isLoggable(INFO)) LOG.info("No counter for period"); LOG.info("No counter for period");
return null; return null;
} }
} catch(DbException e) { } catch(DbException e) {

View File

@@ -2,7 +2,6 @@ package org.briarproject.lifecycle;
import static com.sun.jna.Library.OPTION_FUNCTION_MAPPER; import static com.sun.jna.Library.OPTION_FUNCTION_MAPPER;
import static com.sun.jna.Library.OPTION_TYPE_MAPPER; import static com.sun.jna.Library.OPTION_TYPE_MAPPER;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
import java.util.Collections; import java.util.Collections;
@@ -64,8 +63,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
if(OsUtils.isWindows()) { if(OsUtils.isWindows()) {
new EventLoop().start(); new EventLoop().start();
} else { } else {
if(LOG.isLoggable(WARNING)) LOG.warning("Windows shutdown manager used on non-Windows OS");
LOG.warning("Windows shutdown manager used on non-Windows OS");
} }
initialised = true; initialised = true;
} }
@@ -80,8 +78,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
try { try {
hook.join(); hook.join();
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while running shutdown hooks");
LOG.info("Interrupted while running shutdown hooks");
interrupted = true; interrupted = true;
} }
} }
@@ -119,13 +116,11 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
try { try {
// Use SetWindowLongPtr if available (64-bit safe) // Use SetWindowLongPtr if available (64-bit safe)
user32.SetWindowLongPtr(hwnd, GWL_WNDPROC, proc); user32.SetWindowLongPtr(hwnd, GWL_WNDPROC, proc);
if(LOG.isLoggable(INFO)) LOG.info("Registered 64-bit callback");
LOG.info("Registered 64-bit callback");
} catch(UnsatisfiedLinkError e) { } catch(UnsatisfiedLinkError e) {
// Use SetWindowLong if SetWindowLongPtr isn't available // Use SetWindowLong if SetWindowLongPtr isn't available
user32.SetWindowLong(hwnd, GWL_WNDPROC, proc); user32.SetWindowLong(hwnd, GWL_WNDPROC, proc);
if(LOG.isLoggable(INFO)) LOG.info("Registered 32-bit callback");
LOG.info("Registered 32-bit callback");
} }
// Handle events until the window is destroyed // Handle events until the window is destroyed
MSG msg = new MSG(); MSG msg = new MSG();

View File

@@ -268,8 +268,7 @@ class BluetoothPlugin implements DuplexPlugin {
StreamConnection s = socketLatch.waitForReference(timeout); StreamConnection s = socketLatch.waitForReference(timeout);
if(s != null) return new BluetoothTransportConnection(this, s); if(s != null) return new BluetoothTransportConnection(this, s);
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while exchanging invitations");
LOG.info("Interrupted while exchanging invitations");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} finally { } finally {
// Closing the socket will terminate the listener thread // Closing the socket will terminate the listener thread
@@ -307,8 +306,7 @@ class BluetoothPlugin implements DuplexPlugin {
long end = now + timeout; long end = now + timeout;
while(now < end && running && !socketLatch.isSet()) { while(now < end && running && !socketLatch.isSet()) {
if(!discoverySemaphore.tryAcquire()) { if(!discoverySemaphore.tryAcquire()) {
if(LOG.isLoggable(INFO)) LOG.info("Another device discovery is in progress");
LOG.info("Another device discovery is in progress");
return; return;
} }
try { try {
@@ -319,10 +317,9 @@ class BluetoothPlugin implements DuplexPlugin {
if(url == null) continue; if(url == null) continue;
StreamConnection s = connect(url); StreamConnection s = connect(url);
if(s == null) continue; if(s == null) continue;
if(LOG.isLoggable(INFO)) LOG.info("Outgoing connection"); LOG.info("Outgoing connection");
if(!socketLatch.set(s)) { if(!socketLatch.set(s)) {
if(LOG.isLoggable(INFO)) LOG.info("Closing redundant connection");
LOG.info("Closing redundant connection");
tryToClose(s); tryToClose(s);
} }
return; return;
@@ -331,8 +328,7 @@ class BluetoothPlugin implements DuplexPlugin {
LOG.log(WARNING, e.toString(), e); LOG.log(WARNING, e.toString(), e);
return; return;
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while waiting for URL");
LOG.info("Interrupted while waiting for URL");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
return; return;
} finally { } finally {
@@ -364,15 +360,13 @@ class BluetoothPlugin implements DuplexPlugin {
@Override @Override
public void run() { public void run() {
if(LOG.isLoggable(INFO)) LOG.info("Listening for invitation connections");
LOG.info("Listening for invitation connections");
// Listen until a connection is received or the socket is closed // Listen until a connection is received or the socket is closed
try { try {
StreamConnection s = serverSocket.acceptAndOpen(); StreamConnection s = serverSocket.acceptAndOpen();
if(LOG.isLoggable(INFO)) LOG.info("Incoming connection"); LOG.info("Incoming connection");
if(!socketLatch.set(s)) { if(!socketLatch.set(s)) {
if(LOG.isLoggable(INFO)) LOG.info("Closing redundant connection");
LOG.info("Closing redundant connection");
s.close(); s.close();
} }
} catch(IOException e) { } catch(IOException e) {

View File

@@ -1,7 +1,5 @@
package org.briarproject.plugins.file; package org.briarproject.plugins.file;
import static java.util.logging.Level.INFO;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
@@ -56,8 +54,7 @@ class PollingRemovableDriveMonitor implements RemovableDriveMonitor, Runnable {
drives = newDrives; drives = newDrives;
} }
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(INFO)) LOG.warning("Interrupted while waiting to poll");
LOG.info("Interrupted while waiting to poll");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} catch(IOException e) { } catch(IOException e) {
callback.exceptionThrown(e); callback.exceptionThrown(e);

View File

@@ -56,7 +56,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
} }
public boolean start() throws IOException { public boolean start() throws IOException {
if(LOG.isLoggable(INFO)) LOG.info("Starting"); LOG.info("Starting");
try { try {
stateChange.acquire(); stateChange.acquire();
} catch(InterruptedException e) { } catch(InterruptedException e) {
@@ -121,7 +121,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
} }
public void stop() throws IOException { public void stop() throws IOException {
if(LOG.isLoggable(INFO)) LOG.info("Stopping"); LOG.info("Stopping");
// Wake any threads that are waiting to connect // Wake any threads that are waiting to connect
synchronized(this) { synchronized(this) {
initialised = false; initialised = false;
@@ -149,8 +149,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
ReliabilityLayer reliability; ReliabilityLayer reliability;
synchronized(this) { synchronized(this) {
if(this.reliability == null) { if(this.reliability == null) {
if(LOG.isLoggable(INFO)) LOG.info("Not hanging up - already on the hook");
LOG.info("Not hanging up - already on the hook");
return; return;
} }
reliability = this.reliability; reliability = this.reliability;
@@ -158,7 +157,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
connected = false; connected = false;
} }
reliability.stop(); reliability.stop();
if(LOG.isLoggable(INFO)) LOG.info("Hanging up"); LOG.info("Hanging up");
try { try {
clock.sleep(ESCAPE_SEQUENCE_GUARD_TIME); clock.sleep(ESCAPE_SEQUENCE_GUARD_TIME);
port.writeBytes("+++".getBytes("US-ASCII")); port.writeBytes("+++".getBytes("US-ASCII"));
@@ -176,8 +175,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
public boolean dial(String number) throws IOException { public boolean dial(String number) throws IOException {
if(!stateChange.tryAcquire()) { if(!stateChange.tryAcquire()) {
if(LOG.isLoggable(INFO)) LOG.info("Not dialling - state change in progress");
LOG.info("Not dialling - state change in progress");
return false; return false;
} }
try { try {
@@ -185,19 +183,17 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
reliabilityFactory.createReliabilityLayer(this); reliabilityFactory.createReliabilityLayer(this);
synchronized(this) { synchronized(this) {
if(!initialised) { if(!initialised) {
if(LOG.isLoggable(INFO)) LOG.info("Not dialling - modem not initialised");
LOG.info("Not dialling - modem not initialised");
return false; return false;
} }
if(this.reliability != null) { if(this.reliability != null) {
if(LOG.isLoggable(INFO)) LOG.info("Not dialling - call in progress");
LOG.info("Not dialling - call in progress");
return false; return false;
} }
this.reliability = reliability; this.reliability = reliability;
} }
reliability.start(); reliability.start();
if(LOG.isLoggable(INFO)) LOG.info("Dialling"); LOG.info("Dialling");
try { try {
String dial = "ATDT" + number + "\r\n"; String dial = "ATDT" + number + "\r\n";
port.writeBytes(dial.getBytes("US-ASCII")); port.writeBytes(dial.getBytes("US-ASCII"));
@@ -276,7 +272,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
byte[] b = port.readBytes(); byte[] b = port.readBytes();
if(!handleData(b)) handleText(b); if(!handleData(b)) handleText(b);
} else if(ev.isDSR() && ev.getEventValue() == 0) { } else if(ev.isDSR() && ev.getEventValue() == 0) {
if(LOG.isLoggable(INFO)) LOG.info("Remote end hung up"); LOG.info("Remote end hung up");
hangUp(); hangUp();
} else { } else {
if(LOG.isLoggable(INFO)) { if(LOG.isLoggable(INFO)) {
@@ -355,8 +351,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
private void answer() throws IOException { private void answer() throws IOException {
if(!stateChange.tryAcquire()) { if(!stateChange.tryAcquire()) {
if(LOG.isLoggable(INFO)) LOG.info("Not answering - state change in progress");
LOG.info("Not answering - state change in progress");
return; return;
} }
try { try {
@@ -364,19 +359,17 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
reliabilityFactory.createReliabilityLayer(this); reliabilityFactory.createReliabilityLayer(this);
synchronized(this) { synchronized(this) {
if(!initialised) { if(!initialised) {
if(LOG.isLoggable(INFO)) LOG.info("Not answering - modem not initialised");
LOG.info("Not answering - modem not initialised");
return; return;
} }
if(this.reliability != null) { if(this.reliability != null) {
if(LOG.isLoggable(INFO)) LOG.info("Not answering - call in progress");
LOG.info("Not answering - call in progress");
return; return;
} }
this.reliability = reliability; this.reliability = reliability;
} }
reliability.start(); reliability.start();
if(LOG.isLoggable(INFO)) LOG.info("Answering"); LOG.info("Answering");
try { try {
port.writeBytes("ATA\r\n".getBytes("US-ASCII")); port.writeBytes("ATA\r\n".getBytes("US-ASCII"));
} catch(IOException e) { } catch(IOException e) {

View File

@@ -151,14 +151,13 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
if(resetModem()) continue; if(resetModem()) continue;
break; break;
} }
if(LOG.isLoggable(INFO)) LOG.info("Outgoing call connected"); LOG.info("Outgoing call connected");
ModemTransportConnection conn = new ModemTransportConnection(); ModemTransportConnection conn = new ModemTransportConnection();
callback.outgoingConnectionCreated(c, conn); callback.outgoingConnectionCreated(c, conn);
try { try {
conn.waitForDisposal(); conn.waitForDisposal();
} catch(InterruptedException e) { } catch(InterruptedException e) {
if(LOG.isLoggable(WARNING)) LOG.warning("Interrupted while polling");
LOG.warning("Interrupted while polling");
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
break; break;
} }
@@ -221,7 +220,7 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
} }
public void incomingCallConnected() { public void incomingCallConnected() {
if(LOG.isLoggable(INFO)) LOG.info("Incoming call connected"); LOG.info("Incoming call connected");
callback.incomingConnectionCreated(new ModemTransportConnection()); callback.incomingConnectionCreated(new ModemTransportConnection());
} }
@@ -247,7 +246,7 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
} }
public void dispose(boolean exception, boolean recognised) { public void dispose(boolean exception, boolean recognised) {
if(LOG.isLoggable(INFO)) LOG.info("Call disconnected"); LOG.info("Call disconnected");
try { try {
modem.hangUp(); modem.hangUp();
} catch(IOException e) { } catch(IOException e) {