mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 21:59:54 +01:00
Multi-catch.
This commit is contained in:
@@ -184,12 +184,7 @@ class ContactExchangeTaskImpl extends Thread implements ContactExchangeTask {
|
|||||||
// Close the outgoing stream and expect EOF on the incoming stream
|
// Close the outgoing stream and expect EOF on the incoming stream
|
||||||
w.close();
|
w.close();
|
||||||
if (!r.eof()) LOG.warning("Unexpected data at end of connection");
|
if (!r.eof()) LOG.warning("Unexpected data at end of connection");
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException | IOException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
listener.contactExchangeFailed();
|
|
||||||
tryToClose(conn, true);
|
|
||||||
return;
|
|
||||||
} catch (IOException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
listener.contactExchangeFailed();
|
listener.contactExchangeFailed();
|
||||||
tryToClose(conn, true);
|
tryToClose(conn, true);
|
||||||
|
|||||||
@@ -137,11 +137,7 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return new Transaction(db.startTransaction(), readOnly);
|
return new Transaction(db.startTransaction(), readOnly);
|
||||||
} catch (DbException e) {
|
} catch (DbException | RuntimeException e) {
|
||||||
if (readOnly) lock.readLock().unlock();
|
|
||||||
else lock.writeLock().unlock();
|
|
||||||
throw e;
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
if (readOnly) lock.readLock().unlock();
|
if (readOnly) lock.readLock().unlock();
|
||||||
else lock.writeLock().unlock();
|
else lock.writeLock().unlock();
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
@@ -129,10 +129,7 @@ class KeyAgreementConnector {
|
|||||||
LOG.info("Interrupted while waiting for connection");
|
LOG.info("Interrupted while waiting for connection");
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
return null;
|
return null;
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException | IOException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
return null;
|
|
||||||
} catch (IOException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -203,9 +203,7 @@ class LifecycleManagerImpl implements LifecycleManager {
|
|||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Closing database took " + duration + " ms");
|
LOG.info("Closing database took " + duration + " ms");
|
||||||
shutdownLatch.countDown();
|
shutdownLatch.countDown();
|
||||||
} catch (DbException e) {
|
} catch (DbException | ServiceException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
} catch (ServiceException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
} finally {
|
} finally {
|
||||||
startStopSemaphore.release();
|
startStopSemaphore.release();
|
||||||
|
|||||||
@@ -134,11 +134,7 @@ class ConnectionManagerImpl implements ConnectionManager {
|
|||||||
try {
|
try {
|
||||||
byte[] tag = readTag(reader);
|
byte[] tag = readTag(reader);
|
||||||
ctx = keyManager.getStreamContext(transportId, tag);
|
ctx = keyManager.getStreamContext(transportId, tag);
|
||||||
} catch (IOException e) {
|
} catch (IOException | DbException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
disposeReader(true, false);
|
|
||||||
return;
|
|
||||||
} catch (DbException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
disposeReader(true, false);
|
disposeReader(true, false);
|
||||||
return;
|
return;
|
||||||
@@ -249,11 +245,7 @@ class ConnectionManagerImpl implements ConnectionManager {
|
|||||||
try {
|
try {
|
||||||
byte[] tag = readTag(reader);
|
byte[] tag = readTag(reader);
|
||||||
ctx = keyManager.getStreamContext(transportId, tag);
|
ctx = keyManager.getStreamContext(transportId, tag);
|
||||||
} catch (IOException e) {
|
} catch (IOException | DbException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
disposeReader(true, false);
|
|
||||||
return;
|
|
||||||
} catch (DbException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
disposeReader(true, false);
|
disposeReader(true, false);
|
||||||
return;
|
return;
|
||||||
@@ -381,11 +373,7 @@ class ConnectionManagerImpl implements ConnectionManager {
|
|||||||
try {
|
try {
|
||||||
byte[] tag = readTag(reader);
|
byte[] tag = readTag(reader);
|
||||||
ctx = keyManager.getStreamContext(transportId, tag);
|
ctx = keyManager.getStreamContext(transportId, tag);
|
||||||
} catch (IOException e) {
|
} catch (IOException | DbException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
disposeReader(true, false);
|
|
||||||
return;
|
|
||||||
} catch (DbException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
disposeReader(true, false);
|
disposeReader(true, false);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -58,9 +58,7 @@ class PortMapperImpl implements PortMapper {
|
|||||||
"External address " + scrubInetAddress(externalString));
|
"External address " + scrubInetAddress(externalString));
|
||||||
if (externalString != null)
|
if (externalString != null)
|
||||||
external = InetAddress.getByName(externalString);
|
external = InetAddress.getByName(externalString);
|
||||||
} catch (IOException e) {
|
} catch (IOException | SAXException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
} catch (SAXException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
}
|
}
|
||||||
return new MappingResult(internal, external, port, succeeded);
|
return new MappingResult(internal, external, port, succeeded);
|
||||||
@@ -77,11 +75,7 @@ class PortMapperImpl implements PortMapper {
|
|||||||
GatewayDiscover d = new GatewayDiscover();
|
GatewayDiscover d = new GatewayDiscover();
|
||||||
try {
|
try {
|
||||||
d.discover();
|
d.discover();
|
||||||
} catch (IOException e) {
|
} catch (IOException | SAXException | ParserConfigurationException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
} catch (SAXException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
} catch (ParserConfigurationException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
}
|
}
|
||||||
gateway = d.getValidGateway();
|
gateway = d.getValidGateway();
|
||||||
@@ -92,9 +86,7 @@ class PortMapperImpl implements PortMapper {
|
|||||||
gateway.deletePortMapping(port, "TCP");
|
gateway.deletePortMapping(port, "TCP");
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Deleted mapping for port " + port);
|
LOG.info("Deleted mapping for port " + port);
|
||||||
} catch (IOException e) {
|
} catch (IOException | SAXException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
} catch (SAXException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import java.util.List;
|
|||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@ParametersNotNullByDefault
|
@ParametersNotNullByDefault
|
||||||
abstract class UnixRemovableDriveMonitor implements RemovableDriveMonitor,
|
abstract class UnixRemovableDriveMonitor implements RemovableDriveMonitor,
|
||||||
@@ -34,13 +36,12 @@ JNotifyListener {
|
|||||||
|
|
||||||
protected abstract String[] getPathsToWatch();
|
protected abstract String[] getPathsToWatch();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private static Throwable tryLoad() {
|
private static Throwable tryLoad() {
|
||||||
try {
|
try {
|
||||||
Class.forName("net.contentobjects.jnotify.JNotify");
|
Class.forName("net.contentobjects.jnotify.JNotify");
|
||||||
return null;
|
return null;
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch (UnsatisfiedLinkError | ClassNotFoundException e) {
|
||||||
return e;
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,11 +294,7 @@ class FeedManagerImpl implements FeedManager, Client, EventListener,
|
|||||||
for (Feed feed : feeds) {
|
for (Feed feed : feeds) {
|
||||||
try {
|
try {
|
||||||
newFeeds.add(fetchFeed(feed));
|
newFeeds.add(fetchFeed(feed));
|
||||||
} catch (IOException e) {
|
} catch (IOException | DbException e) {
|
||||||
if (LOG.isLoggable(WARNING))
|
|
||||||
LOG.log(WARNING, e.toString(), e);
|
|
||||||
newFeeds.add(feed);
|
|
||||||
} catch (DbException e) {
|
|
||||||
if (LOG.isLoggable(WARNING))
|
if (LOG.isLoggable(WARNING))
|
||||||
LOG.log(WARNING, e.toString(), e);
|
LOG.log(WARNING, e.toString(), e);
|
||||||
newFeeds.add(feed);
|
newFeeds.add(feed);
|
||||||
@@ -381,9 +377,7 @@ class FeedManagerImpl implements FeedManager, Client, EventListener,
|
|||||||
SyndFeedInput input = new SyndFeedInput();
|
SyndFeedInput input = new SyndFeedInput();
|
||||||
try {
|
try {
|
||||||
return input.build(new XmlReader(stream));
|
return input.build(new XmlReader(stream));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | FeedException e) {
|
||||||
throw new IOException(e);
|
|
||||||
} catch (FeedException e) {
|
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -469,13 +463,7 @@ class FeedManagerImpl implements FeedManager, Client, EventListener,
|
|||||||
BlogPost post = blogPostFactory
|
BlogPost post = blogPostFactory
|
||||||
.createBlogPost(groupId, time, null, localAuthor, body);
|
.createBlogPost(groupId, time, null, localAuthor, body);
|
||||||
blogManager.addLocalPost(txn, post);
|
blogManager.addLocalPost(txn, post);
|
||||||
} catch (DbException e) {
|
} catch (DbException | GeneralSecurityException | FormatException e) {
|
||||||
if (LOG.isLoggable(WARNING))
|
|
||||||
LOG.log(WARNING, e.toString(), e);
|
|
||||||
} catch (GeneralSecurityException e) {
|
|
||||||
if (LOG.isLoggable(WARNING))
|
|
||||||
LOG.log(WARNING, e.toString(), e);
|
|
||||||
} catch (FormatException e) {
|
|
||||||
if (LOG.isLoggable(WARNING))
|
if (LOG.isLoggable(WARNING))
|
||||||
LOG.log(WARNING, e.toString(), e);
|
LOG.log(WARNING, e.toString(), e);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
|||||||
@@ -134,9 +134,7 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
|
|||||||
try {
|
try {
|
||||||
p = forumPostFactory.createPost(groupId, timestamp, parentId,
|
p = forumPostFactory.createPost(groupId, timestamp, parentId,
|
||||||
author, body);
|
author, body);
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException | FormatException e) {
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (FormatException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
|
|||||||
@@ -519,9 +519,7 @@ class IntroduceeManager {
|
|||||||
try {
|
try {
|
||||||
processStateUpdate(txn, null,
|
processStateUpdate(txn, null,
|
||||||
engine.onLocalAction(state, localAction));
|
engine.onLocalAction(state, localAction));
|
||||||
} catch (DbException e) {
|
} catch (DbException | IOException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,9 +173,7 @@ class IntroducerManager {
|
|||||||
try {
|
try {
|
||||||
processStateUpdate(txn,
|
processStateUpdate(txn,
|
||||||
engine.onLocalAction(state, localAction));
|
engine.onLocalAction(state, localAction));
|
||||||
} catch (DbException e) {
|
} catch (DbException | IOException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,12 +251,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
|||||||
LOG.warning("Unknown role '" + role + "'");
|
LOG.warning("Unknown role '" + role + "'");
|
||||||
throw new DbException();
|
throw new DbException();
|
||||||
}
|
}
|
||||||
} catch (DbException e) {
|
} catch (DbException | FormatException e) {
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
|
||||||
if (role == ROLE_INTRODUCER) introducerManager.abort(txn, state);
|
|
||||||
else introduceeManager.abort(txn, state);
|
|
||||||
} catch (FormatException e) {
|
|
||||||
// FIXME necessary?
|
|
||||||
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
if (role == ROLE_INTRODUCER) introducerManager.abort(txn, state);
|
if (role == ROLE_INTRODUCER) introducerManager.abort(txn, state);
|
||||||
else introduceeManager.abort(txn, state);
|
else introduceeManager.abort(txn, state);
|
||||||
|
|||||||
@@ -63,9 +63,7 @@ class GroupMessageFactoryImpl implements GroupMessageFactory {
|
|||||||
Message m = clientHelper.createMessage(groupId, timestamp, body);
|
Message m = clientHelper.createMessage(groupId, timestamp, body);
|
||||||
|
|
||||||
return new GroupMessage(m, null, member);
|
return new GroupMessage(m, null, member);
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException | FormatException e) {
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (FormatException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,9 +89,7 @@ class GroupMessageFactoryImpl implements GroupMessageFactory {
|
|||||||
Message m = clientHelper.createMessage(groupId, timestamp, body);
|
Message m = clientHelper.createMessage(groupId, timestamp, body);
|
||||||
|
|
||||||
return new GroupMessage(m, parentId, author);
|
return new GroupMessage(m, parentId, author);
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException | FormatException e) {
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (FormatException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,9 +324,7 @@ public class TestDataCreatorImpl implements TestDataCreator {
|
|||||||
.createBlogPost(blog.getId(), timestamp, null, author,
|
.createBlogPost(blog.getId(), timestamp, null, author,
|
||||||
body);
|
body);
|
||||||
blogManager.addLocalPost(blogPost);
|
blogManager.addLocalPost(blogPost);
|
||||||
} catch (FormatException e) {
|
} catch (FormatException | GeneralSecurityException e) {
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (GeneralSecurityException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -924,9 +924,7 @@ public class IntroductionIntegrationTest
|
|||||||
time);
|
time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DbException exception) {
|
} catch (DbException | FormatException exception) {
|
||||||
eventWaiter.rethrow(exception);
|
|
||||||
} catch (FormatException exception) {
|
|
||||||
eventWaiter.rethrow(exception);
|
eventWaiter.rethrow(exception);
|
||||||
} finally {
|
} finally {
|
||||||
eventWaiter.resume();
|
eventWaiter.resume();
|
||||||
|
|||||||
Reference in New Issue
Block a user