mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Code cleanup: import static.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package net.sf.briar;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.android.AndroidModule;
|
||||
@@ -65,31 +67,31 @@ public class HelloWorldService extends Service implements Runnable {
|
||||
pluginManager = i.getInstance(PluginManager.class);
|
||||
try {
|
||||
// Start...
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info("Starting");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Starting");
|
||||
db.open(false);
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info("Database opened");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Database opened");
|
||||
keyManager.start();
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info("Key manager started");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Key manager started");
|
||||
int pluginsStarted = pluginManager.start(this);
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info(pluginsStarted + " plugins started");
|
||||
// ...sleep...
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch(InterruptedException ignored) {}
|
||||
// ...and stop
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info("Shutting down");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Shutting down");
|
||||
int pluginsStopped = pluginManager.stop();
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info(pluginsStopped + " plugins stopped");
|
||||
keyManager.stop();
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info("Key manager stopped");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Key manager stopped");
|
||||
db.close();
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info("Database closed");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Database closed");
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package net.sf.briar.db;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.db.DbClosedException;
|
||||
@@ -34,12 +36,12 @@ class DatabaseCleanerImpl extends TimerTask implements DatabaseCleaner {
|
||||
callback.checkFreeSpaceAndClean();
|
||||
}
|
||||
} catch(DbClosedException e) {
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info("Database closed, exiting");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Database closed, exiting");
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
throw new Error(e); // Kill the application
|
||||
} catch(RuntimeException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
throw new Error(e); // Kill the application
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.sf.briar.db;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static net.sf.briar.db.DatabaseConstants.BYTES_PER_SWEEP;
|
||||
import static net.sf.briar.db.DatabaseConstants.CRITICAL_FREE_SPACE;
|
||||
import static net.sf.briar.db.DatabaseConstants.MAX_BYTES_BETWEEN_SPACE_CHECKS;
|
||||
@@ -19,7 +20,6 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -140,11 +140,9 @@ DatabaseCleaner.Callback {
|
||||
close();
|
||||
}
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.sf.briar.db;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static net.sf.briar.db.DatabaseConstants.EXPIRY_MODULUS;
|
||||
import static net.sf.briar.db.DatabaseConstants.RETRANSMIT_THRESHOLD;
|
||||
|
||||
@@ -20,7 +22,6 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -361,7 +362,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
if(s != null) try {
|
||||
s.close();
|
||||
} catch(SQLException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING))LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +370,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
if(rs != null) try {
|
||||
rs.close();
|
||||
} catch(SQLException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING))LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,11 +406,11 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
} catch(SQLException e) {
|
||||
// Try to close the connection
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
try {
|
||||
txn.close();
|
||||
} catch(SQLException e1) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e1.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e1.toString());
|
||||
}
|
||||
// Whatever happens, allow the database to close
|
||||
synchronized(connections) {
|
||||
@@ -443,7 +444,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
try {
|
||||
connections.wait();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Interrupted while closing connections");
|
||||
interrupted = true;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package net.sf.briar.lifecycle;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.util.OsUtils;
|
||||
@@ -62,7 +64,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
|
||||
if(OsUtils.isWindows()) {
|
||||
new EventLoop().start();
|
||||
} else {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning("Windows shutdown manager used on non-Windows OS");
|
||||
}
|
||||
initialised = true;
|
||||
@@ -78,7 +80,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
|
||||
try {
|
||||
hook.join();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Interrupted while running shutdown hooks");
|
||||
interrupted = true;
|
||||
}
|
||||
@@ -113,12 +115,12 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
|
||||
try {
|
||||
// Use SetWindowLongPtr if available (64-bit safe)
|
||||
user32.SetWindowLongPtr(hwnd, GWL_WNDPROC, proc);
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Registered 64-bit callback");
|
||||
} catch(UnsatisfiedLinkError e) {
|
||||
// Use SetWindowLong if SetWindowLongPtr isn't available
|
||||
user32.SetWindowLong(hwnd, GWL_WNDPROC, proc);
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Registered 32-bit callback");
|
||||
}
|
||||
// Handle events until the window is destroyed
|
||||
@@ -128,7 +130,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
|
||||
user32.DispatchMessage(msg);
|
||||
}
|
||||
} catch(UnsatisfiedLinkError e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.sf.briar.plugins;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -9,7 +12,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -97,7 +99,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
SimplexPlugin plugin = factory.createPlugin(pluginExecutor,
|
||||
androidExecutor, appContext, callback);
|
||||
if(plugin == null) {
|
||||
if(LOG.isLoggable(Level.INFO)) {
|
||||
if(LOG.isLoggable(INFO)) {
|
||||
LOG.info(factory.getClass().getSimpleName()
|
||||
+ " did not create a plugin");
|
||||
}
|
||||
@@ -105,7 +107,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
}
|
||||
TransportId id = plugin.getId();
|
||||
if(!ids.add(id)) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning("Duplicate transport ID: " + id);
|
||||
continue;
|
||||
}
|
||||
@@ -113,10 +115,10 @@ class PluginManagerImpl implements PluginManager {
|
||||
plugin.start();
|
||||
simplexPlugins.add(plugin);
|
||||
} catch(ClassCastException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
continue;
|
||||
} catch(Exception e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -130,7 +132,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
DuplexPlugin plugin = factory.createPlugin(pluginExecutor,
|
||||
androidExecutor, appContext, callback);
|
||||
if(plugin == null) {
|
||||
if(LOG.isLoggable(Level.INFO)) {
|
||||
if(LOG.isLoggable(INFO)) {
|
||||
LOG.info(factory.getClass().getSimpleName()
|
||||
+ " did not create a plugin");
|
||||
}
|
||||
@@ -138,7 +140,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
}
|
||||
TransportId id = plugin.getId();
|
||||
if(!ids.add(id)) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning("Duplicate transport ID: " + id);
|
||||
continue;
|
||||
}
|
||||
@@ -146,10 +148,10 @@ class PluginManagerImpl implements PluginManager {
|
||||
plugin.start();
|
||||
duplexPlugins.add(plugin);
|
||||
} catch(ClassCastException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
continue;
|
||||
} catch(Exception e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -182,7 +184,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
plugin.stop();
|
||||
stopped++;
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
// Stop the duplex plugins
|
||||
@@ -191,7 +193,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
plugin.stop();
|
||||
stopped++;
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
// Shut down the executors
|
||||
@@ -225,7 +227,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
try {
|
||||
return db.getConfig(id);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return new TransportConfig();
|
||||
}
|
||||
}
|
||||
@@ -236,7 +238,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
TransportProperties p = db.getLocalProperties(id);
|
||||
return p == null ? new TransportProperties() : p;
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return new TransportProperties();
|
||||
}
|
||||
}
|
||||
@@ -246,7 +248,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
try {
|
||||
return db.getRemoteProperties(id);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
@@ -256,7 +258,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
try {
|
||||
db.mergeConfig(id, c);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +267,7 @@ class PluginManagerImpl implements PluginManager {
|
||||
try {
|
||||
db.mergeLocalProperties(id, p);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package net.sf.briar.plugins;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -57,7 +59,7 @@ class PollerImpl implements Poller, Runnable {
|
||||
try {
|
||||
p.plugin.poll(connected);
|
||||
} catch(RuntimeException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning("Plugin " + p.plugin.getId() + " " + e);
|
||||
}
|
||||
schedule(p.plugin);
|
||||
@@ -65,7 +67,7 @@ class PollerImpl implements Poller, Runnable {
|
||||
try {
|
||||
wait(p.time - now);
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Interrupted while waiting to poll");
|
||||
Thread.currentThread().interrupt();
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.sf.briar.plugins.bluetooth;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static javax.bluetooth.DiscoveryAgent.GIAC;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -12,7 +14,6 @@ import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.bluetooth.BluetoothStateException;
|
||||
@@ -82,7 +83,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
callback.showMessage("BLUETOOTH_INSTALL_LIBS");
|
||||
throw new IOException(e.toString());
|
||||
}
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Local address " + localDevice.getBluetoothAddress());
|
||||
synchronized(this) {
|
||||
running = true;
|
||||
@@ -107,7 +108,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
try {
|
||||
scn = (StreamConnectionNotifier) Connector.open(url);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return;
|
||||
}
|
||||
synchronized(this) {
|
||||
@@ -133,7 +134,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
try {
|
||||
scn.close();
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
s = scn.acceptAndOpen();
|
||||
} catch(IOException e) {
|
||||
// This is expected when the socket is closed
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info(e.toString());
|
||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||
tryToClose(scn);
|
||||
return;
|
||||
}
|
||||
@@ -209,7 +210,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
StreamConnection s = (StreamConnection) Connector.open(url);
|
||||
return new BluetoothTransportConnection(s);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -251,11 +252,11 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
discoveryAgent.startInquiry(GIAC, listener);
|
||||
url = listener.waitForUrl();
|
||||
} catch(BluetoothStateException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning(e.toString());
|
||||
return null;
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Interrupted while waiting for URL");
|
||||
Thread.currentThread().interrupt();
|
||||
return null;
|
||||
@@ -289,7 +290,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
try {
|
||||
scn = (StreamConnectionNotifier) Connector.open(url);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return null;
|
||||
}
|
||||
synchronized(this) {
|
||||
@@ -311,7 +312,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
return new BluetoothTransportConnection(s);
|
||||
} catch(IOException e) {
|
||||
// This is expected when the socket is closed
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info(e.toString());
|
||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||
return null;
|
||||
} finally {
|
||||
if(f.cancel(false)) tryToClose(scn);
|
||||
@@ -326,7 +327,7 @@ class BluetoothPlugin implements DuplexPlugin {
|
||||
try {
|
||||
localDevice.setDiscoverable(GIAC);
|
||||
} catch(BluetoothStateException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package net.sf.briar.plugins.bluetooth;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.bluetooth.BluetoothStateException;
|
||||
@@ -47,7 +48,7 @@ class InvitationListener implements DiscoveryListener {
|
||||
discoveryAgent.searchServices(null, uuids, device, this);
|
||||
searches.incrementAndGet();
|
||||
} catch(BluetoothStateException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ import static android.bluetooth.BluetoothAdapter.STATE_ON;
|
||||
import static android.bluetooth.BluetoothDevice.EXTRA_DEVICE;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.SocketTimeoutException;
|
||||
@@ -22,7 +24,6 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -117,11 +118,10 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
if(!running) return;
|
||||
}
|
||||
if(!enableBluetooth()) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
LOG.info("Could not enable Bluetooth");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Could not enable Bluetooth");
|
||||
return;
|
||||
}
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Local address " + adapter.getAddress());
|
||||
// Advertise the Bluetooth address to contacts
|
||||
TransportProperties p = new TransportProperties();
|
||||
@@ -132,7 +132,7 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
try {
|
||||
ss = InsecureBluetooth.listen(adapter, "RFCOMM", getUuid(), false);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return;
|
||||
}
|
||||
synchronized(this) {
|
||||
@@ -158,7 +158,7 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
if(!adapter.enable()) return false;
|
||||
return receiver.waitForStateChange();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Interrupted while enabling Bluetooth");
|
||||
Thread.currentThread().interrupt();
|
||||
return false;
|
||||
@@ -174,7 +174,7 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
try {
|
||||
ss.close();
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
s = ss.accept();
|
||||
} catch(IOException e) {
|
||||
// This is expected when the socket is closed
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info(e.toString());
|
||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||
tryToClose(ss);
|
||||
return;
|
||||
}
|
||||
@@ -246,7 +246,7 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
private DuplexTransportConnection connect(String address, String uuid) {
|
||||
// Validate the address
|
||||
if(!BluetoothAdapter.checkBluetoothAddress(address)) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning("Invalid address " + address);
|
||||
return null;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
try {
|
||||
u = UUID.fromString(uuid);
|
||||
} catch(IllegalArgumentException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning("Invalid UUID " + uuid);
|
||||
return null;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
BluetoothSocket s = InsecureBluetooth.createSocket(d, u, false);
|
||||
return new DroidtoothTransportConnection(s);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,7 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
try {
|
||||
return receiver.waitForConnection(timeout);
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Interrupted while sending invitation");
|
||||
Thread.currentThread().interrupt();
|
||||
return null;
|
||||
@@ -325,17 +325,17 @@ class DroidtoothPlugin implements DuplexPlugin {
|
||||
try {
|
||||
ss = InsecureBluetooth.listen(adapter, "RFCOMM", uuid, false);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return null;
|
||||
}
|
||||
// Return the first connection received by the socket, if any
|
||||
try {
|
||||
return new DroidtoothTransportConnection(ss.accept((int) timeout));
|
||||
} catch(SocketTimeoutException e) {
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info("Invitation timed out");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Invitation timed out");
|
||||
return null;
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return null;
|
||||
} finally {
|
||||
tryToClose(ss);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.sf.briar.plugins.email;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -9,7 +11,6 @@ import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
@@ -84,7 +85,7 @@ class GmailPlugin implements SimplexPlugin {
|
||||
try {
|
||||
return message.getInputStream();
|
||||
} catch(MessagingException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning(e.toString());
|
||||
}
|
||||
return null;
|
||||
@@ -96,14 +97,14 @@ class GmailPlugin implements SimplexPlugin {
|
||||
message.setFlag(Flag.DELETED, recognised);
|
||||
message.setFlag(Flag.SEEN, recognised);
|
||||
} catch(MessagingException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch(MessagingException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,9 +123,9 @@ class GmailPlugin implements SimplexPlugin {
|
||||
inbox.open(Folder.READ_ONLY);
|
||||
checkUnreadEmails(inbox);
|
||||
} catch(NoSuchProviderException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
} catch(MessagingException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,7 +215,7 @@ class GmailPlugin implements SimplexPlugin {
|
||||
outputStream.close();
|
||||
outputStream = null;
|
||||
} catch(Exception e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package net.sf.briar.plugins.email;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.microedition.io.StreamConnection;
|
||||
@@ -36,7 +37,7 @@ class GmailTransportConnectionWriter implements SimplexTransportWriter {
|
||||
try {
|
||||
stream.close();
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.sf.briar.plugins.file;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static net.sf.briar.api.transport.TransportConstants.MIN_CONNECTION_LENGTH;
|
||||
|
||||
import java.io.File;
|
||||
@@ -9,7 +10,6 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -74,7 +74,7 @@ public abstract class FilePlugin implements SimplexPlugin {
|
||||
OutputStream out = new FileOutputStream(f);
|
||||
return new FileTransportWriter(f, out, capacity, this);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
f.delete();
|
||||
return null;
|
||||
}
|
||||
@@ -104,8 +104,7 @@ public abstract class FilePlugin implements SimplexPlugin {
|
||||
callback.readerCreated(new FileTransportReader(file, in,
|
||||
FilePlugin.this));
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package net.sf.briar.plugins.file;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.plugins.simplex.SimplexTransportReader;
|
||||
@@ -31,7 +32,7 @@ class FileTransportReader implements SimplexTransportReader {
|
||||
try {
|
||||
in.close();
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
if(recognised) {
|
||||
file.delete();
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package net.sf.briar.plugins.file;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.plugins.simplex.SimplexTransportWriter;
|
||||
@@ -42,7 +43,7 @@ class FileTransportWriter implements SimplexTransportWriter {
|
||||
try {
|
||||
out.close();
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
if(exception) file.delete();
|
||||
else plugin.writerFinished(file);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package net.sf.briar.plugins.file;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.plugins.PluginExecutor;
|
||||
@@ -66,7 +67,7 @@ class PollingRemovableDriveMonitor implements RemovableDriveMonitor, Runnable {
|
||||
drives = newDrives;
|
||||
}
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Interrupted while waiting to poll");
|
||||
Thread.currentThread().interrupt();
|
||||
} catch(IOException e) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.sf.briar.plugins.file;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -7,7 +9,6 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -79,7 +80,7 @@ implements RemovableDriveMonitor.Callback {
|
||||
if(i == -1) return null;
|
||||
return drives.get(i);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -108,7 +109,7 @@ implements RemovableDriveMonitor.Callback {
|
||||
}
|
||||
}
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
return Collections.unmodifiableList(matches);
|
||||
}
|
||||
@@ -121,6 +122,6 @@ implements RemovableDriveMonitor.Callback {
|
||||
}
|
||||
|
||||
public void exceptionThrown(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.sf.briar.plugins.socket;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.InetAddress;
|
||||
@@ -10,7 +13,6 @@ import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.crypto.PseudoRandom;
|
||||
@@ -51,7 +53,7 @@ class LanSocketPlugin extends SimpleSocketPlugin {
|
||||
ms.setInterface(iface);
|
||||
ms.joinGroup(mcast.getAddress());
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
if(ms != null) tryToClose(ms, mcast.getAddress());
|
||||
return null;
|
||||
}
|
||||
@@ -75,7 +77,7 @@ class LanSocketPlugin extends SimpleSocketPlugin {
|
||||
Socket s = new Socket(packet.getAddress(), port);
|
||||
return new SocketTransportConnection(s);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
@@ -87,10 +89,10 @@ class LanSocketPlugin extends SimpleSocketPlugin {
|
||||
if(!running) return null;
|
||||
}
|
||||
}
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Timeout while sending invitation");
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
} finally {
|
||||
tryToClose(ms, mcast.getAddress());
|
||||
}
|
||||
@@ -101,7 +103,7 @@ class LanSocketPlugin extends SimpleSocketPlugin {
|
||||
try {
|
||||
ms.leaveGroup(addr);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
ms.close();
|
||||
}
|
||||
@@ -152,7 +154,7 @@ class LanSocketPlugin extends SimpleSocketPlugin {
|
||||
ss = new ServerSocket();
|
||||
ss.bind(new InetSocketAddress(iface, 0));
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
if(ss != null) tryToClose(ss);
|
||||
return null;
|
||||
}
|
||||
@@ -163,7 +165,7 @@ class LanSocketPlugin extends SimpleSocketPlugin {
|
||||
ms = new MulticastSocket();
|
||||
ms.setInterface(iface);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
if(ms != null) ms.close();
|
||||
tryToClose(ss);
|
||||
return null;
|
||||
@@ -197,10 +199,10 @@ class LanSocketPlugin extends SimpleSocketPlugin {
|
||||
if(!running) return null;
|
||||
}
|
||||
}
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Timeout while accepting invitation");
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
} finally {
|
||||
ms.close();
|
||||
tryToClose(ss);
|
||||
@@ -212,7 +214,7 @@ class LanSocketPlugin extends SimpleSocketPlugin {
|
||||
try {
|
||||
ss.close();
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.sf.briar.plugins.socket;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
@@ -10,7 +13,6 @@ import java.net.SocketAddress;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -61,7 +63,7 @@ class SimpleSocketPlugin extends SocketPlugin {
|
||||
try {
|
||||
return new InetSocketAddress(chooseInterface(false), 0);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
return addr;
|
||||
@@ -77,7 +79,7 @@ class SimpleSocketPlugin extends SocketPlugin {
|
||||
boolean link = addr.isLinkLocalAddress();
|
||||
boolean site = addr.isSiteLocalAddress();
|
||||
if(lan == (link || site)) {
|
||||
if(LOG.isLoggable(Level.INFO)) {
|
||||
if(LOG.isLoggable(INFO)) {
|
||||
LOG.info("Choosing interface "
|
||||
+ addr.getHostAddress());
|
||||
}
|
||||
@@ -90,7 +92,7 @@ class SimpleSocketPlugin extends SocketPlugin {
|
||||
for(NetworkInterface iface : ifaces) {
|
||||
for(InetAddress addr : Collections.list(iface.getInetAddresses())) {
|
||||
if(!addr.isLoopbackAddress()) {
|
||||
if(LOG.isLoggable(Level.INFO)) {
|
||||
if(LOG.isLoggable(INFO)) {
|
||||
LOG.info("Accepting interface "
|
||||
+ addr.getHostAddress());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.sf.briar.plugins.socket;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
@@ -7,7 +10,6 @@ import java.net.SocketAddress;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -62,14 +64,14 @@ abstract class SocketPlugin implements DuplexPlugin {
|
||||
addr = getLocalSocketAddress();
|
||||
ss = createServerSocket();
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return;
|
||||
}
|
||||
if(addr == null || ss == null) return;
|
||||
try {
|
||||
ss.bind(addr);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
tryToClose(ss);
|
||||
return;
|
||||
}
|
||||
@@ -80,7 +82,7 @@ abstract class SocketPlugin implements DuplexPlugin {
|
||||
}
|
||||
socket = ss;
|
||||
}
|
||||
if(LOG.isLoggable(Level.INFO)) {
|
||||
if(LOG.isLoggable(INFO)) {
|
||||
LOG.info("Listening on " + ss.getInetAddress().getHostAddress()
|
||||
+ ":" + ss.getLocalPort());
|
||||
}
|
||||
@@ -92,7 +94,7 @@ abstract class SocketPlugin implements DuplexPlugin {
|
||||
try {
|
||||
ss.close();
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +105,7 @@ abstract class SocketPlugin implements DuplexPlugin {
|
||||
s = ss.accept();
|
||||
} catch(IOException e) {
|
||||
// This is expected when the socket is closed
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info(e.toString());
|
||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||
tryToClose(ss);
|
||||
return;
|
||||
}
|
||||
@@ -163,7 +165,7 @@ abstract class SocketPlugin implements DuplexPlugin {
|
||||
s.connect(addr);
|
||||
return new SocketTransportConnection(s);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info(e.toString());
|
||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package net.sf.briar.plugins.tor;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -76,11 +78,9 @@ class TorPlugin implements DuplexPlugin {
|
||||
// Connect to Tor
|
||||
NetFactory netFactory = NetFactory.getInstance();
|
||||
NetLayer nl = netFactory.getNetLayerById(NetLayerIDs.TOR);
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
LOG.info("Waiting for net layer to be ready");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Waiting for net layer to be ready");
|
||||
nl.waitUntilReady();
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
LOG.info("Net layer is ready");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Net layer is ready");
|
||||
synchronized(this) {
|
||||
if(!running) {
|
||||
tryToClear(nl);
|
||||
@@ -93,8 +93,7 @@ class TorPlugin implements DuplexPlugin {
|
||||
// If we're configure not to create a hidden service, return
|
||||
TransportConfig c = callback.getConfig();
|
||||
if(c.containsKey("noHiddenService")) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
LOG.info("Not creating hidden service");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Not creating hidden service");
|
||||
TransportProperties p = new TransportProperties();
|
||||
p.put("onion", null);
|
||||
callback.mergeLocalProperties(p);
|
||||
@@ -105,17 +104,17 @@ class TorPlugin implements DuplexPlugin {
|
||||
TorNetLayerUtil util = TorNetLayerUtil.getInstance();
|
||||
String privateKey = c.get("privateKey");
|
||||
if(privateKey == null) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Creating hidden service address");
|
||||
addr = createHiddenServiceAddress(util);
|
||||
} else {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Parsing hidden service address");
|
||||
try {
|
||||
addr = util.parseTorHiddenServicePrivateNetAddressFromStrings(
|
||||
privateKey, "", false);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
addr = createHiddenServiceAddress(util);
|
||||
}
|
||||
}
|
||||
@@ -123,11 +122,11 @@ class TorPlugin implements DuplexPlugin {
|
||||
new TorHiddenServicePortPrivateNetAddress(addr, 80);
|
||||
// Publish the hidden service
|
||||
NetServerSocket ss;
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info("Publishing hidden service");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Publishing hidden service");
|
||||
try {
|
||||
ss = nl.createNetServerSocket(null, addrPort);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return;
|
||||
}
|
||||
synchronized(this) {
|
||||
@@ -138,7 +137,7 @@ class TorPlugin implements DuplexPlugin {
|
||||
socket = ss;
|
||||
}
|
||||
String onion = addr.getPublicOnionHostname();
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info("Listening on " + onion);
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Listening on " + onion);
|
||||
TransportProperties p = callback.getLocalProperties();
|
||||
p.put("onion", onion);
|
||||
callback.mergeLocalProperties(p);
|
||||
@@ -161,7 +160,7 @@ class TorPlugin implements DuplexPlugin {
|
||||
try {
|
||||
nl.clear();
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +168,7 @@ class TorPlugin implements DuplexPlugin {
|
||||
try {
|
||||
ss.close();
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +179,7 @@ class TorPlugin implements DuplexPlugin {
|
||||
s = ss.accept();
|
||||
} catch(IOException e) {
|
||||
// This is expected when the socket is closed
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info(e.toString());
|
||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||
tryToClose(ss);
|
||||
return;
|
||||
}
|
||||
@@ -244,12 +243,12 @@ class TorPlugin implements DuplexPlugin {
|
||||
synchronized(this) {
|
||||
while(!connected) {
|
||||
if(!running) return null;
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Waiting for net layer before connecting");
|
||||
try {
|
||||
wait();
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Interrupted while waiting to connect");
|
||||
Thread.currentThread().interrupt();
|
||||
return null;
|
||||
@@ -263,14 +262,12 @@ class TorPlugin implements DuplexPlugin {
|
||||
if(onion == null) return null;
|
||||
NetAddress addr = new TcpipNetAddress(onion, 80);
|
||||
try {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
LOG.info("Connecting to hidden service");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Connecting to hidden service");
|
||||
NetSocket s = nl.createNetSocket(null, null, addr);
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
LOG.info("Connected to hidden service");
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Connected to hidden service");
|
||||
return new TorTransportConnection(s);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.INFO)) LOG.info(e.toString());
|
||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package net.sf.briar.protocol.duplex;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -14,7 +17,6 @@ import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -179,7 +181,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
// The writer will dispose of the transport if no exceptions occur
|
||||
writerTasks.add(CLOSE);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true, true);
|
||||
}
|
||||
}
|
||||
@@ -217,11 +219,11 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
writer.close();
|
||||
dispose(false, true);
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Interrupted while waiting for task");
|
||||
dispose(true, true);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true, true);
|
||||
} finally {
|
||||
connRegistry.unregisterConnection(contactId, transportId);
|
||||
@@ -235,7 +237,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
try {
|
||||
transport.dispose(exception, recognised);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +254,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
try {
|
||||
db.receiveAck(contactId, ack);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,7 +273,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
Batch b = batch.verify();
|
||||
dbExecutor.execute(new ReceiveBatch(b));
|
||||
} catch(GeneralSecurityException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,7 +291,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
try {
|
||||
db.receiveBatch(contactId, batch);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -308,7 +310,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
Request r = db.receiveOffer(contactId, offer);
|
||||
writerTasks.add(new WriteRequest(r));
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,7 +329,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
try {
|
||||
writer.writeRequest(request);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true, true);
|
||||
}
|
||||
}
|
||||
@@ -346,7 +348,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
try {
|
||||
db.setSeen(contactId, seen);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,7 +366,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
try {
|
||||
db.receiveSubscriptionUpdate(contactId, update);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -382,7 +384,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
try {
|
||||
db.receiveTransportUpdate(contactId, update);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -397,7 +399,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
Ack a = db.generateAck(contactId, maxBatches);
|
||||
if(a != null) writerTasks.add(new WriteAck(a));
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -417,7 +419,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
writer.writeAck(ack);
|
||||
dbExecutor.execute(new GenerateAcks());
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true, true);
|
||||
}
|
||||
}
|
||||
@@ -440,7 +442,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
if(b == null) new GenerateOffer().run();
|
||||
else writerTasks.add(new WriteBatch(b, requested));
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -463,7 +465,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
if(requested.isEmpty()) dbExecutor.execute(new GenerateOffer());
|
||||
else dbExecutor.execute(new GenerateBatches(requested));
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true, true);
|
||||
}
|
||||
}
|
||||
@@ -487,7 +489,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
writerTasks.add(new WriteOffer(o));
|
||||
}
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -506,7 +508,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
try {
|
||||
writer.writeOffer(offer);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true, true);
|
||||
}
|
||||
}
|
||||
@@ -520,7 +522,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
SubscriptionUpdate s = db.generateSubscriptionUpdate(contactId);
|
||||
if(s != null) writerTasks.add(new WriteSubscriptionUpdate(s));
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -539,7 +541,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
try {
|
||||
writer.writeSubscriptionUpdate(update);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true, true);
|
||||
}
|
||||
}
|
||||
@@ -553,7 +555,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
TransportUpdate t = db.generateTransportUpdate(contactId);
|
||||
if(t != null) writerTasks.add(new WriteTransportUpdate(t));
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -572,7 +574,7 @@ abstract class DuplexConnection implements DatabaseListener {
|
||||
try {
|
||||
writer.writeTransportUpdate(update);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package net.sf.briar.protocol.duplex;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -78,7 +79,7 @@ class DuplexConnectionFactoryImpl implements DuplexConnectionFactory {
|
||||
DuplexTransportConnection transport) {
|
||||
ConnectionContext ctx = keyManager.getConnectionContext(c, t);
|
||||
if(ctx == null) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning("Could not create outgoing connection context");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package net.sf.briar.protocol.simplex;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -88,7 +89,7 @@ class IncomingSimplexConnection {
|
||||
}
|
||||
dispose(false, true);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true, true);
|
||||
} finally {
|
||||
connRegistry.unregisterConnection(contactId, transportId);
|
||||
@@ -100,7 +101,7 @@ class IncomingSimplexConnection {
|
||||
try {
|
||||
transport.dispose(exception, recognised);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +117,7 @@ class IncomingSimplexConnection {
|
||||
try {
|
||||
db.receiveAck(contactId, ack);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,7 +135,7 @@ class IncomingSimplexConnection {
|
||||
Batch b = batch.verify();
|
||||
dbExecutor.execute(new ReceiveBatch(b));
|
||||
} catch(GeneralSecurityException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +152,7 @@ class IncomingSimplexConnection {
|
||||
try {
|
||||
db.receiveBatch(contactId, batch);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +169,7 @@ class IncomingSimplexConnection {
|
||||
try {
|
||||
db.receiveSubscriptionUpdate(contactId, update);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,7 +186,7 @@ class IncomingSimplexConnection {
|
||||
try {
|
||||
db.receiveTransportUpdate(contactId, update);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package net.sf.briar.protocol.simplex;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static net.sf.briar.api.protocol.ProtocolConstants.MAX_PACKET_LENGTH;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -99,10 +99,10 @@ class OutgoingSimplexConnection {
|
||||
writer.close();
|
||||
dispose(false);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true);
|
||||
} finally {
|
||||
connRegistry.unregisterConnection(contactId, transportId);
|
||||
@@ -114,7 +114,7 @@ class OutgoingSimplexConnection {
|
||||
try {
|
||||
transport.dispose(exception);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package net.sf.briar.protocol.simplex;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -72,7 +73,7 @@ class SimplexConnectionFactoryImpl implements SimplexConnectionFactory {
|
||||
SimplexTransportWriter w) {
|
||||
ConnectionContext ctx = keyManager.getConnectionContext(c, t);
|
||||
if(ctx == null) {
|
||||
if(LOG.isLoggable(Level.WARNING))
|
||||
if(LOG.isLoggable(WARNING))
|
||||
LOG.warning("Could not create outgoing connection context");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package net.sf.briar.transport;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static net.sf.briar.api.transport.TransportConstants.TAG_LENGTH;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -98,18 +98,18 @@ class ConnectionDispatcherImpl implements ConnectionDispatcher {
|
||||
transport);
|
||||
}
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
try {
|
||||
transport.dispose(true, false);
|
||||
} catch(IOException e1) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
try {
|
||||
transport.dispose(true, false);
|
||||
} catch(IOException e1) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ class ConnectionDispatcherImpl implements ConnectionDispatcher {
|
||||
try {
|
||||
tag = readTag(transport.getInputStream());
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true, false);
|
||||
return;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ class ConnectionDispatcherImpl implements ConnectionDispatcher {
|
||||
try {
|
||||
ctx = recogniser.acceptConnection(transportId, tag);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
dispose(true, false);
|
||||
return;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ class ConnectionDispatcherImpl implements ConnectionDispatcher {
|
||||
try {
|
||||
transport.dispose(exception, recognised);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.sf.briar.transport;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -8,7 +10,6 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
@@ -63,7 +64,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, DatabaseListener {
|
||||
try {
|
||||
secrets = db.getSecrets();
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return false;
|
||||
}
|
||||
// Work out what phase of its lifecycle each secret is in
|
||||
@@ -76,7 +77,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, DatabaseListener {
|
||||
try {
|
||||
db.addSecrets(created);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -223,7 +224,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, DatabaseListener {
|
||||
try {
|
||||
connection = db.incrementConnectionCounter(c, t, s.getPeriod());
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
return null;
|
||||
}
|
||||
byte[] secret = s.getSecret().clone();
|
||||
@@ -268,7 +269,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, DatabaseListener {
|
||||
try {
|
||||
db.addSecrets(Arrays.asList(s1, s2));
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
// Pass the new secrets to the recogniser
|
||||
recogniser.addSecret(s1);
|
||||
@@ -303,7 +304,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, DatabaseListener {
|
||||
try {
|
||||
db.addSecrets(created);
|
||||
} catch(DbException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
}
|
||||
// Pass any secrets that have been created to the recogniser
|
||||
for(TemporarySecret s : created) recogniser.addSecret(s);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.sf.briar.util;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -8,7 +10,6 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@@ -44,12 +45,12 @@ public class BoundedExecutor implements Executor {
|
||||
}
|
||||
});
|
||||
} catch(InterruptedException e) {
|
||||
if(LOG.isLoggable(Level.INFO))
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Interrupted while queueing task");
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RejectedExecutionException();
|
||||
} catch(RejectedExecutionException e) {
|
||||
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
||||
if(LOG.isLoggable(WARNING)) LOG.warning(e.toString());
|
||||
semaphore.release();
|
||||
throw e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user