Author: felixk
Date: Thu Mar 24 21:46:19 2011
New Revision: 1085154
URL: http://svn.apache.org/viewvc?rev=1085154&view=rev
Log:
I don't see the benefit of a nested try block
Modified:
james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
Modified:
james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java?rev=1085154&r1=1085153&r2=1085154&view=diff
==============================================================================
---
james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
(original)
+++
james/server/trunk/mailets/src/main/java/org/apache/james/transport/matchers/IsInWhiteList.java
Thu Mar 24 21:46:19 2011
@@ -89,76 +89,70 @@ public class IsInWhiteList extends Abstr
PreparedStatement selectStmt = null;
ResultSet selectRS = null;
try {
+ String recipientUser =
recipientMailAddress.getLocalPart().toLowerCase(Locale.US);
+ String recipientHost =
recipientMailAddress.getDomain().toLowerCase(Locale.US);
- try {
- String recipientUser =
recipientMailAddress.getLocalPart().toLowerCase(Locale.US);
- String recipientHost =
recipientMailAddress.getDomain().toLowerCase(Locale.US);
-
- if (conn == null) {
- conn = datasource.getConnection();
- }
+ if (conn == null) {
+ conn = datasource.getConnection();
+ }
- if (selectStmt == null) {
- selectStmt = conn.prepareStatement(selectByPK);
- }
- selectStmt.setString(1, recipientUser);
- selectStmt.setString(2, recipientHost);
- selectStmt.setString(3, senderUser);
- selectStmt.setString(4, senderHost);
- selectRS = selectStmt.executeQuery();
- if (selectRS.next()) {
- // This address was already in the list
- return true;
- }
-
-
- // check for wildcard domain entries
- selectStmt = conn.prepareStatement(selectByPK);
-
- selectStmt.setString(1, recipientUser);
- selectStmt.setString(2, recipientHost);
- selectStmt.setString(3, "*");
- selectStmt.setString(4, senderHost);
- selectRS = selectStmt.executeQuery();
- if (selectRS.next()) {
- // This address was already in the list
- return true;
- }
-
-
- // check for wildcard recipient domain entries
+ if (selectStmt == null) {
selectStmt = conn.prepareStatement(selectByPK);
-
- selectStmt.setString(1, "*");
- selectStmt.setString(2, recipientHost);
- selectStmt.setString(3, senderUser);
- selectStmt.setString(4, senderHost);
- selectRS = selectStmt.executeQuery();
- if (selectRS.next()) {
- // This address was already in the list
- return true;
- }
- // check for wildcard domain entries on both
- selectStmt = conn.prepareStatement(selectByPK);
-
- selectStmt.setString(1, "*");
- selectStmt.setString(2, recipientHost);
- selectStmt.setString(3, "*");
- selectStmt.setString(4, senderHost);
- selectRS = selectStmt.executeQuery();
- if (selectRS.next()) {
- // This address was already in the list
- return true;
- }
-
- } finally {
- theJDBCUtil.closeJDBCResultSet(selectRS);
}
-
+ selectStmt.setString(1, recipientUser);
+ selectStmt.setString(2, recipientHost);
+ selectStmt.setString(3, senderUser);
+ selectStmt.setString(4, senderHost);
+ selectRS = selectStmt.executeQuery();
+ if (selectRS.next()) {
+ // This address was already in the list
+ return true;
+ }
+
+
+ // check for wildcard domain entries
+ selectStmt = conn.prepareStatement(selectByPK);
+
+ selectStmt.setString(1, recipientUser);
+ selectStmt.setString(2, recipientHost);
+ selectStmt.setString(3, "*");
+ selectStmt.setString(4, senderHost);
+ selectRS = selectStmt.executeQuery();
+ if (selectRS.next()) {
+ // This address was already in the list
+ return true;
+ }
+
+
+ // check for wildcard recipient domain entries
+ selectStmt = conn.prepareStatement(selectByPK);
+
+ selectStmt.setString(1, "*");
+ selectStmt.setString(2, recipientHost);
+ selectStmt.setString(3, senderUser);
+ selectStmt.setString(4, senderHost);
+ selectRS = selectStmt.executeQuery();
+ if (selectRS.next()) {
+ // This address was already in the list
+ return true;
+ }
+ // check for wildcard domain entries on both
+ selectStmt = conn.prepareStatement(selectByPK);
+
+ selectStmt.setString(1, "*");
+ selectStmt.setString(2, recipientHost);
+ selectStmt.setString(3, "*");
+ selectStmt.setString(4, senderHost);
+ selectRS = selectStmt.executeQuery();
+ if (selectRS.next()) {
+ // This address was already in the list
+ return true;
+ }
} catch (SQLException sqle) {
log("Error accessing database", sqle);
throw new MessagingException("Exception thrown", sqle);
} finally {
+ theJDBCUtil.closeJDBCResultSet(selectRS);
theJDBCUtil.closeJDBCStatement(selectStmt);
theJDBCUtil.closeJDBCConnection(conn);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]