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