Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x

This commit is contained in:
Jan Bartel 2020-07-06 10:37:32 +02:00
commit bd15434915
2 changed files with 16 additions and 3 deletions

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.servlet;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.servlet.DispatcherType;
@ -159,7 +160,7 @@ public class FilterMapping implements Dumpable
if (_holder == null)
return false;
if (_dispatches == 0)
return type == REQUEST || type == ASYNC && holder.isAsyncSupported();
return type == REQUEST || type == ASYNC && (_holder != null && _holder.isAsyncSupported());
return (_dispatches & type) != 0;
}
@ -251,7 +252,7 @@ public class FilterMapping implements Dumpable
*/
public void setFilterName(String filterName)
{
_filterName = filterName;
_filterName = Objects.requireNonNull(filterName);
}
/**
@ -259,7 +260,7 @@ public class FilterMapping implements Dumpable
*/
void setFilterHolder(FilterHolder holder)
{
_holder = holder;
_holder = Objects.requireNonNull(holder);
setFilterName(holder.getName());
}

View File

@ -25,6 +25,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ -314,6 +315,7 @@ public class ServletHandlerTest
//add another ordinary mapping
FilterHolder of1 = new FilterHolder(new Source(Source.Origin.DESCRIPTOR, "foo.xml"));
of1.setName("foo");
FilterMapping ofm1 = new FilterMapping();
ofm1.setFilterHolder(of1);
ofm1.setPathSpec("/*");
@ -449,6 +451,16 @@ public class ServletHandlerTest
assertTrue(fm5 == mappings[mappings.length - 1]);
}
@Test
public void testFilterMappingNoFilter() throws Exception
{
FilterMapping mapping = new FilterMapping();
mapping.setPathSpec("/*");
mapping.setFilterName("foo");
//default dispatch is REQUEST, and there is no holder to check for async supported
assertFalse(mapping.appliesTo(DispatcherType.ASYNC));
}
@Test
public void testFilterMappingsMix() throws Exception
{