Author: lukaszlenart
Date: Fri Jul 12 07:16:32 2013
New Revision: 1502451

URL: http://svn.apache.org/r1502451
Log:
WW-4121 Improves loop

Modified:
    
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RolesInterceptor.java

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RolesInterceptor.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RolesInterceptor.java?rev=1502451&r1=1502450&r2=1502451&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RolesInterceptor.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/RolesInterceptor.java
 Fri Jul 12 07:16:32 2013
@@ -21,19 +21,17 @@
 
 package org.apache.struts2.interceptor;
 
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
+import org.apache.struts2.ServletActionContext;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
-
-import org.apache.struts2.ServletActionContext;
-
 /**
  * <!-- START SNIPPET: description --> This interceptor ensures that the action
  * will only be executed if the user has the correct role. <!--
@@ -92,7 +90,7 @@ public class RolesInterceptor extends Ab
     public String intercept(ActionInvocation invocation) throws Exception {
         HttpServletRequest request = ServletActionContext.getRequest();
         HttpServletResponse response = ServletActionContext.getResponse();
-        String result = null;
+        String result;
         if (!isAllowed(request, invocation.getAction())) {
             result = handleRejection(invocation, response);
         } else {
@@ -109,7 +107,7 @@ public class RolesInterceptor extends Ab
             String[] list = val.split("[ ]*,[ ]*");
             return Arrays.asList(list);
         } else {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
     }
 
@@ -126,6 +124,7 @@ public class RolesInterceptor extends Ab
             for (String role : allowedRoles) {
                 if (request.isUserInRole(role)) {
                     result = true;
+                    break;
                 }
             }
             return result;


Reply via email to