JAMES-2366 adopt fail-fast coding style

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/930e7e52
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/930e7e52
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/930e7e52

Branch: refs/heads/master
Commit: 930e7e52f7f7b5138123009456d5e61afec96788
Parents: 949594c
Author: Matthieu Baechler <matth...@apache.org>
Authored: Tue Apr 17 15:02:05 2018 +0200
Committer: Matthieu Baechler <matth...@apache.org>
Committed: Tue Apr 24 14:45:26 2018 +0200

----------------------------------------------------------------------
 .../rrt/lib/AbstractRecipientRewriteTable.java  | 82 ++++++++++----------
 1 file changed, 41 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/930e7e52/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
----------------------------------------------------------------------
diff --git 
a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
 
b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
index 7249250..001b554 100644
--- 
a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
+++ 
b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
@@ -109,59 +109,59 @@ public abstract class AbstractRecipientRewriteTable 
implements RecipientRewriteT
 
         if (targetMappings.contains(Type.Error)) {
             throw new 
ErrorMappingException(targetMappings.getError().getErrorMessage());
-        } else {
-            MappingsImpl.Builder mappings = MappingsImpl.builder();
+        }
 
-            for (String target : targetMappings.asStrings()) {
-                Type type = Mapping.detectType(target);
-                Optional<String> maybeAddressWithMappingApplied = 
applyMapping(user, domain, target, type);
+        MappingsImpl.Builder mappings = MappingsImpl.builder();
 
-                if (!maybeAddressWithMappingApplied.isPresent()) {
-                    continue;
-                }
-                String addressWithMappingApplied = 
maybeAddressWithMappingApplied.get();
-                LOGGER.debug("Valid virtual user mapping {}@{} to {}", user, 
domain.name(), addressWithMappingApplied);
-
-                if (recursive) {
-
-                    String userName;
-                    Domain targetDomain;
-                    String[] args = addressWithMappingApplied.split("@");
-
-                    if (args.length > 1) {
-                        userName = args[0];
-                        targetDomain = Domain.of(args[1]);
-                    } else {
-                        // TODO Is that the right todo here?
-                        userName = addressWithMappingApplied;
-                        targetDomain = domain;
-                    }
+        for (String target : targetMappings.asStrings()) {
+            Type type = Mapping.detectType(target);
+            Optional<String> maybeAddressWithMappingApplied = 
applyMapping(user, domain, target, type);
 
-                    // Check if the returned mapping is the same as the
-                    // input. If so return null to avoid loops
-                    if (userName.equalsIgnoreCase(user) && 
targetDomain.equals(domain)) {
-                        if (type.equals(Type.Forward)) {
-                            mappings.add(toMapping(addressWithMappingApplied, 
type));
-                            continue;
-                        }
-                        return MappingsImpl.empty();
-                    }
+            if (!maybeAddressWithMappingApplied.isPresent()) {
+                continue;
+            }
+            String addressWithMappingApplied = 
maybeAddressWithMappingApplied.get();
+            LOGGER.debug("Valid virtual user mapping {}@{} to {}", user, 
domain.name(), addressWithMappingApplied);
+
+            if (recursive) {
+
+                String userName;
+                Domain targetDomain;
+                String[] args = addressWithMappingApplied.split("@");
 
-                    Mappings childMappings = getMappings(userName, 
targetDomain, mappingLimit - 1);
+                if (args.length > 1) {
+                    userName = args[0];
+                    targetDomain = Domain.of(args[1]);
+                } else {
+                    // TODO Is that the right todo here?
+                    userName = addressWithMappingApplied;
+                    targetDomain = domain;
+                }
 
-                    if (childMappings.isEmpty()) {
-                        // add mapping
+                // Check if the returned mapping is the same as the
+                // input. If so return null to avoid loops
+                if (userName.equalsIgnoreCase(user) && 
targetDomain.equals(domain)) {
+                    if (type.equals(Type.Forward)) {
                         mappings.add(toMapping(addressWithMappingApplied, 
type));
-                    } else {
-                        mappings = mappings.addAll(childMappings);
+                        continue;
                     }
+                    return MappingsImpl.empty();
+                }
 
-                } else {
+                Mappings childMappings = getMappings(userName, targetDomain, 
mappingLimit - 1);
+
+                if (childMappings.isEmpty()) {
+                    // add mapping
                     mappings.add(toMapping(addressWithMappingApplied, type));
+                } else {
+                    mappings = mappings.addAll(childMappings);
                 }
+
+            } else {
+                mappings.add(toMapping(addressWithMappingApplied, type));
             }
-            return mappings.build();
         }
+        return mappings.build();
     }
 
     private Mapping toMapping(String mappedAddress, Type type) {


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to