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:
Tianli Feng 2022-04-07 15:45:20 -07:00 committed by GitHub
parent 249155772b
commit 47a22bb08d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 28 deletions

View File

@ -274,7 +274,7 @@ class BindingProcessor extends AbstractProcessor {
} }
// prevent the parent from creating a JIT binding for this key // 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); injector.state.putBinding(key, binding);
} }

View File

@ -143,18 +143,18 @@ class InheritingState implements State {
} }
@Override @Override
public void blacklist(Key<?> key) { public void denylist(Key<?> key) {
parent.blacklist(key); parent.denylist(key);
denylistedKeys.add(key); denylistedKeys.add(key);
} }
@Override @Override
public boolean isBlacklisted(Key<?> key) { public boolean isDenylisted(Key<?> key) {
return denylistedKeys.contains(key); return denylistedKeys.contains(key);
} }
@Override @Override
public void clearBlacklisted() { public void clearDenylisted() {
denylistedKeys = new WeakKeySet(); denylistedKeys = new WeakKeySet();
} }

View File

@ -530,12 +530,12 @@ class InjectorImpl implements Injector, Lookups {
* other ancestor injectors until this injector is tried. * other ancestor injectors until this injector is tried.
*/ */
private <T> BindingImpl<T> createJustInTimeBindingRecursive(Key<T> key, Errors errors) throws ErrorsException { 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(); throw errors.childBindingAlreadySet(key).toException();
} }
BindingImpl<T> binding = createJustInTimeBinding(key, errors); BindingImpl<T> binding = createJustInTimeBinding(key, errors);
state.parent().blacklist(key); state.parent().denylist(key);
jitBindings.put(key, binding); jitBindings.put(key, binding);
return binding; return binding;
} }
@ -555,7 +555,7 @@ class InjectorImpl implements Injector, Lookups {
* if the binding cannot be created. * if the binding cannot be created.
*/ */
<T> BindingImpl<T> createJustInTimeBinding(Key<T> key, Errors errors) throws ErrorsException { <T> BindingImpl<T> createJustInTimeBinding(Key<T> key, Errors errors) throws ErrorsException {
if (state.isBlacklisted(key)) { if (state.isDenylisted(key)) {
throw errors.childBindingAlreadySet(key).toException(); throw errors.childBindingAlreadySet(key).toException();
} }
@ -805,7 +805,7 @@ class InjectorImpl implements Injector, Lookups {
// ES_GUICE: clear caches // ES_GUICE: clear caches
public void clearCache() { public void clearCache() {
state.clearBlacklisted(); state.clearDenylisted();
constructors = new ConstructorInjectorStore(this); constructors = new ConstructorInjectorStore(this);
membersInjectorStore = new MembersInjectorStore(this, state.getTypeListenerBindings()); membersInjectorStore = new MembersInjectorStore(this, state.getTypeListenerBindings());
jitBindings = new HashMap<>(); jitBindings = new HashMap<>();

View File

@ -106,15 +106,15 @@ interface State {
} }
@Override @Override
public void blacklist(Key<?> key) {} public void denylist(Key<?> key) {}
@Override @Override
public boolean isBlacklisted(Key<?> key) { public boolean isDenylisted(Key<?> key) {
return true; return true;
} }
@Override @Override
public void clearBlacklisted() {} public void clearDenylisted() {}
@Override @Override
public void makeAllBindingsToEagerSingletons(Injector injector) {} 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 * denylist their bound keys on their parent injectors to prevent just-in-time bindings on the
* parent injector that would conflict. * 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 * 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. * 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 * Returns the shared lock for all injector data. This is a low-granularity, high-contention lock
@ -182,7 +182,7 @@ interface State {
Object lock(); Object lock();
// ES_GUICE: clean denylist keys // ES_GUICE: clean denylist keys
void clearBlacklisted(); void clearDenylisted();
void makeAllBindingsToEagerSingletons(Injector injector); void makeAllBindingsToEagerSingletons(Injector injector);
} }

View File

@ -47,7 +47,7 @@ import java.util.regex.Pattern;
* *
* Each denylist pattern is a suffix match on the path. Empty patterns are not allowed. * 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; private final Pattern pattern;
/** /**
@ -55,7 +55,7 @@ final class BlacklistedPathPatternMatcher {
* *
* @param p The suffix pattern. Must be a non-empty string. * @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 // guard against accidentally matching everything as an empty string lead to the pattern ".*" which matches everything
if (p == null || p.trim().isEmpty()) { if (p == null || p.trim().isEmpty()) {
throw new IllegalArgumentException("Empty denylist patterns are not supported"); throw new IllegalArgumentException("Empty denylist patterns are not supported");

View File

@ -116,7 +116,7 @@ public abstract class OpenSearchClientYamlSuiteTestCase extends OpenSearchRestTe
*/ */
private static final String PATHS_SEPARATOR = "(?<!\\\\),"; private static final String PATHS_SEPARATOR = "(?<!\\\\),";
private static List<BlacklistedPathPatternMatcher> denylistPathMatchers; private static List<DenylistedPathPatternMatcher> denylistPathMatchers;
private static ClientYamlTestExecutionContext restTestExecutionContext; private static ClientYamlTestExecutionContext restTestExecutionContext;
private static ClientYamlTestExecutionContext adminExecutionContext; private static ClientYamlTestExecutionContext adminExecutionContext;
private static ClientYamlTestClient clientYamlTestClient; private static ClientYamlTestClient clientYamlTestClient;
@ -157,11 +157,11 @@ public abstract class OpenSearchClientYamlSuiteTestCase extends OpenSearchRestTe
final String[] denylist = resolvePathsProperty(REST_TESTS_DENYLIST, null); final String[] denylist = resolvePathsProperty(REST_TESTS_DENYLIST, null);
denylistPathMatchers = new ArrayList<>(); denylistPathMatchers = new ArrayList<>();
for (final String entry : denylist) { for (final String entry : denylist) {
denylistPathMatchers.add(new BlacklistedPathPatternMatcher(entry)); denylistPathMatchers.add(new DenylistedPathPatternMatcher(entry));
} }
final String[] denylistAdditions = resolvePathsProperty(REST_TESTS_DENYLIST_ADDITIONS, null); final String[] denylistAdditions = resolvePathsProperty(REST_TESTS_DENYLIST_ADDITIONS, null);
for (final String entry : denylistAdditions) { for (final String entry : denylistAdditions) {
denylistPathMatchers.add(new BlacklistedPathPatternMatcher(entry)); denylistPathMatchers.add(new DenylistedPathPatternMatcher(entry));
} }
} }
assert restTestExecutionContext != null; assert restTestExecutionContext != null;
@ -368,12 +368,9 @@ public abstract class OpenSearchClientYamlSuiteTestCase extends OpenSearchRestTe
public void test() throws IOException { public void test() throws IOException {
// skip test if it matches one of the denylist globs // 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(); String testPath = testCandidate.getSuitePath() + "/" + testCandidate.getTestSection().getName();
assumeFalse( assumeFalse("[" + testCandidate.getTestPath() + "] skipped, reason: denylisted", denylistedPathMatcher.isSuffixMatch(testPath));
"[" + testCandidate.getTestPath() + "] skipped, reason: blacklisted",
denylistedPathMatcher.isSuffixMatch(testPath)
);
} }
// skip test if the whole suite (yaml file) is disabled // skip test if the whole suite (yaml file) is disabled

View File

@ -33,7 +33,7 @@ package org.opensearch.test.rest.yaml;
import org.opensearch.test.OpenSearchTestCase; import org.opensearch.test.OpenSearchTestCase;
public class BlacklistedPathPatternMatcherTests extends OpenSearchTestCase { public class DenylistedPathPatternMatcherTests extends OpenSearchTestCase {
public void testMatchesExact() { public void testMatchesExact() {
// suffix match // suffix match
@ -71,12 +71,12 @@ public class BlacklistedPathPatternMatcherTests extends OpenSearchTestCase {
} }
private void assertMatch(String pattern, String path) { 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)); assertTrue("Pattern [" + pattern + "] should have matched path [" + path + "]", matcher.isSuffixMatch(path));
} }
private void assertNoMatch(String pattern, String 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)); assertFalse("Pattern [" + pattern + "] should not have matched path [" + path + "]", matcher.isSuffixMatch(path));
} }
} }