SEC-599: Refactoring to use Map.Entry for iterating through patterns.

This commit is contained in:
Luke Taylor 2008-01-18 16:33:36 +00:00
parent 04c89e0795
commit a40bb11be3
2 changed files with 5 additions and 12 deletions

View File

@ -111,10 +111,11 @@ public abstract class AbstractFilterInvocationDefinitionSource implements Filter
} }
} }
Iterator patterns = requestMap.keySet().iterator(); Iterator entries = requestMap.entrySet().iterator();
while (patterns.hasNext()) { while (entries.hasNext()) {
Object p = patterns.next(); Map.Entry entry = (Map.Entry) entries.next();
Object p = entry.getKey();
boolean matched = urlMatcher.pathMatchesUrl(p, url); boolean matched = urlMatcher.pathMatchesUrl(p, url);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
@ -122,7 +123,7 @@ public abstract class AbstractFilterInvocationDefinitionSource implements Filter
} }
if (matched) { if (matched) {
return (ConfigAttributeDefinition) getRequestMap().get(p); return (ConfigAttributeDefinition) entry.getValue();
} }
} }

View File

@ -47,14 +47,6 @@ public class AbstractFilterInvocationDefinitionSourceTests extends TestCase {
//~ Methods ======================================================================================================== //~ Methods ========================================================================================================
public static void main(String[] args) {
junit.textui.TestRunner.run(AbstractFilterInvocationDefinitionSourceTests.class);
}
public final void setUp() throws Exception {
super.setUp();
}
public void testDoesNotSupportAnotherObject() { public void testDoesNotSupportAnotherObject() {
MockFilterInvocationDefinitionSource mfis = new MockFilterInvocationDefinitionSource(false, true); MockFilterInvocationDefinitionSource mfis = new MockFilterInvocationDefinitionSource(false, true);
assertFalse(mfis.supports(String.class)); assertFalse(mfis.supports(String.class));