diff --git a/briar-android/briar-android.iml b/briar-android/briar-android.iml
index 5b58d4ce0..8237583e3 100644
--- a/briar-android/briar-android.iml
+++ b/briar-android/briar-android.iml
@@ -66,7 +66,6 @@
-
diff --git a/briar-android/src/org/briarproject/android/AndroidNotificationManagerImpl.java b/briar-android/src/org/briarproject/android/AndroidNotificationManagerImpl.java
index e6207fe1c..cff01cd66 100644
--- a/briar-android/src/org/briarproject/android/AndroidNotificationManagerImpl.java
+++ b/briar-android/src/org/briarproject/android/AndroidNotificationManagerImpl.java
@@ -61,9 +61,9 @@ Service, EventListener {
private final Executor dbExecutor;
private final EventBus eventBus;
private final Context appContext;
- private final Lock synchLock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- // The following are locking: synchLock
+ // The following are locking: lock
private final Map contactCounts =
new HashMap();
private final Map groupCounts =
@@ -112,7 +112,7 @@ Service, EventListener {
}
public void showPrivateMessageNotification(ContactId c) {
- synchLock.lock();
+ lock.lock();
try {
Integer count = contactCounts.get(c);
if (count == null) contactCounts.put(c, 1);
@@ -120,23 +120,23 @@ Service, EventListener {
privateTotal++;
updatePrivateMessageNotification();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
public void clearPrivateMessageNotification(ContactId c) {
- synchLock.lock();
+ lock.lock();
try {
Integer count = contactCounts.remove(c);
if (count == null) return; // Already cleared
privateTotal -= count;
updatePrivateMessageNotification();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
- // Locking: synchLock
+ // Locking: lock
private void updatePrivateMessageNotification() {
if (privateTotal == 0) {
clearPrivateMessageNotification();
@@ -181,7 +181,7 @@ Service, EventListener {
}
}
- // Locking: synchLock
+ // Locking: lock
private void clearPrivateMessageNotification() {
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
@@ -200,7 +200,7 @@ Service, EventListener {
}
public void showGroupPostNotification(GroupId g) {
- synchLock.lock();
+ lock.lock();
try {
Integer count = groupCounts.get(g);
if (count == null) groupCounts.put(g, 1);
@@ -208,23 +208,23 @@ Service, EventListener {
groupTotal++;
updateGroupPostNotification();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
public void clearGroupPostNotification(GroupId g) {
- synchLock.lock();
+ lock.lock();
try {
Integer count = groupCounts.remove(g);
if (count == null) return; // Already cleared
groupTotal -= count;
updateGroupPostNotification();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
- // Locking: synchLock
+ // Locking: lock
private void updateGroupPostNotification() {
if (groupTotal == 0) {
clearGroupPostNotification();
@@ -269,7 +269,7 @@ Service, EventListener {
}
}
- // Locking: synchLock
+ // Locking: lock
private void clearGroupPostNotification() {
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
NotificationManager nm = (NotificationManager) o;
@@ -277,7 +277,7 @@ Service, EventListener {
}
public void clearNotifications() {
- synchLock.lock();
+ lock.lock();
try {
contactCounts.clear();
groupCounts.clear();
@@ -285,7 +285,7 @@ Service, EventListener {
clearPrivateMessageNotification();
clearGroupPostNotification();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
}
diff --git a/briar-android/src/org/briarproject/android/ReferenceManagerImpl.java b/briar-android/src/org/briarproject/android/ReferenceManagerImpl.java
index 9844648b7..7b1b96c2b 100644
--- a/briar-android/src/org/briarproject/android/ReferenceManagerImpl.java
+++ b/briar-android/src/org/briarproject/android/ReferenceManagerImpl.java
@@ -15,15 +15,15 @@ class ReferenceManagerImpl implements ReferenceManager {
private static final Logger LOG =
Logger.getLogger(ReferenceManagerImpl.class.getName());
- private final Lock synchLock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- // The following are locking: synchLock
+ // The following are locking: lock
private final Map, Map> outerMap =
new HashMap, Map>();
private long nextHandle = 0;
public T getReference(long handle, Class c) {
- synchLock.lock();
+ lock.lock();
try {
Map innerMap = outerMap.get(c);
if (innerMap == null) {
@@ -36,13 +36,13 @@ class ReferenceManagerImpl implements ReferenceManager {
Object o = innerMap.get(handle);
return c.cast(o);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
public long putReference(T reference, Class c) {
- synchLock.lock();
+ lock.lock();
try {
Map innerMap = outerMap.get(c);
if (innerMap == null) {
@@ -57,12 +57,12 @@ class ReferenceManagerImpl implements ReferenceManager {
}
return handle;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
public T removeReference(long handle, Class c) {
- synchLock.lock();
+ lock.lock();
try {
Map innerMap = outerMap.get(c);
if (innerMap == null) return null;
@@ -74,7 +74,7 @@ class ReferenceManagerImpl implements ReferenceManager {
}
return c.cast(o);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
diff --git a/briar-api/briar-api.iml b/briar-api/briar-api.iml
index 896f2a87a..58d6d226a 100644
--- a/briar-api/briar-api.iml
+++ b/briar-api/briar-api.iml
@@ -13,7 +13,7 @@
-
+
@@ -28,5 +28,6 @@
+
\ No newline at end of file
diff --git a/briar-core/briar-core.iml b/briar-core/briar-core.iml
index e6c05689f..36261ca61 100644
--- a/briar-core/briar-core.iml
+++ b/briar-core/briar-core.iml
@@ -13,7 +13,7 @@
-
+
@@ -32,5 +32,6 @@
+
\ No newline at end of file
diff --git a/briar-core/src/org/briarproject/crypto/FortunaGenerator.java b/briar-core/src/org/briarproject/crypto/FortunaGenerator.java
index 885bd803b..688a03dee 100644
--- a/briar-core/src/org/briarproject/crypto/FortunaGenerator.java
+++ b/briar-core/src/org/briarproject/crypto/FortunaGenerator.java
@@ -19,9 +19,9 @@ class FortunaGenerator {
private static final int KEY_BYTES = 32;
private static final int BLOCK_BYTES = 16;
- private final Lock synchLock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- // The following are locking: synchLock
+ // The following are locking: lock
private final MessageDigest digest = new DoubleDigest(new SHA256Digest());
private final BlockCipher cipher = new AESLightEngine();
private final byte[] key = new byte[KEY_BYTES];
@@ -34,21 +34,21 @@ class FortunaGenerator {
}
void reseed(byte[] seed) {
- synchLock.lock();
+ lock.lock();
try {
digest.update(key);
digest.update(seed);
digest.digest(key, 0, KEY_BYTES);
incrementCounter();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
// Package access for testing
void incrementCounter() {
- synchLock.lock();
+ lock.lock();
try {
counter[0]++;
for (int i = 0; counter[i] == 0; i++) {
@@ -57,23 +57,23 @@ class FortunaGenerator {
counter[i + 1]++;
}
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
// Package access for testing
byte[] getCounter() {
- synchLock.lock();
+ lock.lock();
try {
return counter;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
int nextBytes(byte[] dest, int off, int len) {
- synchLock.lock();
+ lock.lock();
try {
// Don't write more than the maximum number of bytes in one request
if (len > MAX_BYTES_PER_REQUEST) len = MAX_BYTES_PER_REQUEST;
@@ -104,7 +104,7 @@ class FortunaGenerator {
// Return the number of bytes written
return len;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
}
diff --git a/briar-core/src/org/briarproject/invitation/ConnectorGroup.java b/briar-core/src/org/briarproject/invitation/ConnectorGroup.java
index cf523e2ee..24439b181 100644
--- a/briar-core/src/org/briarproject/invitation/ConnectorGroup.java
+++ b/briar-core/src/org/briarproject/invitation/ConnectorGroup.java
@@ -62,9 +62,9 @@ class ConnectorGroup extends Thread implements InvitationTask {
private final Collection listeners;
private final AtomicBoolean connected;
private final CountDownLatch localConfirmationLatch;
- private final Lock synchLock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- // The following are locking: synchLock
+ // The following are locking: lock
private int localConfirmationCode = -1, remoteConfirmationCode = -1;
private boolean connectionFailed = false;
private boolean localCompared = false, remoteCompared = false;
@@ -103,7 +103,7 @@ class ConnectorGroup extends Thread implements InvitationTask {
}
public InvitationState addListener(InvitationListener l) {
- synchLock.lock();
+ lock.lock();
try {
listeners.add(l);
return new InvitationState(localInvitationCode,
@@ -112,7 +112,7 @@ class ConnectorGroup extends Thread implements InvitationTask {
localCompared, remoteCompared, localMatched, remoteMatched,
remoteName);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
@@ -134,11 +134,11 @@ class ConnectorGroup extends Thread implements InvitationTask {
localProps = db.getLocalProperties();
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
- synchLock.lock();
+ lock.lock();
try {
connectionFailed = true;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
for (InvitationListener l : listeners) l.connectionFailed();
return;
@@ -170,11 +170,11 @@ class ConnectorGroup extends Thread implements InvitationTask {
}
// If none of the threads connected, inform the listeners
if (!connected.get()) {
- synchLock.lock();
+ lock.lock();
try {
connectionFailed = true;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
for (InvitationListener l : listeners) l.connectionFailed();
}
@@ -203,23 +203,23 @@ class ConnectorGroup extends Thread implements InvitationTask {
}
public void localConfirmationSucceeded() {
- synchLock.lock();
+ lock.lock();
try {
localCompared = true;
localMatched = true;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
localConfirmationLatch.countDown();
}
public void localConfirmationFailed() {
- synchLock.lock();
+ lock.lock();
try {
localCompared = true;
localMatched = false;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
localConfirmationLatch.countDown();
}
@@ -232,12 +232,12 @@ class ConnectorGroup extends Thread implements InvitationTask {
}
void keyAgreementSucceeded(int localCode, int remoteCode) {
- synchLock.lock();
+ lock.lock();
try {
localConfirmationCode = localCode;
remoteConfirmationCode = remoteCode;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
for (InvitationListener l : listeners)
l.keyAgreementSucceeded(localCode, remoteCode);
@@ -249,43 +249,43 @@ class ConnectorGroup extends Thread implements InvitationTask {
boolean waitForLocalConfirmationResult() throws InterruptedException {
localConfirmationLatch.await(CONFIRMATION_TIMEOUT, MILLISECONDS);
- synchLock.lock();
+ lock.lock();
try {
return localMatched;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
void remoteConfirmationSucceeded() {
- synchLock.lock();
+ lock.lock();
try {
remoteCompared = true;
remoteMatched = true;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
for (InvitationListener l : listeners) l.remoteConfirmationSucceeded();
}
void remoteConfirmationFailed() {
- synchLock.lock();
+ lock.lock();
try {
remoteCompared = true;
remoteMatched = false;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
for (InvitationListener l : listeners) l.remoteConfirmationFailed();
}
void pseudonymExchangeSucceeded(Author remoteAuthor) {
String name = remoteAuthor.getName();
- synchLock.lock();
+ lock.lock();
try {
remoteName = name;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
for (InvitationListener l : listeners)
l.pseudonymExchangeSucceeded(name);
diff --git a/briar-core/src/org/briarproject/lifecycle/ShutdownManagerImpl.java b/briar-core/src/org/briarproject/lifecycle/ShutdownManagerImpl.java
index f639dc888..3779db258 100644
--- a/briar-core/src/org/briarproject/lifecycle/ShutdownManagerImpl.java
+++ b/briar-core/src/org/briarproject/lifecycle/ShutdownManagerImpl.java
@@ -9,9 +9,9 @@ import org.briarproject.api.lifecycle.ShutdownManager;
class ShutdownManagerImpl implements ShutdownManager {
- private final Lock synchLock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- // The following are locking: synchLock
+ // The following are locking: lock
protected final Map hooks;
private int nextHandle = 0;
@@ -20,7 +20,7 @@ class ShutdownManagerImpl implements ShutdownManager {
}
public int addShutdownHook(Runnable r) {
- synchLock.lock();
+ lock.lock();
try {
int handle = nextHandle++;
Thread hook = createThread(r);
@@ -28,7 +28,7 @@ class ShutdownManagerImpl implements ShutdownManager {
Runtime.getRuntime().addShutdownHook(hook);
return handle;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
@@ -38,13 +38,13 @@ class ShutdownManagerImpl implements ShutdownManager {
}
public boolean removeShutdownHook(int handle) {
- synchLock.lock();
+ lock.lock();
try {
Thread hook = hooks.remove(handle);
if (hook == null) return false;
else return Runtime.getRuntime().removeShutdownHook(hook);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
diff --git a/briar-core/src/org/briarproject/plugins/ConnectionRegistryImpl.java b/briar-core/src/org/briarproject/plugins/ConnectionRegistryImpl.java
index fc4f9ecae..66e6eb3db 100644
--- a/briar-core/src/org/briarproject/plugins/ConnectionRegistryImpl.java
+++ b/briar-core/src/org/briarproject/plugins/ConnectionRegistryImpl.java
@@ -27,9 +27,9 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
Logger.getLogger(ConnectionRegistryImpl.class.getName());
private final EventBus eventBus;
- private final Lock synchLock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- // The following are locking: synchLock
+ // The following are locking: lock
private final Map> connections;
private final Map contactCounts;
@@ -43,7 +43,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
public void registerConnection(ContactId c, TransportId t) {
LOG.info("Connection registered");
boolean firstConnection = false;
- synchLock.lock();
+ lock.lock();
try {
Map m = connections.get(t);
if (m == null) {
@@ -61,7 +61,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
contactCounts.put(c, count + 1);
}
} finally {
- synchLock.unlock();
+ lock.unlock();
}
if (firstConnection) {
@@ -73,7 +73,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
public void unregisterConnection(ContactId c, TransportId t) {
LOG.info("Connection unregistered");
boolean lastConnection = false;
- synchLock.lock();
+ lock.lock();
try {
Map m = connections.get(t);
if (m == null) throw new IllegalArgumentException();
@@ -93,7 +93,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
contactCounts.put(c, count - 1);
}
} finally {
- synchLock.unlock();
+ lock.unlock();
}
if (lastConnection) {
@@ -104,7 +104,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
public Collection getConnectedContacts(
TransportId t) {
- synchLock.lock();
+ lock.lock();
try {
Map m = connections.get(t);
if (m == null) return Collections.emptyList();
@@ -112,17 +112,17 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
if (LOG.isLoggable(INFO)) LOG.info(ids.size() + " contacts connected");
return Collections.unmodifiableList(ids);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
public boolean isConnected(ContactId c) {
- synchLock.lock();
+ lock.lock();
try {
return contactCounts.containsKey(c);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
diff --git a/briar-core/src/org/briarproject/transport/KeyManagerImpl.java b/briar-core/src/org/briarproject/transport/KeyManagerImpl.java
index 89174c8ff..7b926cc4f 100644
--- a/briar-core/src/org/briarproject/transport/KeyManagerImpl.java
+++ b/briar-core/src/org/briarproject/transport/KeyManagerImpl.java
@@ -50,9 +50,9 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
private final TagRecogniser tagRecogniser;
private final Clock clock;
private final Timer timer;
- private final Lock synchLock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- // The following are locking: synchLock
+ // The following are locking: lock
private final Map maxLatencies;
private final Map oldSecrets;
private final Map currentSecrets;
@@ -75,7 +75,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
}
public boolean start() {
- synchLock.lock();
+ lock.lock();
try {
eventBus.addListener(this);
// Load the temporary secrets and transport latencies from the DB
@@ -116,12 +116,12 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
MS_BETWEEN_CHECKS);
return true;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
// Assigns secrets to the appropriate maps and returns any dead secrets
- // Locking: synchLock
+ // Locking: lock
private Collection assignSecretsToMaps(long now,
Collection secrets) {
Collection dead = new ArrayList();
@@ -154,7 +154,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
}
// Replaces the given secrets and returns any secrets created
- // Locking: synchLock
+ // Locking: lock
private Collection replaceDeadSecrets(long now,
Collection dead) {
// If there are several dead secrets for an endpoint, use the newest
@@ -213,7 +213,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
}
public boolean stop() {
- synchLock.lock();
+ lock.lock();
try {
eventBus.removeListener(this);
timer.cancel();
@@ -224,13 +224,13 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
newSecrets.clear();
return true;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
public StreamContext getStreamContext(ContactId c,
TransportId t) {
- synchLock.lock();
+ lock.lock();
try {
TemporarySecret s = currentSecrets.get(new EndpointKey(c, t));
if (s == null) {
@@ -251,13 +251,13 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
byte[] secret = s.getSecret();
return new StreamContext(c, t, secret, streamNumber, s.getAlice());
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
public void endpointAdded(Endpoint ep, int maxLatency,
byte[] initialSecret) {
- synchLock.lock();
+ lock.lock();
try {
maxLatencies.put(ep.getTransportId(), maxLatency);
// Work out which rotation period we're in
@@ -291,13 +291,13 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
tagRecogniser.addSecret(s2);
tagRecogniser.addSecret(s3);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
@Override
public void run() {
- synchLock.lock();
+ lock.lock();
try {
// Rebuild the maps because we may be running a whole period late
Collection secrets = new ArrayList();
@@ -330,7 +330,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
for (TemporarySecret s : created) tagRecogniser.addSecret(s);
}
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
@@ -347,14 +347,14 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
}
}
- // Locking: synchLock
+ // Locking: lock
private void removeSecrets(ContactId c, Map, TemporarySecret> m) {
Iterator it = m.values().iterator();
while (it.hasNext())
if (it.next().getContactId().equals(c)) it.remove();
}
- // Locking: synchLock
+ // Locking: lock
private void removeSecrets(TransportId t, Map, TemporarySecret> m) {
Iterator it = m.values().iterator();
while (it.hasNext())
@@ -403,13 +403,13 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
public void run() {
ContactId c = event.getContactId();
tagRecogniser.removeSecrets(c);
- synchLock.lock();
+ lock.lock();
try {
removeSecrets(c, oldSecrets);
removeSecrets(c, currentSecrets);
removeSecrets(c, newSecrets);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
}
@@ -424,11 +424,11 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
@Override
public void run() {
- synchLock.lock();
+ lock.lock();
try {
maxLatencies.put(event.getTransportId(), event.getMaxLatency());
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
}
@@ -445,14 +445,14 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
public void run() {
TransportId t = event.getTransportId();
tagRecogniser.removeSecrets(t);
- synchLock.lock();
+ lock.lock();
try {
maxLatencies.remove(t);
removeSecrets(t, oldSecrets);
removeSecrets(t, currentSecrets);
removeSecrets(t, newSecrets);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
}
diff --git a/briar-core/src/org/briarproject/transport/TagRecogniserImpl.java b/briar-core/src/org/briarproject/transport/TagRecogniserImpl.java
index 1be649bca..b6e53b955 100644
--- a/briar-core/src/org/briarproject/transport/TagRecogniserImpl.java
+++ b/briar-core/src/org/briarproject/transport/TagRecogniserImpl.java
@@ -20,9 +20,9 @@ class TagRecogniserImpl implements TagRecogniser {
private final CryptoComponent crypto;
private final DatabaseComponent db;
- private final Lock synchLock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- // Locking: synchLock
+ // Locking: lock
private final Map recognisers;
@Inject
@@ -35,11 +35,11 @@ class TagRecogniserImpl implements TagRecogniser {
public StreamContext recogniseTag(TransportId t, byte[] tag)
throws DbException {
TransportTagRecogniser r;
- synchLock.lock();
+ lock.lock();
try {
r = recognisers.get(t);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
if (r == null) return null;
return r.recogniseTag(tag);
@@ -48,7 +48,7 @@ class TagRecogniserImpl implements TagRecogniser {
public void addSecret(TemporarySecret s) {
TransportId t = s.getTransportId();
TransportTagRecogniser r;
- synchLock.lock();
+ lock.lock();
try {
r = recognisers.get(t);
if (r == null) {
@@ -56,49 +56,49 @@ class TagRecogniserImpl implements TagRecogniser {
recognisers.put(t, r);
}
} finally {
- synchLock.unlock();
+ lock.unlock();
}
r.addSecret(s);
}
public void removeSecret(ContactId c, TransportId t, long period) {
TransportTagRecogniser r;
- synchLock.lock();
+ lock.lock();
try {
r = recognisers.get(t);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
if (r != null) r.removeSecret(c, period);
}
public void removeSecrets(ContactId c) {
- synchLock.lock();
+ lock.lock();
try {
for (TransportTagRecogniser r : recognisers.values())
r.removeSecrets(c);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
public void removeSecrets(TransportId t) {
- synchLock.lock();
+ lock.lock();
try {
recognisers.remove(t);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
public void removeSecrets() {
- synchLock.lock();
+ lock.lock();
try {
for (TransportTagRecogniser r : recognisers.values())
r.removeSecrets();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
diff --git a/briar-core/src/org/briarproject/transport/TransportTagRecogniser.java b/briar-core/src/org/briarproject/transport/TransportTagRecogniser.java
index 9d0d4e042..eaa102963 100644
--- a/briar-core/src/org/briarproject/transport/TransportTagRecogniser.java
+++ b/briar-core/src/org/briarproject/transport/TransportTagRecogniser.java
@@ -29,9 +29,9 @@ class TransportTagRecogniser {
private final CryptoComponent crypto;
private final DatabaseComponent db;
private final TransportId transportId;
- private final Lock synchLock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- // The following are locking: synchLock
+ // The following are locking: lock
private final Map tagMap;
private final Map removalMap;
@@ -45,7 +45,7 @@ class TransportTagRecogniser {
}
StreamContext recogniseTag(byte[] tag) throws DbException {
- synchLock.lock();
+ lock.lock();
try {
TagContext t = tagMap.remove(new Bytes(tag));
if (t == null) return null; // The tag was not expected
@@ -69,12 +69,12 @@ class TransportTagRecogniser {
return new StreamContext(t.contactId, transportId, t.secret,
t.streamNumber, t.alice);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
void addSecret(TemporarySecret s) {
- synchLock.lock();
+ lock.lock();
try {
ContactId contactId = s.getContactId();
boolean alice = s.getAlice();
@@ -97,23 +97,23 @@ class TransportTagRecogniser {
RemovalContext r = new RemovalContext(window, secret, alice);
removalMap.put(new RemovalKey(contactId, period), r);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
void removeSecret(ContactId contactId, long period) {
- synchLock.lock();
+ lock.lock();
try {
RemovalKey k = new RemovalKey(contactId, period);
RemovalContext removed = removalMap.remove(k);
if (removed == null) throw new IllegalArgumentException();
removeSecret(removed);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
- // Locking: synchLock
+ // Locking: lock
private void removeSecret(RemovalContext r) {
// Remove the expected tags
SecretKey key = crypto.deriveTagKey(r.secret, !r.alice);
@@ -126,7 +126,7 @@ class TransportTagRecogniser {
}
void removeSecrets(ContactId c) {
- synchLock.lock();
+ lock.lock();
try {
Collection keysToRemove = new ArrayList();
for (RemovalKey k : removalMap.keySet())
@@ -134,18 +134,18 @@ class TransportTagRecogniser {
for (RemovalKey k : keysToRemove)
removeSecret(k.contactId, k.period);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
void removeSecrets() {
- synchLock.lock();
+ lock.lock();
try {
for (RemovalContext r : removalMap.values()) removeSecret(r);
assert tagMap.isEmpty();
removalMap.clear();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
diff --git a/briar-desktop/briar-desktop.iml b/briar-desktop/briar-desktop.iml
index abeeda389..ea72f302e 100644
--- a/briar-desktop/briar-desktop.iml
+++ b/briar-desktop/briar-desktop.iml
@@ -13,7 +13,7 @@
-
+
diff --git a/briar-desktop/src/org/briarproject/lifecycle/WindowsShutdownManagerImpl.java b/briar-desktop/src/org/briarproject/lifecycle/WindowsShutdownManagerImpl.java
index ef3343c07..602d27f75 100644
--- a/briar-desktop/src/org/briarproject/lifecycle/WindowsShutdownManagerImpl.java
+++ b/briar-desktop/src/org/briarproject/lifecycle/WindowsShutdownManagerImpl.java
@@ -38,9 +38,9 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
private static final int WS_MINIMIZE = 0x20000000;
private final Map options;
- private final Lock synchLock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- private boolean initialised = false; // Locking: synchLock
+ private boolean initialised = false; // Locking: lock
WindowsShutdownManagerImpl() {
// Use the Unicode versions of Win32 API calls
@@ -52,12 +52,12 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
@Override
public int addShutdownHook(Runnable r) {
- synchLock.lock();
+ lock.lock();
try {
if (!initialised) initialise();
return super.addShutdownHook(r);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
@@ -66,7 +66,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
return new StartOnce(r);
}
- // Locking: synchLock
+ // Locking: lock
private void initialise() {
if (OsUtils.isWindows()) {
new EventLoop().start();
@@ -78,7 +78,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
// Package access for testing
void runShutdownHooks() {
- synchLock.lock();
+ lock.lock();
try {
boolean interrupted = false;
// Start each hook in its own thread
@@ -94,7 +94,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
}
if (interrupted) Thread.currentThread().interrupt();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
@@ -162,7 +162,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
}
}
- private static interface User32 extends StdCallLibrary {
+ private interface User32 extends StdCallLibrary {
HWND CreateWindowEx(int styleEx, String className, String windowName,
int style, int x, int y, int width, int height, HWND parent,
@@ -177,8 +177,8 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
LRESULT DispatchMessage(MSG msg);
}
- private static interface WindowProc extends StdCallCallback {
+ private interface WindowProc extends StdCallCallback {
- public LRESULT callback(HWND hwnd, int msg, WPARAM wp, LPARAM lp);
+ LRESULT callback(HWND hwnd, int msg, WPARAM wp, LPARAM lp);
}
}
diff --git a/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java b/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java
index de0d04d9c..bfe731d87 100644
--- a/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java
+++ b/briar-desktop/src/org/briarproject/plugins/file/UnixRemovableDriveMonitor.java
@@ -14,15 +14,15 @@ abstract class UnixRemovableDriveMonitor implements RemovableDriveMonitor,
JNotifyListener {
//TODO: rationalise this in a further refactor
- private static final Lock staticSynchLock = new ReentrantLock();
+ private static final Lock staticLock = new ReentrantLock();
- // The following are locking: staticSynchLock
+ // The following are locking: staticLock
private static boolean triedLoad = false;
private static Throwable loadError = null;
- private final Lock synchLock = new ReentrantLock();
+ private final Lock lock = new ReentrantLock();
- // The following are locking: synchLock
+ // The following are locking: lock
private final List watches = new ArrayList();
private boolean started = false;
private Callback callback = null;
@@ -41,7 +41,7 @@ JNotifyListener {
}
public static void checkEnabled() throws IOException {
- staticSynchLock.lock();
+ staticLock.lock();
try {
if (!triedLoad) {
loadError = tryLoad();
@@ -49,7 +49,7 @@ JNotifyListener {
}
if (loadError != null) throw new IOException(loadError.toString());
} finally {
- staticSynchLock.unlock();
+ staticLock.unlock();
}
}
@@ -61,7 +61,7 @@ JNotifyListener {
if (new File(path).exists())
watches.add(JNotify.addWatch(path, mask, false, this));
}
- synchLock.lock();
+ lock.lock();
try {
assert !started;
assert this.callback == null;
@@ -69,14 +69,14 @@ JNotifyListener {
this.callback = callback;
this.watches.addAll(watches);
} finally {
- synchLock.unlock();
+ lock.unlock();
}
}
public void stop() throws IOException {
checkEnabled();
List watches;
- synchLock.lock();
+ lock.lock();
try {
assert started;
assert callback != null;
@@ -85,18 +85,18 @@ JNotifyListener {
watches = new ArrayList(this.watches);
this.watches.clear();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
for (Integer w : watches) JNotify.removeWatch(w);
}
public void fileCreated(int wd, String rootPath, String name) {
Callback callback;
- synchLock.lock();
+ lock.lock();
try {
callback = this.callback;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
if (callback != null)
callback.driveInserted(new File(rootPath + "/" + name));
diff --git a/briar-desktop/src/org/briarproject/plugins/modem/ModemImpl.java b/briar-desktop/src/org/briarproject/plugins/modem/ModemImpl.java
index 13b628369..59fc18930 100644
--- a/briar-desktop/src/org/briarproject/plugins/modem/ModemImpl.java
+++ b/briar-desktop/src/org/briarproject/plugins/modem/ModemImpl.java
@@ -44,11 +44,11 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
private final Semaphore stateChange;
private final byte[] line;
- private final Lock synchLock = new ReentrantLock();
- private final Condition connectedStateChanged = synchLock.newCondition();
- private final Condition initialisedStateChanged = synchLock.newCondition();
+ private final Lock lock = new ReentrantLock();
+ private final Condition connectedStateChanged = lock.newCondition();
+ private final Condition initialisedStateChanged = lock.newCondition();
- // The following are locking: synchLock
+ // The following are locking: lock
private ReliabilityLayer reliability = null;
private boolean initialised = false, connected = false;
@@ -100,7 +100,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
// Wait for the event thread to receive "OK"
boolean success = false;
try {
- synchLock.lock();
+ lock.lock();
try {
long now = clock.currentTimeMillis();
long end = now + OK_TIMEOUT;
@@ -110,7 +110,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
}
success = initialised;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
} catch (InterruptedException e) {
tryToClose(port);
@@ -135,7 +135,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
public void stop() throws IOException {
LOG.info("Stopping");
- synchLock.lock();
+ lock.lock();
try {
// Wake any threads that are waiting to connect
initialised = false;
@@ -143,7 +143,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
initialisedStateChanged.signalAll();
connectedStateChanged.signalAll();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
// Hang up if necessary and close the port
try {
@@ -164,7 +164,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
// Locking: stateChange
private void hangUpInner() throws IOException {
ReliabilityLayer reliability;
- synchLock.lock();
+ lock.lock();
try {
if (this.reliability == null) {
LOG.info("Not hanging up - already on the hook");
@@ -174,7 +174,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
this.reliability = null;
connected = false;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
reliability.stop();
LOG.info("Hanging up");
@@ -201,7 +201,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
try {
ReliabilityLayer reliability =
reliabilityFactory.createReliabilityLayer(this);
- synchLock.lock();
+ lock.lock();
try {
if (!initialised) {
LOG.info("Not dialling - modem not initialised");
@@ -213,7 +213,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
}
this.reliability = reliability;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
reliability.start();
LOG.info("Dialling");
@@ -226,7 +226,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
}
// Wait for the event thread to receive "CONNECT"
try {
- synchLock.lock();
+ lock.lock();
try {
long now = clock.currentTimeMillis();
long end = now + CONNECT_TIMEOUT;
@@ -236,7 +236,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
}
if (connected) return true;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
} catch (InterruptedException e) {
tryToClose(port);
@@ -252,11 +252,11 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
public InputStream getInputStream() throws IOException {
ReliabilityLayer reliability;
- synchLock.lock();
+ lock.lock();
try {
reliability = this.reliability;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
if (reliability == null) throw new IOException("Not connected");
return reliability.getInputStream();
@@ -264,11 +264,11 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
public OutputStream getOutputStream() throws IOException {
ReliabilityLayer reliability;
- synchLock.lock();
+ lock.lock();
try {
reliability = this.reliability;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
if (reliability == null) throw new IOException("Not connected");
return reliability.getOutputStream();
@@ -319,11 +319,11 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
private boolean handleData(byte[] b) throws IOException {
ReliabilityLayer reliability;
- synchLock.lock();
+ lock.lock();
try {
reliability = this.reliability;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
if (reliability == null) return false;
reliability.handleRead(b);
@@ -343,12 +343,12 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
lineLen = 0;
if (LOG.isLoggable(INFO)) LOG.info("Modem status: " + s);
if (s.startsWith("CONNECT")) {
- synchLock.lock();
+ lock.lock();
try {
connected = true;
connectedStateChanged.signalAll();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
// There might be data in the buffer as well as text
int off = i + 1;
@@ -360,20 +360,20 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
return;
} else if (s.equals("BUSY") || s.equals("NO DIALTONE")
|| s.equals("NO CARRIER")) {
- synchLock.lock();
+ lock.lock();
try {
connected = false;
connectedStateChanged.signalAll();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
} else if (s.equals("OK")) {
- synchLock.lock();
+ lock.lock();
try {
initialised = true;
initialisedStateChanged.signalAll();
} finally {
- synchLock.unlock();
+ lock.unlock();
}
} else if (s.equals("RING")) {
ioExecutor.execute(new Runnable() {
@@ -401,7 +401,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
try {
ReliabilityLayer reliability =
reliabilityFactory.createReliabilityLayer(this);
- synchLock.lock();
+ lock.lock();
try {
if (!initialised) {
LOG.info("Not answering - modem not initialised");
@@ -413,7 +413,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
}
this.reliability = reliability;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
reliability.start();
LOG.info("Answering");
@@ -426,7 +426,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
// Wait for the event thread to receive "CONNECT"
boolean success = false;
try {
- synchLock.lock();
+ lock.lock();
try {
long now = clock.currentTimeMillis();
long end = now + CONNECT_TIMEOUT;
@@ -436,7 +436,7 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
}
success = connected;
} finally {
- synchLock.unlock();
+ lock.unlock();
}
} catch (InterruptedException e) {
tryToClose(port);
diff --git a/briar-tests/briar-tests.iml b/briar-tests/briar-tests.iml
index 12a098eac..83fdb9b9f 100644
--- a/briar-tests/briar-tests.iml
+++ b/briar-tests/briar-tests.iml
@@ -13,7 +13,7 @@
-
+
diff --git a/briar.iml b/briar.iml
index 85c8e272d..16216bfa2 100644
--- a/briar.iml
+++ b/briar.iml
@@ -1,5 +1,5 @@
-
+