Skip to content

Commit

Permalink
Check isFilterDisabled in runFilter.
Browse files Browse the repository at this point in the history
  • Loading branch information
ghenkes committed Jul 16, 2015
1 parent 3378b35 commit da700e1
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion zuul-core/src/main/java/com/netflix/zuul/ZuulFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public boolean isFilterDisabled() {
*/
public ZuulFilterResult runFilter() {
ZuulFilterResult zr = new ZuulFilterResult();
if (!filterDisabled.get()) {
if (!isFilterDisabled()) {
if (shouldFilter()) {
Tracer t = TracerFactory.instance().startMicroTracer("ZUUL::" + this.getClass().getSimpleName());
try {
Expand Down Expand Up @@ -197,5 +197,49 @@ public Object run() {

}

@Test
public void testIsFilterDisabled() {
class TestZuulFilter extends ZuulFilter {

@Override
public String filterType() {
return null;
}

@Override
public int filterOrder() {
return 0;
}

public boolean isFilterDisabled() {
return false;
}

public boolean shouldFilter() {
return true;
}

public Object run() {
return null;
}
}

TestZuulFilter tf1 = spy(new TestZuulFilter());
TestZuulFilter tf2 = spy(new TestZuulFilter());

when(tf1.isFilterDisabled()).thenReturn(false);
when(tf2.isFilterDisabled()).thenReturn(true);

try {
tf1.runFilter();
tf2.runFilter();
verify(tf1, times(1)).run();
verify(tf2, times(0)).run();
} catch (Throwable throwable) {
throwable.printStackTrace();
}

}

}
}

0 comments on commit da700e1

Please sign in to comment.