Commit 97c95732 authored by Christian Schudt's avatar Christian Schudt

Java 7: Collapse identical catch blocks.

parent 6cc1e42d
...@@ -751,11 +751,7 @@ public class XMPPServer { ...@@ -751,11 +751,7 @@ public class XMPPServer {
if (openfireHome == null) { if (openfireHome == null) {
try { try {
openfireHome = verifyHome("..", jiveConfigName).getCanonicalFile(); openfireHome = verifyHome("..", jiveConfigName).getCanonicalFile();
} } catch (IOException ie) {
catch (FileNotFoundException fe) {
// Ignore.
}
catch (IOException ie) {
// Ignore. // Ignore.
} }
} }
......
...@@ -768,8 +768,6 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -768,8 +768,6 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
rootE.addElement("newSecret").setText(newSecret); rootE.addElement("newSecret").setText(newSecret);
executeRequest(POST, path, groupDoc.asXML()); executeRequest(POST, path, groupDoc.asXML());
} catch (UnauthorizedException ue) {
Log.error("Error updating the password of Clearspace", ue);
} catch (Exception e) { } catch (Exception e) {
Log.error("Error updating the password of Clearspace", e); Log.error("Error updating the password of Clearspace", e);
} }
...@@ -808,8 +806,6 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -808,8 +806,6 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
rootE.addElement("tcpPort").setText(xmppPort); rootE.addElement("tcpPort").setText(xmppPort);
executeRequest(POST, path, groupDoc.asXML()); executeRequest(POST, path, groupDoc.asXML());
} catch (UnauthorizedException ue) {
Log.error("Error updating the client settings of Clearspace", ue);
} catch (Exception e) { } catch (Exception e) {
Log.error("Error updating the client settings of Clearspace", e); Log.error("Error updating the client settings of Clearspace", e);
} }
......
...@@ -92,17 +92,7 @@ public class AuthenticateUser extends AdHocCommand { ...@@ -92,17 +92,7 @@ public class AuthenticateUser extends AdHocCommand {
try { try {
AuthFactory.authenticate(user.getUsername(), password); AuthFactory.authenticate(user.getUsername(), password);
} }
catch (UnauthorizedException e) { catch (UnauthorizedException | ConnectionException | InternalUnauthenticatedException e) {
// Auth failed
note.addAttribute("type", "error");
note.setText("Authentication failed.");
return;
} catch (ConnectionException e) {
// Auth failed
note.addAttribute("type", "error");
note.setText("Authentication failed.");
return;
} catch (InternalUnauthenticatedException e) {
// Auth failed // Auth failed
note.addAttribute("type", "error"); note.addAttribute("type", "error");
note.setText("Authentication failed."); note.setText("Authentication failed.");
......
...@@ -193,20 +193,11 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo { ...@@ -193,20 +193,11 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
} }
} }
} }
catch (UserNotFoundException e) { catch (UserNotFoundException | UnauthorizedException e) {
response = IQ.createResultIQ(packet);
response.setChildElement(packet.getChildElement().createCopy());
response.setError(PacketError.Condition.not_authorized);
}
catch (UnauthorizedException e) {
response = IQ.createResultIQ(packet); response = IQ.createResultIQ(packet);
response.setChildElement(packet.getChildElement().createCopy()); response.setChildElement(packet.getChildElement().createCopy());
response.setError(PacketError.Condition.not_authorized); response.setError(PacketError.Condition.not_authorized);
} catch (ConnectionException e) { } catch (ConnectionException | InternalUnauthenticatedException e) {
response = IQ.createResultIQ(packet);
response.setChildElement(packet.getChildElement().createCopy());
response.setError(PacketError.Condition.internal_server_error);
} catch (InternalUnauthenticatedException e) {
response = IQ.createResultIQ(packet); response = IQ.createResultIQ(packet);
response.setChildElement(packet.getChildElement().createCopy()); response.setChildElement(packet.getChildElement().createCopy());
response.setError(PacketError.Condition.internal_server_error); response.setError(PacketError.Condition.internal_server_error);
......
...@@ -219,13 +219,10 @@ public class HttpBindServlet extends HttpServlet { ...@@ -219,13 +219,10 @@ public class HttpBindServlet extends HttpServlet {
Log.info(new Date() + ": HTTP RECV(" + connection.getSession().getStreamID().getID() + "): " + rootNode.asXML()); Log.info(new Date() + ": HTTP RECV(" + connection.getSession().getStreamID().getID() + "): " + rootNode.asXML());
} }
} }
catch (UnauthorizedException e) { catch (UnauthorizedException | HttpBindException e) {
// Server wasn't initialized yet. // Server wasn't initialized yet.
sendLegacyError(context, BoshBindingError.internalServerError, "Server has not finished initialization." ); sendLegacyError(context, BoshBindingError.internalServerError, "Server has not finished initialization." );
} }
catch (HttpBindException e) {
sendLegacyError(context, BoshBindingError.internalServerError, "Server has not finished initialization." );
}
} }
private void handleSessionRequest(String sid, AsyncContext context, Element rootNode) private void handleSessionRequest(String sid, AsyncContext context, Element rootNode)
......
...@@ -74,9 +74,7 @@ public class HttpConnection { ...@@ -74,9 +74,7 @@ public class HttpConnection {
try { try {
deliverBody(null, true); deliverBody(null, true);
} }
catch (HttpConnectionClosedException e) { catch (HttpConnectionClosedException | IOException e) {
Log.warn("Unexpected exception occurred while trying to close an HttpException.", e);
} catch (IOException e) {
Log.warn("Unexpected exception occurred while trying to close an HttpException.", e); Log.warn("Unexpected exception occurred while trying to close an HttpException.", e);
} }
} }
......
...@@ -208,14 +208,7 @@ public class HttpSessionManager { ...@@ -208,14 +208,7 @@ public class HttpSessionManager {
try { try {
connection.deliverBody(createSessionCreationResponse(session), true); connection.deliverBody(createSessionCreationResponse(session), true);
} }
catch (HttpConnectionClosedException e) { catch (HttpConnectionClosedException | DocumentException | IOException e) {
Log.error("Error creating session.", e);
throw new HttpBindException("Internal server error", BoshBindingError.internalServerError);
}
catch (DocumentException e) {
Log.error("Error creating session.", e);
throw new HttpBindException("Internal server error", BoshBindingError.internalServerError);
} catch (IOException e) {
Log.error("Error creating session.", e); Log.error("Error creating session.", e);
throw new HttpBindException("Internal server error", BoshBindingError.internalServerError); throw new HttpBindException("Internal server error", BoshBindingError.internalServerError);
} }
......
...@@ -110,14 +110,10 @@ public class DroppableFrame extends JFrame implements DropTargetListener, DragSo ...@@ -110,14 +110,10 @@ public class DroppableFrame extends JFrame implements DropTargetListener, DragSo
dropTargetDropEvent.rejectDrop(); dropTargetDropEvent.rejectDrop();
} }
} }
catch (IOException io) { catch (IOException | UnsupportedFlavorException io) {
io.printStackTrace(); io.printStackTrace();
dropTargetDropEvent.rejectDrop(); dropTargetDropEvent.rejectDrop();
} }
catch (UnsupportedFlavorException ufe) {
ufe.printStackTrace();
dropTargetDropEvent.rejectDrop();
}
} }
@Override @Override
......
...@@ -110,14 +110,10 @@ public abstract class DroppableTextPane extends JTextPane implements DropTargetL ...@@ -110,14 +110,10 @@ public abstract class DroppableTextPane extends JTextPane implements DropTargetL
dropTargetDropEvent.rejectDrop(); dropTargetDropEvent.rejectDrop();
} }
} }
catch (IOException io) { catch (IOException | UnsupportedFlavorException io) {
io.printStackTrace(); io.printStackTrace();
dropTargetDropEvent.rejectDrop(); dropTargetDropEvent.rejectDrop();
} }
catch (UnsupportedFlavorException ufe) {
ufe.printStackTrace();
dropTargetDropEvent.rejectDrop();
}
} }
@Override @Override
......
...@@ -57,16 +57,7 @@ public class Echo implements Runnable { ...@@ -57,16 +57,7 @@ public class Echo implements Runnable {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
socket.send(packet); socket.send(packet);
} }
} } catch (IOException ioe) {
catch (UnknownHostException uhe) {
if (enabled) {
}
}
catch (SocketException se) {
if (enabled) {
}
}
catch (IOException ioe) {
if (enabled) { if (enabled) {
} }
} }
......
...@@ -114,9 +114,7 @@ public class MediaProxyService extends BasicModule ...@@ -114,9 +114,7 @@ public class MediaProxyService extends BasicModule
echo = new Echo(echoPort); echo = new Echo(echoPort);
Thread t = new Thread(echo); Thread t = new Thread(echo);
t.start(); t.start();
} catch (UnknownHostException e) { } catch (UnknownHostException | SocketException e) {
// Ignore
} catch (SocketException e) {
// Ignore // Ignore
} }
......
...@@ -501,7 +501,7 @@ public class LocalMUCUser implements MUCUser { ...@@ -501,7 +501,7 @@ public class LocalMUCUser implements MUCUser {
catch (ServiceUnavailableException e) { catch (ServiceUnavailableException e) {
sendErrorPacket(packet, PacketError.Condition.service_unavailable); sendErrorPacket(packet, PacketError.Condition.service_unavailable);
} }
catch (UserAlreadyExistsException e) { catch (UserAlreadyExistsException | ConflictException e) {
sendErrorPacket(packet, PacketError.Condition.conflict); sendErrorPacket(packet, PacketError.Condition.conflict);
} }
catch (RoomLockedException e) { catch (RoomLockedException e) {
...@@ -513,11 +513,7 @@ public class LocalMUCUser implements MUCUser { ...@@ -513,11 +513,7 @@ public class LocalMUCUser implements MUCUser {
} }
catch (RegistrationRequiredException e) { catch (RegistrationRequiredException e) {
sendErrorPacket(packet, PacketError.Condition.registration_required); sendErrorPacket(packet, PacketError.Condition.registration_required);
} } catch (NotAcceptableException e) {
catch (ConflictException e) {
sendErrorPacket(packet, PacketError.Condition.conflict);
}
catch (NotAcceptableException e) {
sendErrorPacket(packet, PacketError.Condition.not_acceptable); sendErrorPacket(packet, PacketError.Condition.not_acceptable);
} }
catch (NotAllowedException e) { catch (NotAllowedException e) {
......
...@@ -641,11 +641,7 @@ public class MUCPersistenceManager { ...@@ -641,11 +641,7 @@ public class MUCPersistenceManager {
default: default:
Log.error("Unknown affiliation value " + affiliation + " for user " + affiliationJID + " in persistent room " + room.getID()); Log.error("Unknown affiliation value " + affiliation + " for user " + affiliationJID + " in persistent room " + room.getID());
} }
} catch (ForbiddenException e) { } catch (ForbiddenException | ConflictException | NotAllowedException e) {
Log.warn("An exception prevented affiliations to be added to the room with id " + roomID, e);
} catch (ConflictException e) {
Log.warn("An exception prevented affiliations to be added to the room with id " + roomID, e);
} catch (NotAllowedException e) {
Log.warn("An exception prevented affiliations to be added to the room with id " + roomID, e); Log.warn("An exception prevented affiliations to be added to the room with id " + roomID, e);
} }
} catch (SQLException e) { } catch (SQLException e) {
...@@ -680,9 +676,7 @@ public class MUCPersistenceManager { ...@@ -680,9 +676,7 @@ public class MUCPersistenceManager {
// might be a group JID // might be a group JID
affiliationJID = GroupJID.fromString(resultSet.getString(2)); affiliationJID = GroupJID.fromString(resultSet.getString(2));
room.addMember(affiliationJID, resultSet.getString(3), room.getRole()); room.addMember(affiliationJID, resultSet.getString(3), room.getRole());
} catch (ForbiddenException e) { } catch (ForbiddenException | ConflictException e) {
Log.warn("Unable to add member to room.", e);
} catch (ConflictException e) {
Log.warn("Unable to add member to room.", e); Log.warn("Unable to add member to room.", e);
} }
} catch (SQLException e) { } catch (SQLException e) {
......
...@@ -113,12 +113,10 @@ public class ClientTrustManager implements X509TrustManager { ...@@ -113,12 +113,10 @@ public class ClientTrustManager implements X509TrustManager {
try { try {
crlStore = CertStore.getInstance("Collection", params); crlStore = CertStore.getInstance("Collection", params);
} }
catch (InvalidAlgorithmParameterException ex) { catch (InvalidAlgorithmParameterException | NoSuchAlgorithmException ex) {
Log.warn("ClientTrustManager: ",ex);
} catch (NoSuchAlgorithmException ex) {
Log.warn("ClientTrustManager: ",ex); Log.warn("ClientTrustManager: ",ex);
} }
loadCRL(); loadCRL();
} }
...@@ -311,15 +309,10 @@ public class ClientTrustManager implements X509TrustManager { ...@@ -311,15 +309,10 @@ public class ClientTrustManager implements X509TrustManager {
Log.debug("ClientTrustManager: Trusted CA: "+trustedCert.getSubjectDN()); Log.debug("ClientTrustManager: Trusted CA: "+trustedCert.getSubjectDN());
} }
} }
catch(CertPathBuilderException e) { catch(CertPathBuilderException | CertPathValidatorException e) {
Log.debug("ClientTrustManager:",e);
throw new CertificateException("certificate path failed: "+e.getMessage());
}
catch(CertPathValidatorException e) {
Log.debug("ClientTrustManager:",e); Log.debug("ClientTrustManager:",e);
throw new CertificateException("certificate path failed: "+e.getMessage()); throw new CertificateException("certificate path failed: "+e.getMessage());
} } catch(Exception e) {
catch(Exception e) {
Log.debug("ClientTrustManager:",e); Log.debug("ClientTrustManager:",e);
throw new CertificateException("unexpected error: "+e.getMessage()); throw new CertificateException("unexpected error: "+e.getMessage());
} }
......
...@@ -66,11 +66,7 @@ public class SSLJiveTrustManager implements X509TrustManager { ...@@ -66,11 +66,7 @@ public class SSLJiveTrustManager implements X509TrustManager {
try { try {
x509Certificates[0].checkValidity(); x509Certificates[0].checkValidity();
} }
catch (CertificateExpiredException e) { catch (CertificateExpiredException | CertificateNotYetValidException e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
trusted = false;
}
catch (CertificateNotYetValidException e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e); Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
trusted = false; trusted = false;
} }
......
...@@ -88,12 +88,9 @@ public class XMPPCallbackHandler implements CallbackHandler { ...@@ -88,12 +88,9 @@ public class XMPPCallbackHandler implements CallbackHandler {
//Log.debug("XMPPCallbackHandler: PasswordCallback"); //Log.debug("XMPPCallbackHandler: PasswordCallback");
} }
catch (UserNotFoundException e) { catch (UserNotFoundException | UnsupportedOperationException e) {
throw new IOException(e.toString()); throw new IOException(e.toString());
} }
catch (UnsupportedOperationException uoe) {
throw new IOException(uoe.toString());
}
} }
else if (callback instanceof VerifyPasswordCallback) { else if (callback instanceof VerifyPasswordCallback) {
......
...@@ -170,12 +170,9 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us ...@@ -170,12 +170,9 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us
} }
} }
} }
catch (UnsupportedOperationException e) { catch (UnsupportedOperationException | UserNotFoundException e) {
// Do nothing // Do nothing
} }
catch (UserNotFoundException e) {
// Do nothing.
}
} }
/** /**
......
...@@ -143,10 +143,7 @@ public class SaslServerPlainImpl implements SaslServer { ...@@ -143,10 +143,7 @@ public class SaslServerPlainImpl implements SaslServer {
} }
return null; return null;
} }
} catch (UnsupportedCallbackException e) { } catch (UnsupportedCallbackException | IOException e) {
aborted = true;
throw new SaslException("PLAIN authentication failed for: "+username, e);
} catch (IOException e) {
aborted = true; aborted = true;
throw new SaslException("PLAIN authentication failed for: "+username, e); throw new SaslException("PLAIN authentication failed for: "+username, e);
} }
......
...@@ -195,13 +195,9 @@ public class User implements Cacheable, Externalizable, Result { ...@@ -195,13 +195,9 @@ public class User implements Cacheable, Externalizable, Result {
UserEventDispatcher.dispatchEvent(this, UserEventDispatcher.EventType.user_modified, UserEventDispatcher.dispatchEvent(this, UserEventDispatcher.EventType.user_modified,
params); params);
} }
catch (UserNotFoundException e) { catch (UserNotFoundException | ConnectionException | InternalUnauthenticatedException e) {
Log.error(e.getMessage(), e); Log.error(e.getMessage(), e);
} catch (ConnectionException e) { }
Log.error(e.getMessage(), e);
} catch (InternalUnauthenticatedException e) {
Log.error(e.getMessage(), e);
}
} }
public String getStoredKey() { public String getStoredKey() {
......
...@@ -505,12 +505,9 @@ public class EmailService { ...@@ -505,12 +505,9 @@ public class EmailService {
transport.sendMessage(message, transport.sendMessage(message,
message.getRecipients(MimeMessage.RecipientType.TO)); message.getRecipients(MimeMessage.RecipientType.TO));
} }
catch (AddressException ae) { catch (AddressException | SendFailedException ae) {
Log.error(ae.getMessage(), ae); Log.error(ae.getMessage(), ae);
} }
catch (SendFailedException sfe) {
Log.error(sfe.getMessage(), sfe);
}
} }
} }
finally { finally {
......
...@@ -61,10 +61,7 @@ public class SimpleSSLSocketFactory extends SSLSocketFactory { ...@@ -61,10 +61,7 @@ public class SimpleSSLSocketFactory extends SSLSocketFactory {
new java.security.SecureRandom()); new java.security.SecureRandom());
factory = sslcontent.getSocketFactory(); factory = sslcontent.getSocketFactory();
} }
catch (NoSuchAlgorithmException e) { catch (NoSuchAlgorithmException | KeyManagementException e) {
Log.error(e.getMessage(), e);
}
catch (KeyManagementException e) {
Log.error(e.getMessage(), e); Log.error(e.getMessage(), e);
} }
} }
......
...@@ -1097,10 +1097,7 @@ public class XMLWriter extends XMLFilterImpl implements LexicalHandler { ...@@ -1097,10 +1097,7 @@ public class XMLWriter extends XMLFilterImpl implements LexicalHandler {
parent.setProperty(LEXICAL_HANDLER_NAMES[i], this); parent.setProperty(LEXICAL_HANDLER_NAMES[i], this);
break; break;
} }
catch (SAXNotRecognizedException ex) { catch (SAXNotRecognizedException | SAXNotSupportedException ex) {
// ignore
}
catch (SAXNotSupportedException ex) {
// ignore // ignore
} }
} }
......
...@@ -447,12 +447,10 @@ public class CacheFactory { ...@@ -447,12 +447,10 @@ public class CacheFactory {
clusteredCacheFactoryStrategy = (CacheFactoryStrategy) Class.forName( clusteredCacheFactoryStrategy = (CacheFactoryStrategy) Class.forName(
clusteredCacheFactoryClass, true, clusteredCacheFactoryClass, true,
getClusteredCacheStrategyClassLoader()).newInstance(); getClusteredCacheStrategyClassLoader()).newInstance();
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError | Exception e) {
log.warn("Clustered cache factory strategy " + clusteredCacheFactoryClass + " not found");
} catch (Exception e) {
log.warn("Clustered cache factory strategy " + clusteredCacheFactoryClass + " not found"); log.warn("Clustered cache factory strategy " + clusteredCacheFactoryClass + " not found");
} }
} }
return (clusteredCacheFactoryStrategy != null); return (clusteredCacheFactoryStrategy != null);
} }
......
...@@ -93,8 +93,7 @@ public class SANCertificateIdentityMapping implements CertificateIdentityMapping ...@@ -93,8 +93,7 @@ public class SANCertificateIdentityMapping implements CertificateIdentityMapping
// OF-517: othername formats are extensible. If we don't recognize the format, skip it. // OF-517: othername formats are extensible. If we don't recognize the format, skip it.
Log.debug("Cannot parse altName, likely because of unknown record format.", ex); Log.debug("Cannot parse altName, likely because of unknown record format.", ex);
} }
} } catch (IOException e) {
catch (IOException e) {
// Ignore // Ignore
} }
catch (Exception e) { catch (Exception e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment