mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 20:29:52 +01:00
Ensure semaphore is released if an exception is thrown.
This commit is contained in:
@@ -72,9 +72,10 @@ class IncomingBatchConnection {
|
|||||||
} catch(DbException e) {
|
} catch(DbException e) {
|
||||||
if(LOG.isLoggable(Level.WARNING))
|
if(LOG.isLoggable(Level.WARNING))
|
||||||
LOG.warning(e.getMessage());
|
LOG.warning(e.getMessage());
|
||||||
}
|
} finally {
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if(proto.hasBatch()) {
|
} else if(proto.hasBatch()) {
|
||||||
final UnverifiedBatch b = proto.readBatch();
|
final UnverifiedBatch b = proto.readBatch();
|
||||||
@@ -90,9 +91,10 @@ class IncomingBatchConnection {
|
|||||||
} catch(GeneralSecurityException e) {
|
} catch(GeneralSecurityException e) {
|
||||||
if(LOG.isLoggable(Level.WARNING))
|
if(LOG.isLoggable(Level.WARNING))
|
||||||
LOG.warning(e.getMessage());
|
LOG.warning(e.getMessage());
|
||||||
}
|
} finally {
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if(proto.hasSubscriptionUpdate()) {
|
} else if(proto.hasSubscriptionUpdate()) {
|
||||||
final SubscriptionUpdate s = proto.readSubscriptionUpdate();
|
final SubscriptionUpdate s = proto.readSubscriptionUpdate();
|
||||||
@@ -105,9 +107,10 @@ class IncomingBatchConnection {
|
|||||||
} catch(DbException e) {
|
} catch(DbException e) {
|
||||||
if(LOG.isLoggable(Level.WARNING))
|
if(LOG.isLoggable(Level.WARNING))
|
||||||
LOG.warning(e.getMessage());
|
LOG.warning(e.getMessage());
|
||||||
}
|
} finally {
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if(proto.hasTransportUpdate()) {
|
} else if(proto.hasTransportUpdate()) {
|
||||||
final TransportUpdate t = proto.readTransportUpdate();
|
final TransportUpdate t = proto.readTransportUpdate();
|
||||||
@@ -120,9 +123,10 @@ class IncomingBatchConnection {
|
|||||||
} catch(DbException e) {
|
} catch(DbException e) {
|
||||||
if(LOG.isLoggable(Level.WARNING))
|
if(LOG.isLoggable(Level.WARNING))
|
||||||
LOG.warning(e.getMessage());
|
LOG.warning(e.getMessage());
|
||||||
}
|
} finally {
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw new FormatException();
|
throw new FormatException();
|
||||||
|
|||||||
@@ -140,9 +140,10 @@ abstract class StreamConnection implements DatabaseListener {
|
|||||||
} catch(DbException e) {
|
} catch(DbException e) {
|
||||||
if(LOG.isLoggable(Level.WARNING))
|
if(LOG.isLoggable(Level.WARNING))
|
||||||
LOG.warning(e.getMessage());
|
LOG.warning(e.getMessage());
|
||||||
}
|
} finally {
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if(proto.hasBatch()) {
|
} else if(proto.hasBatch()) {
|
||||||
final UnverifiedBatch b = proto.readBatch();
|
final UnverifiedBatch b = proto.readBatch();
|
||||||
@@ -158,9 +159,10 @@ abstract class StreamConnection implements DatabaseListener {
|
|||||||
} catch(GeneralSecurityException e) {
|
} catch(GeneralSecurityException e) {
|
||||||
if(LOG.isLoggable(Level.WARNING))
|
if(LOG.isLoggable(Level.WARNING))
|
||||||
LOG.warning(e.getMessage());
|
LOG.warning(e.getMessage());
|
||||||
}
|
} finally {
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if(proto.hasOffer()) {
|
} else if(proto.hasOffer()) {
|
||||||
Offer o = proto.readOffer();
|
Offer o = proto.readOffer();
|
||||||
@@ -200,9 +202,10 @@ abstract class StreamConnection implements DatabaseListener {
|
|||||||
} catch(DbException e) {
|
} catch(DbException e) {
|
||||||
if(LOG.isLoggable(Level.WARNING))
|
if(LOG.isLoggable(Level.WARNING))
|
||||||
LOG.warning(e.getMessage());
|
LOG.warning(e.getMessage());
|
||||||
}
|
} finally {
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// Store the requested message IDs and notify the writer
|
// Store the requested message IDs and notify the writer
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
@@ -223,9 +226,10 @@ abstract class StreamConnection implements DatabaseListener {
|
|||||||
} catch(DbException e) {
|
} catch(DbException e) {
|
||||||
if(LOG.isLoggable(Level.WARNING))
|
if(LOG.isLoggable(Level.WARNING))
|
||||||
LOG.warning(e.getMessage());
|
LOG.warning(e.getMessage());
|
||||||
}
|
} finally {
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if(proto.hasTransportUpdate()) {
|
} else if(proto.hasTransportUpdate()) {
|
||||||
final TransportUpdate t = proto.readTransportUpdate();
|
final TransportUpdate t = proto.readTransportUpdate();
|
||||||
@@ -238,9 +242,10 @@ abstract class StreamConnection implements DatabaseListener {
|
|||||||
} catch(DbException e) {
|
} catch(DbException e) {
|
||||||
if(LOG.isLoggable(Level.WARNING))
|
if(LOG.isLoggable(Level.WARNING))
|
||||||
LOG.warning(e.getMessage());
|
LOG.warning(e.getMessage());
|
||||||
}
|
} finally {
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw new FormatException();
|
throw new FormatException();
|
||||||
|
|||||||
Reference in New Issue
Block a user