Skip to content

Commit d2cd738

Browse files
Tianli Fenggithub-actions[bot]
authored andcommitted
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> (cherry picked from commit 47a22bb)
1 parent 2458c7a commit d2cd738

7 files changed

Lines changed: 25 additions & 28 deletions

File tree

server/src/main/java/org/opensearch/common/inject/BindingProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ private void putBinding(BindingImpl<?> binding) {
274274
}
275275

276276
// prevent the parent from creating a JIT binding for this key
277-
injector.state.parent().blacklist(key);
277+
injector.state.parent().denylist(key);
278278
injector.state.putBinding(key, binding);
279279
}
280280

server/src/main/java/org/opensearch/common/inject/InheritingState.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,18 @@ public List<TypeListenerBinding> getTypeListenerBindings() {
143143
}
144144

145145
@Override
146-
public void blacklist(Key<?> key) {
147-
parent.blacklist(key);
146+
public void denylist(Key<?> key) {
147+
parent.denylist(key);
148148
denylistedKeys.add(key);
149149
}
150150

151151
@Override
152-
public boolean isBlacklisted(Key<?> key) {
152+
public boolean isDenylisted(Key<?> key) {
153153
return denylistedKeys.contains(key);
154154
}
155155

156156
@Override
157-
public void clearBlacklisted() {
157+
public void clearDenylisted() {
158158
denylistedKeys = new WeakKeySet();
159159
}
160160

server/src/main/java/org/opensearch/common/inject/InjectorImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,12 @@ public T get(Errors errors, InternalContext context, Dependency<?> dependency) t
530530
* other ancestor injectors until this injector is tried.
531531
*/
532532
private <T> BindingImpl<T> createJustInTimeBindingRecursive(Key<T> key, Errors errors) throws ErrorsException {
533-
if (state.isBlacklisted(key)) {
533+
if (state.isDenylisted(key)) {
534534
throw errors.childBindingAlreadySet(key).toException();
535535
}
536536

537537
BindingImpl<T> binding = createJustInTimeBinding(key, errors);
538-
state.parent().blacklist(key);
538+
state.parent().denylist(key);
539539
jitBindings.put(key, binding);
540540
return binding;
541541
}
@@ -555,7 +555,7 @@ private <T> BindingImpl<T> createJustInTimeBindingRecursive(Key<T> key, Errors e
555555
* if the binding cannot be created.
556556
*/
557557
<T> BindingImpl<T> createJustInTimeBinding(Key<T> key, Errors errors) throws ErrorsException {
558-
if (state.isBlacklisted(key)) {
558+
if (state.isDenylisted(key)) {
559559
throw errors.childBindingAlreadySet(key).toException();
560560
}
561561

@@ -805,7 +805,7 @@ public String toString() {
805805

806806
// ES_GUICE: clear caches
807807
public void clearCache() {
808-
state.clearBlacklisted();
808+
state.clearDenylisted();
809809
constructors = new ConstructorInjectorStore(this);
810810
membersInjectorStore = new MembersInjectorStore(this, state.getTypeListenerBindings());
811811
jitBindings = new HashMap<>();

server/src/main/java/org/opensearch/common/inject/State.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ public List<TypeListenerBinding> getTypeListenerBindings() {
106106
}
107107

108108
@Override
109-
public void blacklist(Key<?> key) {}
109+
public void denylist(Key<?> key) {}
110110

111111
@Override
112-
public boolean isBlacklisted(Key<?> key) {
112+
public boolean isDenylisted(Key<?> key) {
113113
return true;
114114
}
115115

116116
@Override
117-
public void clearBlacklisted() {}
117+
public void clearDenylisted() {}
118118

119119
@Override
120120
public void makeAllBindingsToEagerSingletons(Injector injector) {}
@@ -167,13 +167,13 @@ public Object lock() {
167167
* denylist their bound keys on their parent injectors to prevent just-in-time bindings on the
168168
* parent injector that would conflict.
169169
*/
170-
void blacklist(Key<?> key);
170+
void denylist(Key<?> key);
171171

172172
/**
173173
* Returns true if {@code key} is forbidden from being bound in this injector. This indicates that
174174
* one of this injector's descendent's has bound the key.
175175
*/
176-
boolean isBlacklisted(Key<?> key);
176+
boolean isDenylisted(Key<?> key);
177177

178178
/**
179179
* Returns the shared lock for all injector data. This is a low-granularity, high-contention lock
@@ -182,7 +182,7 @@ public Object lock() {
182182
Object lock();
183183

184184
// ES_GUICE: clean denylist keys
185-
void clearBlacklisted();
185+
void clearDenylisted();
186186

187187
void makeAllBindingsToEagerSingletons(Injector injector);
188188
}

test/framework/src/main/java/org/opensearch/test/rest/yaml/BlacklistedPathPatternMatcher.java renamed to test/framework/src/main/java/org/opensearch/test/rest/yaml/DenylistedPathPatternMatcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@
4747
*
4848
* Each denylist pattern is a suffix match on the path. Empty patterns are not allowed.
4949
*/
50-
final class BlacklistedPathPatternMatcher {
50+
final class DenylistedPathPatternMatcher {
5151
private final Pattern pattern;
5252

5353
/**
5454
* Constructs a new <code>DenylistedPathPatternMatcher</code> instance from the provided suffix pattern.
5555
*
5656
* @param p The suffix pattern. Must be a non-empty string.
5757
*/
58-
BlacklistedPathPatternMatcher(String p) {
58+
DenylistedPathPatternMatcher(String p) {
5959
// guard against accidentally matching everything as an empty string lead to the pattern ".*" which matches everything
6060
if (p == null || p.trim().isEmpty()) {
6161
throw new IllegalArgumentException("Empty denylist patterns are not supported");

test/framework/src/main/java/org/opensearch/test/rest/yaml/OpenSearchClientYamlSuiteTestCase.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public abstract class OpenSearchClientYamlSuiteTestCase extends OpenSearchRestTe
116116
*/
117117
private static final String PATHS_SEPARATOR = "(?<!\\\\),";
118118

119-
private static List<BlacklistedPathPatternMatcher> denylistPathMatchers;
119+
private static List<DenylistedPathPatternMatcher> denylistPathMatchers;
120120
private static ClientYamlTestExecutionContext restTestExecutionContext;
121121
private static ClientYamlTestExecutionContext adminExecutionContext;
122122
private static ClientYamlTestClient clientYamlTestClient;
@@ -157,11 +157,11 @@ public void initAndResetContext() throws Exception {
157157
final String[] denylist = resolvePathsProperty(REST_TESTS_DENYLIST, null);
158158
denylistPathMatchers = new ArrayList<>();
159159
for (final String entry : denylist) {
160-
denylistPathMatchers.add(new BlacklistedPathPatternMatcher(entry));
160+
denylistPathMatchers.add(new DenylistedPathPatternMatcher(entry));
161161
}
162162
final String[] denylistAdditions = resolvePathsProperty(REST_TESTS_DENYLIST_ADDITIONS, null);
163163
for (final String entry : denylistAdditions) {
164-
denylistPathMatchers.add(new BlacklistedPathPatternMatcher(entry));
164+
denylistPathMatchers.add(new DenylistedPathPatternMatcher(entry));
165165
}
166166
}
167167
assert restTestExecutionContext != null;
@@ -368,12 +368,9 @@ protected RequestOptions getCatNodesVersionMasterRequestOptions() {
368368

369369
public void test() throws IOException {
370370
// skip test if it matches one of the denylist globs
371-
for (BlacklistedPathPatternMatcher denylistedPathMatcher : denylistPathMatchers) {
371+
for (DenylistedPathPatternMatcher denylistedPathMatcher : denylistPathMatchers) {
372372
String testPath = testCandidate.getSuitePath() + "/" + testCandidate.getTestSection().getName();
373-
assumeFalse(
374-
"[" + testCandidate.getTestPath() + "] skipped, reason: blacklisted",
375-
denylistedPathMatcher.isSuffixMatch(testPath)
376-
);
373+
assumeFalse("[" + testCandidate.getTestPath() + "] skipped, reason: denylisted", denylistedPathMatcher.isSuffixMatch(testPath));
377374
}
378375

379376
// skip test if the whole suite (yaml file) is disabled

test/framework/src/test/java/org/opensearch/test/rest/yaml/BlacklistedPathPatternMatcherTests.java renamed to test/framework/src/test/java/org/opensearch/test/rest/yaml/DenylistedPathPatternMatcherTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
import org.opensearch.test.OpenSearchTestCase;
3535

36-
public class BlacklistedPathPatternMatcherTests extends OpenSearchTestCase {
36+
public class DenylistedPathPatternMatcherTests extends OpenSearchTestCase {
3737

3838
public void testMatchesExact() {
3939
// suffix match
@@ -71,12 +71,12 @@ public void testMatchesMixedPatterns() {
7171
}
7272

7373
private void assertMatch(String pattern, String path) {
74-
BlacklistedPathPatternMatcher matcher = new BlacklistedPathPatternMatcher(pattern);
74+
DenylistedPathPatternMatcher matcher = new DenylistedPathPatternMatcher(pattern);
7575
assertTrue("Pattern [" + pattern + "] should have matched path [" + path + "]", matcher.isSuffixMatch(path));
7676
}
7777

7878
private void assertNoMatch(String pattern, String path) {
79-
BlacklistedPathPatternMatcher matcher = new BlacklistedPathPatternMatcher(pattern);
79+
DenylistedPathPatternMatcher matcher = new DenylistedPathPatternMatcher(pattern);
8080
assertFalse("Pattern [" + pattern + "] should not have matched path [" + path + "]", matcher.isSuffixMatch(path));
8181
}
8282
}

0 commit comments

Comments
 (0)