* Fix #6868 Fix copy constructors Fixed copy constructors found by static code analysis Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
4793092f9d
commit
f398da7200
|
@ -144,6 +144,7 @@ public class HttpConfiguration implements Dumpable
|
|||
_responseCookieCompliance = config._responseCookieCompliance;
|
||||
_notifyRemoteAsyncErrors = config._notifyRemoteAsyncErrors;
|
||||
_relativeRedirectAllowed = config._relativeRedirectAllowed;
|
||||
_uriCompliance = config._uriCompliance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -496,6 +496,7 @@ public class ClassMatcher extends AbstractSet<String>
|
|||
{
|
||||
}
|
||||
|
||||
@SuppressWarnings("CopyConstructorMissesField")
|
||||
public ClassMatcher(ClassMatcher patterns)
|
||||
{
|
||||
if (patterns != null)
|
||||
|
@ -676,7 +677,7 @@ public class ClassMatcher extends AbstractSet<String>
|
|||
*/
|
||||
public String[] getPatterns()
|
||||
{
|
||||
return toArray(new String[_entries.size()]);
|
||||
return toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
|
@ -119,6 +120,13 @@ public class ClassMatcherTest
|
|||
assertTrue(_pattern.match("org.example.Anything$Else"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopy()
|
||||
{
|
||||
ClassMatcher copy = new ClassMatcher(_pattern);
|
||||
assertThat(copy.toString(), is(_pattern.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchFundamentalExcludeSpecific()
|
||||
{
|
||||
|
@ -145,9 +153,9 @@ public class ClassMatcherTest
|
|||
|
||||
ClassMatcher pattern = new ClassMatcher();
|
||||
pattern.include("something");
|
||||
assertThat(pattern.match(String.class), Matchers.is(false));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(false));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(false));
|
||||
assertThat(pattern.match(String.class), is(false));
|
||||
assertThat(pattern.match(Test.class), is(false));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), is(false));
|
||||
|
||||
// Add directory for both JVM classes
|
||||
pattern.include(locString.toASCIIString());
|
||||
|
@ -155,14 +163,14 @@ public class ClassMatcherTest
|
|||
// Add jar for individual class and classes directory
|
||||
pattern.include(locJunit.toString(), locTest.toString());
|
||||
|
||||
assertThat(pattern.match(String.class), Matchers.is(true));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(true));
|
||||
assertThat(pattern.match(String.class), is(true));
|
||||
assertThat(pattern.match(Test.class), is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), is(true));
|
||||
|
||||
pattern.add("-java.lang.String");
|
||||
assertThat(pattern.match(String.class), Matchers.is(false));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(true));
|
||||
assertThat(pattern.match(String.class), is(false));
|
||||
assertThat(pattern.match(Test.class), is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), is(true));
|
||||
}
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
|
@ -183,9 +191,9 @@ public class ClassMatcherTest
|
|||
|
||||
ClassMatcher pattern = new ClassMatcher();
|
||||
pattern.include("something");
|
||||
assertThat(pattern.match(String.class), Matchers.is(false));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(false));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(false));
|
||||
assertThat(pattern.match(String.class), is(false));
|
||||
assertThat(pattern.match(Test.class), is(false));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), is(false));
|
||||
|
||||
// Add module for all JVM base classes
|
||||
pattern.include("jrt:/java.base");
|
||||
|
@ -193,14 +201,14 @@ public class ClassMatcherTest
|
|||
// Add jar for individual class and classes directory
|
||||
pattern.include(locJunit.toString(), locTest.toString());
|
||||
|
||||
assertThat(pattern.match(String.class), Matchers.is(true));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(true));
|
||||
assertThat(pattern.match(String.class), is(true));
|
||||
assertThat(pattern.match(Test.class), is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), is(true));
|
||||
|
||||
pattern.add("-java.lang.String");
|
||||
assertThat(pattern.match(String.class), Matchers.is(false));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(true));
|
||||
assertThat(pattern.match(String.class), is(false));
|
||||
assertThat(pattern.match(Test.class), is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), is(true));
|
||||
}
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
|
@ -224,9 +232,9 @@ public class ClassMatcherTest
|
|||
// include everything
|
||||
pattern.include(".");
|
||||
|
||||
assertThat(pattern.match(String.class), Matchers.is(true));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(true));
|
||||
assertThat(pattern.match(String.class), is(true));
|
||||
assertThat(pattern.match(Test.class), is(true));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), is(true));
|
||||
|
||||
// Add directory for both JVM classes
|
||||
pattern.exclude("jrt:/java.base/");
|
||||
|
@ -234,9 +242,9 @@ public class ClassMatcherTest
|
|||
// Add jar for individual class and classes directory
|
||||
pattern.exclude(locJunit.toString(), locTest.toString());
|
||||
|
||||
assertThat(pattern.match(String.class), Matchers.is(false));
|
||||
assertThat(pattern.match(Test.class), Matchers.is(false));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), Matchers.is(false));
|
||||
assertThat(pattern.match(String.class), is(false));
|
||||
assertThat(pattern.match(Test.class), is(false));
|
||||
assertThat(pattern.match(ClassMatcherTest.class), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -248,33 +256,33 @@ public class ClassMatcherTest
|
|||
IncludeExcludeSet<Entry, URI> locations = new IncludeExcludeSet<>(ByLocationOrModule.class);
|
||||
|
||||
//Test no name or location includes or excludes - should match
|
||||
assertThat(ClassMatcher.combine(names, "a.b.c", locations, NULL_SUPPLIER), Matchers.is(true));
|
||||
assertThat(ClassMatcher.combine(names, "a.b.c", locations, NULL_SUPPLIER), is(true));
|
||||
|
||||
names.include(matcher.newEntry("a.b.", true));
|
||||
names.exclude(matcher.newEntry("d.e.", false));
|
||||
|
||||
//Test explicit include by name no locations - should match
|
||||
assertThat(ClassMatcher.combine(names, "a.b.c", locations, NULL_SUPPLIER), Matchers.is(true));
|
||||
assertThat(ClassMatcher.combine(names, "a.b.c", locations, NULL_SUPPLIER), is(true));
|
||||
|
||||
//Test explicit exclude by name no locations - should not match
|
||||
assertThat(ClassMatcher.combine(names, "d.e.f", locations, NULL_SUPPLIER), Matchers.is(false));
|
||||
assertThat(ClassMatcher.combine(names, "d.e.f", locations, NULL_SUPPLIER), is(false));
|
||||
|
||||
//Test include by name with location includes - should match
|
||||
locations.include(matcher.newEntry("file:/foo/bar", true));
|
||||
assertThat(ClassMatcher.combine(names, "a.b.c", locations, NULL_SUPPLIER), Matchers.is(true));
|
||||
assertThat(ClassMatcher.combine(names, "a.b.c", locations, NULL_SUPPLIER), is(true));
|
||||
|
||||
//Test include by name but with location exclusions - should not match
|
||||
locations.clear();
|
||||
locations.exclude(matcher.newEntry("file:/high/low", false));
|
||||
assertThat(ClassMatcher.combine(names, "a.b.c", locations, NULL_SUPPLIER), Matchers.is(false));
|
||||
assertThat(ClassMatcher.combine(names, "a.b.c", locations, NULL_SUPPLIER), is(false));
|
||||
|
||||
//Test neither included or excluded by name, but with location exclusions - should not match
|
||||
assertThat(ClassMatcher.combine(names, "g.b.r", locations, NULL_SUPPLIER), Matchers.is(false));
|
||||
assertThat(ClassMatcher.combine(names, "g.b.r", locations, NULL_SUPPLIER), is(false));
|
||||
|
||||
//Test neither included nor excluded by name, but with location inclusions - should not match
|
||||
locations.clear();
|
||||
locations.include(matcher.newEntry("file:/foo/bar", true));
|
||||
assertThat(ClassMatcher.combine(names, "g.b.r", locations, NULL_SUPPLIER), Matchers.is(false));
|
||||
assertThat(ClassMatcher.combine(names, "g.b.r", locations, NULL_SUPPLIER), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue