Replace remaining 'blacklist' with 'denylist' in internal class and method names (#2784)
* Replace blacklist with denylist in BlacklistedPathPatternMatcher Signed-off-by: Tianli Feng <ftianli@amazon.com> * Replace blacklist with denylist in assumption message Signed-off-by: Tianli Feng <ftianli@amazon.com> * Replace all Blacklisted with Denylisted Signed-off-by: Tianli Feng <ftianli@amazon.com> * Replace all blacklist(key) with denylist(key) Signed-off-by: Tianli Feng <ftianli@amazon.com> * Adjust format by spotlessApply task Signed-off-by: Tianli Feng <ftianli@amazon.com>
This commit is contained in:
parent
249155772b
commit
47a22bb08d
|
@ -274,7 +274,7 @@ class BindingProcessor extends AbstractProcessor {
|
|||
}
|
||||
|
||||
// prevent the parent from creating a JIT binding for this key
|
||||
injector.state.parent().blacklist(key);
|
||||
injector.state.parent().denylist(key);
|
||||
injector.state.putBinding(key, binding);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,18 +143,18 @@ class InheritingState implements State {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void blacklist(Key<?> key) {
|
||||
parent.blacklist(key);
|
||||
public void denylist(Key<?> key) {
|
||||
parent.denylist(key);
|
||||
denylistedKeys.add(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlacklisted(Key<?> key) {
|
||||
public boolean isDenylisted(Key<?> key) {
|
||||
return denylistedKeys.contains(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBlacklisted() {
|
||||
public void clearDenylisted() {
|
||||
denylistedKeys = new WeakKeySet();
|
||||
}
|
||||
|
||||
|
|
|
@ -530,12 +530,12 @@ class InjectorImpl implements Injector, Lookups {
|
|||
* other ancestor injectors until this injector is tried.
|
||||
*/
|
||||
private <T> BindingImpl<T> createJustInTimeBindingRecursive(Key<T> key, Errors errors) throws ErrorsException {
|
||||
if (state.isBlacklisted(key)) {
|
||||
if (state.isDenylisted(key)) {
|
||||
throw errors.childBindingAlreadySet(key).toException();
|
||||
}
|
||||
|
||||
BindingImpl<T> binding = createJustInTimeBinding(key, errors);
|
||||
state.parent().blacklist(key);
|
||||
state.parent().denylist(key);
|
||||
jitBindings.put(key, binding);
|
||||
return binding;
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ class InjectorImpl implements Injector, Lookups {
|
|||
* if the binding cannot be created.
|
||||
*/
|
||||
<T> BindingImpl<T> createJustInTimeBinding(Key<T> key, Errors errors) throws ErrorsException {
|
||||
if (state.isBlacklisted(key)) {
|
||||
if (state.isDenylisted(key)) {
|
||||
throw errors.childBindingAlreadySet(key).toException();
|
||||
}
|
||||
|
||||
|
@ -805,7 +805,7 @@ class InjectorImpl implements Injector, Lookups {
|
|||
|
||||
// ES_GUICE: clear caches
|
||||
public void clearCache() {
|
||||
state.clearBlacklisted();
|
||||
state.clearDenylisted();
|
||||
constructors = new ConstructorInjectorStore(this);
|
||||
membersInjectorStore = new MembersInjectorStore(this, state.getTypeListenerBindings());
|
||||
jitBindings = new HashMap<>();
|
||||
|
|
|
@ -106,15 +106,15 @@ interface State {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void blacklist(Key<?> key) {}
|
||||
public void denylist(Key<?> key) {}
|
||||
|
||||
@Override
|
||||
public boolean isBlacklisted(Key<?> key) {
|
||||
public boolean isDenylisted(Key<?> key) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearBlacklisted() {}
|
||||
public void clearDenylisted() {}
|
||||
|
||||
@Override
|
||||
public void makeAllBindingsToEagerSingletons(Injector injector) {}
|
||||
|
@ -167,13 +167,13 @@ interface State {
|
|||
* denylist their bound keys on their parent injectors to prevent just-in-time bindings on the
|
||||
* parent injector that would conflict.
|
||||
*/
|
||||
void blacklist(Key<?> key);
|
||||
void denylist(Key<?> key);
|
||||
|
||||
/**
|
||||
* Returns true if {@code key} is forbidden from being bound in this injector. This indicates that
|
||||
* one of this injector's descendent's has bound the key.
|
||||
*/
|
||||
boolean isBlacklisted(Key<?> key);
|
||||
boolean isDenylisted(Key<?> key);
|
||||
|
||||
/**
|
||||
* Returns the shared lock for all injector data. This is a low-granularity, high-contention lock
|
||||
|
@ -182,7 +182,7 @@ interface State {
|
|||
Object lock();
|
||||
|
||||
// ES_GUICE: clean denylist keys
|
||||
void clearBlacklisted();
|
||||
void clearDenylisted();
|
||||
|
||||
void makeAllBindingsToEagerSingletons(Injector injector);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ import java.util.regex.Pattern;
|
|||
*
|
||||
* Each denylist pattern is a suffix match on the path. Empty patterns are not allowed.
|
||||
*/
|
||||
final class BlacklistedPathPatternMatcher {
|
||||
final class DenylistedPathPatternMatcher {
|
||||
private final Pattern pattern;
|
||||
|
||||
/**
|
||||
|
@ -55,7 +55,7 @@ final class BlacklistedPathPatternMatcher {
|
|||
*
|
||||
* @param p The suffix pattern. Must be a non-empty string.
|
||||
*/
|
||||
BlacklistedPathPatternMatcher(String p) {
|
||||
DenylistedPathPatternMatcher(String p) {
|
||||
// guard against accidentally matching everything as an empty string lead to the pattern ".*" which matches everything
|
||||
if (p == null || p.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("Empty denylist patterns are not supported");
|
|
@ -116,7 +116,7 @@ public abstract class OpenSearchClientYamlSuiteTestCase extends OpenSearchRestTe
|
|||
*/
|
||||
private static final String PATHS_SEPARATOR = "(?<!\\\\),";
|
||||
|
||||
private static List<BlacklistedPathPatternMatcher> denylistPathMatchers;
|
||||
private static List<DenylistedPathPatternMatcher> denylistPathMatchers;
|
||||
private static ClientYamlTestExecutionContext restTestExecutionContext;
|
||||
private static ClientYamlTestExecutionContext adminExecutionContext;
|
||||
private static ClientYamlTestClient clientYamlTestClient;
|
||||
|
@ -157,11 +157,11 @@ public abstract class OpenSearchClientYamlSuiteTestCase extends OpenSearchRestTe
|
|||
final String[] denylist = resolvePathsProperty(REST_TESTS_DENYLIST, null);
|
||||
denylistPathMatchers = new ArrayList<>();
|
||||
for (final String entry : denylist) {
|
||||
denylistPathMatchers.add(new BlacklistedPathPatternMatcher(entry));
|
||||
denylistPathMatchers.add(new DenylistedPathPatternMatcher(entry));
|
||||
}
|
||||
final String[] denylistAdditions = resolvePathsProperty(REST_TESTS_DENYLIST_ADDITIONS, null);
|
||||
for (final String entry : denylistAdditions) {
|
||||
denylistPathMatchers.add(new BlacklistedPathPatternMatcher(entry));
|
||||
denylistPathMatchers.add(new DenylistedPathPatternMatcher(entry));
|
||||
}
|
||||
}
|
||||
assert restTestExecutionContext != null;
|
||||
|
@ -368,12 +368,9 @@ public abstract class OpenSearchClientYamlSuiteTestCase extends OpenSearchRestTe
|
|||
|
||||
public void test() throws IOException {
|
||||
// skip test if it matches one of the denylist globs
|
||||
for (BlacklistedPathPatternMatcher denylistedPathMatcher : denylistPathMatchers) {
|
||||
for (DenylistedPathPatternMatcher denylistedPathMatcher : denylistPathMatchers) {
|
||||
String testPath = testCandidate.getSuitePath() + "/" + testCandidate.getTestSection().getName();
|
||||
assumeFalse(
|
||||
"[" + testCandidate.getTestPath() + "] skipped, reason: blacklisted",
|
||||
denylistedPathMatcher.isSuffixMatch(testPath)
|
||||
);
|
||||
assumeFalse("[" + testCandidate.getTestPath() + "] skipped, reason: denylisted", denylistedPathMatcher.isSuffixMatch(testPath));
|
||||
}
|
||||
|
||||
// skip test if the whole suite (yaml file) is disabled
|
||||
|
|
|
@ -33,7 +33,7 @@ package org.opensearch.test.rest.yaml;
|
|||
|
||||
import org.opensearch.test.OpenSearchTestCase;
|
||||
|
||||
public class BlacklistedPathPatternMatcherTests extends OpenSearchTestCase {
|
||||
public class DenylistedPathPatternMatcherTests extends OpenSearchTestCase {
|
||||
|
||||
public void testMatchesExact() {
|
||||
// suffix match
|
||||
|
@ -71,12 +71,12 @@ public class BlacklistedPathPatternMatcherTests extends OpenSearchTestCase {
|
|||
}
|
||||
|
||||
private void assertMatch(String pattern, String path) {
|
||||
BlacklistedPathPatternMatcher matcher = new BlacklistedPathPatternMatcher(pattern);
|
||||
DenylistedPathPatternMatcher matcher = new DenylistedPathPatternMatcher(pattern);
|
||||
assertTrue("Pattern [" + pattern + "] should have matched path [" + path + "]", matcher.isSuffixMatch(path));
|
||||
}
|
||||
|
||||
private void assertNoMatch(String pattern, String path) {
|
||||
BlacklistedPathPatternMatcher matcher = new BlacklistedPathPatternMatcher(pattern);
|
||||
DenylistedPathPatternMatcher matcher = new DenylistedPathPatternMatcher(pattern);
|
||||
assertFalse("Pattern [" + pattern + "] should not have matched path [" + path + "]", matcher.isSuffixMatch(path));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue