Skip to content

Commit 806104d

Browse files
committed
Collapse identical catch branches
1 parent 7a0b204 commit 806104d

24 files changed

+35
-109
lines changed

exist-core/src/main/java/org/exist/BTreeTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ public BTreeTest() {
2828

2929
BrokerPool.configure(1, 5, config);
3030
pool = BrokerPool.getInstance();
31-
} catch (DatabaseConfigurationException e) {
32-
e.printStackTrace();
33-
} catch (EXistException e) {
31+
} catch (DatabaseConfigurationException | EXistException e) {
3432
e.printStackTrace();
3533
}
3634
}
@@ -119,11 +117,7 @@ public static void main(String[] args) {
119117
} else if ("rebuild".equals(command)) {
120118
test.rebuild();
121119
}
122-
} catch (DBException e) {
123-
e.printStackTrace();
124-
} catch (IOException e) {
125-
e.printStackTrace();
126-
} catch (TerminatedException e) {
120+
} catch (DBException | TerminatedException | IOException e) {
127121
e.printStackTrace();
128122
} finally {
129123
test.shutdown();

exist-core/src/main/java/org/exist/client/security/EditGroupDialog.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,10 @@ private void setFormPropertiesFromGroup() {
7676
isGroupManager(groupManagers, groupMember)
7777
});
7878
}
79-
} catch(final XMLDBException xmldbe) {
79+
} catch(final XMLDBException | PermissionDeniedException xmldbe) {
8080
JOptionPane.showMessageDialog(this, "Could not get group members: " + xmldbe.getMessage(), "Edit Group Error", JOptionPane.ERROR_MESSAGE);
81-
} catch(final PermissionDeniedException pde) {
82-
JOptionPane.showMessageDialog(this, "Could not get group members: " + pde.getMessage(), "Edit Group Error", JOptionPane.ERROR_MESSAGE);
8381
}
84-
82+
8583
//enable additions to the group?
8684
miAddGroupMember.setEnabled(canModifyGroupMembers());
8785
btnAddMember.setEnabled(canModifyGroupMembers());
@@ -101,10 +99,8 @@ private void updateGroup() {
10199

102100
getUserManagementService().updateGroup(getGroup());
103101

104-
} catch(final PermissionDeniedException pde) {
102+
} catch(final PermissionDeniedException | XMLDBException pde) {
105103
JOptionPane.showMessageDialog(this, "Could not update group '" + txtGroupName.getText() + "': " + pde.getMessage(), "Edit Group Error", JOptionPane.ERROR_MESSAGE);
106-
} catch(final XMLDBException xmldbe) {
107-
JOptionPane.showMessageDialog(this, "Could not update group '" + txtGroupName.getText() + "': " + xmldbe.getMessage(), "Edit Group Error", JOptionPane.ERROR_MESSAGE);
108104
}
109105
}
110106

@@ -159,12 +155,9 @@ protected Group getGroup() {
159155
protected boolean canModifyGroupMembers() {
160156
try {
161157
return (getUserManagementService().getAccount(getCurrentUser()).hasDbaRole() || isGroupManager(group.getManagers(), getCurrentUser()));
162-
} catch(final XMLDBException xmldbe) {
158+
} catch(final XMLDBException | PermissionDeniedException xmldbe) {
163159
JOptionPane.showMessageDialog(this, "Could not establish user " + getCurrentUser() + "'s group permissions: " + xmldbe.getMessage(), "Edit Group Error", JOptionPane.ERROR_MESSAGE);
164160
return false;
165-
} catch(final PermissionDeniedException pde) {
166-
JOptionPane.showMessageDialog(this, "Could not establish user " + getCurrentUser() + "'s group permissions: " + pde.getMessage(), "Edit Group Error", JOptionPane.ERROR_MESSAGE);
167-
return false;
168161
}
169162
}
170163

exist-core/src/main/java/org/exist/client/security/EditUserDialog.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,8 @@ private void updateUser() {
137137
acct.setPassword(newPassword.get());
138138
getUserManagementService().updateAccount(acct);
139139
}
140-
} catch(final PermissionDeniedException pde) {
140+
} catch(final PermissionDeniedException | XMLDBException pde) {
141141
JOptionPane.showMessageDialog(this, "Could not update user '" + txtUsername.getText() + "': " + pde.getMessage(), "Edit User Error", JOptionPane.ERROR_MESSAGE);
142-
} catch(final XMLDBException xmldbe) {
143-
JOptionPane.showMessageDialog(this, "Could not update user '" + txtUsername.getText() + "': " + xmldbe.getMessage(), "Edit User Error", JOptionPane.ERROR_MESSAGE);
144142
}
145143
}
146144

exist-core/src/main/java/org/exist/client/security/UserDialog.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,9 @@ protected void createUser() {
406406
try {
407407
groupAider.addManager(userAider);
408408
getUserManagementService().updateGroup(groupAider);
409-
} catch(final XMLDBException xmldbe) {
409+
} catch(final XMLDBException | PermissionDeniedException xmldbe) {
410410
JOptionPane.showMessageDialog(this, "Could not set user '" + txtUsername.getText() + "' as manager of personal group '" + txtUsername.getText() + "': " + xmldbe.getMessage(), "Create User Error", JOptionPane.ERROR_MESSAGE);
411411
return;
412-
} catch(final PermissionDeniedException pde) {
413-
JOptionPane.showMessageDialog(this, "Could not set user '" + txtUsername.getText() + "' as manager of personal group '" + txtUsername.getText() + "': " + pde.getMessage(), "Create User Error", JOptionPane.ERROR_MESSAGE);
414-
return;
415412
}
416413
}
417414
}

exist-core/src/main/java/org/exist/debuggee/DebuggeeFactory.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ public static Debuggee getInstance() {
5151
}
5252
} catch (final ClassNotFoundException e) {
5353
LOG.warn("Class not found for debuggee: " + className);
54-
} catch (final IllegalAccessException e) {
55-
LOG.warn("Failed to instantiate class for debuggee: " + className);
56-
} catch (final InstantiationException e) {
54+
} catch (final IllegalAccessException | InstantiationException e) {
5755
LOG.warn("Failed to instantiate class for debuggee: " + className);
5856
}
5957
if (instance == null)

exist-core/src/main/java/org/exist/dom/persistent/SortedNodeSet.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
*/
2222
package org.exist.dom.persistent;
2323

24+
import antlr.RecognitionException;
25+
import antlr.TokenStreamException;
2426
import antlr.collections.AST;
2527

2628
import org.exist.EXistException;
@@ -110,13 +112,9 @@ public void addAll(final NodeSet other) {
110112
final IteratorItem item = new IteratorItem(p, expr);
111113
list.add(item);
112114
}
113-
} catch(final antlr.RecognitionException re) {
115+
} catch(final RecognitionException | TokenStreamException re) {
114116
LOG.debug(re); //TODO : throw exception ! -pb
115-
} catch(final antlr.TokenStreamException tse) {
116-
LOG.debug(tse); //TODO : throw exception ! -pb
117-
} catch(final EXistException e) {
118-
LOG.debug("Exception during sort", e); //TODO : throw exception ! -pb
119-
} catch(final XPathException e) {
117+
} catch(final EXistException | XPathException e) {
120118
LOG.debug("Exception during sort", e); //TODO : throw exception ! -pb
121119
}
122120
LOG.debug("sort-expression found " + list.size() + " in "

exist-core/src/main/java/org/exist/dom/persistent/VirtualNodeSet.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,13 +526,11 @@ private void addChildren(final NodeProxy contextNode, final NodeSet result) {
526526
++level;
527527
}
528528
}
529-
} catch(final IOException e) {
529+
} catch(final IOException | XMLStreamException e) {
530530
LOG.error(e);
531531
//TODO : throw exception ,
532-
} catch(final XMLStreamException e) {
533-
LOG.error(e);
534-
//TODO : throw exception ? -pb
535-
}
532+
} //TODO : throw exception ? -pb
533+
536534
}
537535

538536
/**

exist-core/src/main/java/org/exist/http/Descriptor.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,9 @@ private Descriptor() {
159159
if (maps.getLength() > 0) {
160160
configureMaps((Element) maps.item(0));
161161
}
162-
} catch (final SAXException e) {
162+
} catch (final SAXException | IOException | ParserConfigurationException e) {
163163
LOG.warn("Error while reading descriptor file: " + file, e);
164164
return;
165-
} catch (final ParserConfigurationException cfg) {
166-
LOG.warn("Error while reading descriptor file: " + file, cfg);
167-
return;
168-
} catch (final IOException io) {
169-
LOG.warn("Error while reading descriptor file: " + file, io);
170-
return;
171165
} finally {
172166
if (is != null) {
173167
try {

exist-core/src/main/java/org/exist/http/RESTServer.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,11 +2216,7 @@ private void writeResultJSON(final HttpServletResponse response,
22162216

22172217
writer.flush();
22182218
writer.close();
2219-
} catch (final IOException e) {
2220-
throw new BadRequestException("Error while serializing xml: " + e.toString(), e);
2221-
} catch (final SAXException e) {
2222-
throw new BadRequestException("Error while serializing xml: " + e.toString(), e);
2223-
} catch (final XPathException e) {
2219+
} catch (final IOException | XPathException | SAXException e) {
22242220
throw new BadRequestException("Error while serializing xml: " + e.toString(), e);
22252221
}
22262222
}

exist-core/src/main/java/org/exist/http/servlets/AbstractExistHttpServlet.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,24 +141,16 @@ private void doDatabaseStartup(Configuration configuration) throws ServletExcept
141141
if(!BrokerPool.isConfigured()) {
142142
BrokerPool.configure(1, 5, configuration);
143143
}
144-
} catch(final EXistException e) {
145-
throw new ServletException(e.getMessage(), e);
146-
} catch(final DatabaseConfigurationException e) {
144+
} catch(final EXistException | DatabaseConfigurationException e) {
147145
throw new ServletException(e.getMessage(), e);
148146
}
149-
147+
150148
try {
151149
getLog().info("Registering XMLDB driver");
152150
final Class<?> clazz = Class.forName("org.exist.xmldb.DatabaseImpl");
153151
final Database database = (Database) clazz.newInstance();
154152
DatabaseManager.registerDatabase(database);
155-
} catch(final ClassNotFoundException e) {
156-
getLog().info("ERROR", e);
157-
} catch(final InstantiationException e) {
158-
getLog().info("ERROR", e);
159-
} catch(final IllegalAccessException e) {
160-
getLog().info("ERROR", e);
161-
} catch(final XMLDBException e) {
153+
} catch(final ClassNotFoundException | XMLDBException | IllegalAccessException | InstantiationException e) {
162154
getLog().info("ERROR", e);
163155
}
164156
}

0 commit comments

Comments
 (0)