Skip to content

Commit 492efa7

Browse files
authored
Remove suppresions for "unchecked" for hamcrest varargs methods (#41528)
In hamcrest 2.1 warnings for unchecked varargs were fixed by hamcrest using @SafeVarargs for those matchers where this warning occurred. This PR is aimed to remove these annotations when Matchers.contains ,Matchers.containsInAnyOrder or Matchers.hasItems was used
1 parent 905902c commit 492efa7

File tree

8 files changed

+0
-24
lines changed

8 files changed

+0
-24
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/BulkProcessorIT.java

-2
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception
291291
assertMultiGetResponse(highLevelClient().mget(multiGetRequest, RequestOptions.DEFAULT), testDocs);
292292
}
293293

294-
@SuppressWarnings("unchecked")
295294
public void testGlobalParametersAndSingleRequest() throws Exception {
296295
createIndexWithMultipleShards("test");
297296

@@ -326,7 +325,6 @@ public void testGlobalParametersAndSingleRequest() throws Exception {
326325
assertThat(blogs, everyItem(hasProperty(fieldFromSource("fieldNameXYZ"), equalTo("valueXYZ"))));
327326
}
328327

329-
@SuppressWarnings("unchecked")
330328
public void testGlobalParametersAndBulkProcessor() throws Exception {
331329
createIndexWithMultipleShards("test");
332330

client/rest-high-level/src/test/java/org/elasticsearch/client/BulkRequestWithGlobalParametersIT.java

-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
public class BulkRequestWithGlobalParametersIT extends ESRestHighLevelClientTestCase {
4646

47-
@SuppressWarnings("unchecked")
4847
public void testGlobalPipelineOnBulkRequest() throws IOException {
4948
createFieldAddingPipleine("xyz", "fieldNameXYZ", "valueXYZ");
5049

@@ -83,7 +82,6 @@ public void testPipelineOnRequestOverridesGlobalPipeline() throws IOException {
8382
assertThat(hits, everyItem(hasProperty(fieldFromSource("fieldXYZ"), nullValue())));
8483
}
8584

86-
@SuppressWarnings("unchecked")
8785
public void testMixPipelineOnRequestAndGlobal() throws IOException {
8886
createFieldAddingPipleine("globalId", "fieldXYZ", "valueXYZ");
8987
createFieldAddingPipleine("perIndexId", "someNewField", "someValue");
@@ -153,7 +151,6 @@ public void testGlobalType() throws IOException {
153151
assertThat(hits, everyItem(hasType("global_type")));
154152
}
155153

156-
@SuppressWarnings("unchecked")
157154
public void testTypeGlobalAndPerRequest() throws IOException {
158155
BulkRequest request = new BulkRequest(null, "global_type");
159156
request.add(new IndexRequest("index1", "local_type", "1")
@@ -171,7 +168,6 @@ public void testTypeGlobalAndPerRequest() throws IOException {
171168
.and(hasType("global_type"))));
172169
}
173170

174-
@SuppressWarnings("unchecked")
175171
public void testGlobalRouting() throws IOException {
176172
createIndexWithMultipleShards("index");
177173
BulkRequest request = new BulkRequest(null);
@@ -189,7 +185,6 @@ public void testGlobalRouting() throws IOException {
189185
assertThat(hits, containsInAnyOrder(hasId("1"), hasId("2")));
190186
}
191187

192-
@SuppressWarnings("unchecked")
193188
public void testMixLocalAndGlobalRouting() throws IOException {
194189
BulkRequest request = new BulkRequest(null);
195190
request.routing("globalRouting");

qa/logging-config/src/test/java/org/elasticsearch/common/logging/JsonLoggerTests.java

-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public void tearDown() throws Exception {
6767
super.tearDown();
6868
}
6969

70-
@SuppressWarnings("unchecked")
7170
public void testJsonLayout() throws IOException {
7271
final Logger testLogger = LogManager.getLogger("test");
7372

@@ -90,7 +89,6 @@ public void testJsonLayout() throws IOException {
9089
}
9190
}
9291

93-
@SuppressWarnings("unchecked")
9492
public void testPrefixLoggerInJson() throws IOException {
9593
Logger shardIdLogger = Loggers.getLogger("shardIdLogger", ShardId.fromString("[indexName][123]"));
9694
shardIdLogger.info("This is an info message with a shardId");

x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java

-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ private String loadWatch(String watch) throws IOException {
277277
return StreamsUtils.copyToStringFromClasspath("/org/elasticsearch/xpack/restart/" + watch);
278278
}
279279

280-
@SuppressWarnings("unchecked")
281280
private void assertOldTemplatesAreDeleted() throws IOException {
282281
Map<String, Object> templates = entityAsMap(client().performRequest(new Request("GET", "/_template")));
283282
assertThat(templates.keySet(), not(hasItems(is("watches"), startsWith("watch-history"), is("triggered_watches"))));

x-pack/qa/openldap-tests/src/test/java/org/elasticsearch/xpack/security/authc/ldap/SearchGroupsResolverTests.java

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import static org.hamcrest.Matchers.is;
2424
import static org.hamcrest.Matchers.notNullValue;
2525

26-
@SuppressWarnings("unchecked")
2726
public class SearchGroupsResolverTests extends GroupsResolverTestCase {
2827

2928
private static final String BRUCE_BANNER_DN = "uid=hulk,ou=people,dc=oldap,dc=test,dc=elasticsearch,dc=com";

x-pack/qa/third-party/active-directory/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectoryGroupsResolverTests.java

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public void setReferralFollowing() {
3535
}
3636

3737
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/35738")
38-
@SuppressWarnings("unchecked")
3938
public void testResolveSubTree() throws Exception {
4039
Settings settings = Settings.builder()
4140
.put("xpack.security.authc.realms.active_directory.ad.group_search.scope", LdapSearchScope.SUB_TREE)

x-pack/qa/third-party/active-directory/src/test/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactoryTests.java

-9
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public boolean enableWarningsCheck() {
6666
return false;
6767
}
6868

69-
@SuppressWarnings("unchecked")
7069
public void testAdAuth() throws Exception {
7170
RealmConfig config = configureRealm("ad-test", buildAdSettings(AD_LDAP_URL, AD_DOMAIN, false));
7271
try (ActiveDirectorySessionFactory sessionFactory = getActiveDirectorySessionFactory(config, sslService, threadPool)) {
@@ -101,7 +100,6 @@ private RealmConfig configureRealm(String name, Settings settings) {
101100
return new RealmConfig(identifier, mergedSettings, env, new ThreadContext(globalSettings));
102101
}
103102

104-
@SuppressWarnings("unchecked")
105103
public void testNetbiosAuth() throws Exception {
106104
final String adUrl = randomFrom(AD_LDAP_URL, AD_LDAP_GC_URL);
107105
RealmConfig config = configureRealm("ad-test", buildAdSettings(adUrl, AD_DOMAIN, false));
@@ -139,7 +137,6 @@ public void testAdAuthAvengers() throws Exception {
139137
}
140138
}
141139

142-
@SuppressWarnings("unchecked")
143140
public void testAuthenticate() throws Exception {
144141
Settings settings = buildAdSettings(REALM_ID, AD_LDAP_URL, AD_DOMAIN, "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com",
145142
LdapSearchScope.ONE_LEVEL, false);
@@ -163,7 +160,6 @@ public void testAuthenticate() throws Exception {
163160
}
164161
}
165162

166-
@SuppressWarnings("unchecked")
167163
public void testAuthenticateBaseUserSearch() throws Exception {
168164
Settings settings = buildAdSettings(REALM_ID, AD_LDAP_URL, AD_DOMAIN,
169165
"CN=Bruce Banner, CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com", LdapSearchScope.BASE, false);
@@ -208,7 +204,6 @@ public void testAuthenticateBaseGroupSearch() throws Exception {
208204
}
209205
}
210206

211-
@SuppressWarnings("unchecked")
212207
public void testAuthenticateWithUserPrincipalName() throws Exception {
213208
Settings settings = buildAdSettings(REALM_ID, AD_LDAP_URL, AD_DOMAIN, "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com",
214209
LdapSearchScope.ONE_LEVEL, false);
@@ -229,7 +224,6 @@ public void testAuthenticateWithUserPrincipalName() throws Exception {
229224
}
230225
}
231226

232-
@SuppressWarnings("unchecked")
233227
public void testAuthenticateWithSAMAccountName() throws Exception {
234228
Settings settings = buildAdSettings(REALM_ID, AD_LDAP_URL, AD_DOMAIN, "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com",
235229
LdapSearchScope.ONE_LEVEL, false);
@@ -251,7 +245,6 @@ public void testAuthenticateWithSAMAccountName() throws Exception {
251245
}
252246
}
253247

254-
@SuppressWarnings("unchecked")
255248
public void testCustomUserFilter() throws Exception {
256249
Settings settings = Settings.builder()
257250
.put(buildAdSettings(REALM_ID, AD_LDAP_URL, AD_DOMAIN, "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com",
@@ -275,7 +268,6 @@ public void testCustomUserFilter() throws Exception {
275268
}
276269

277270

278-
@SuppressWarnings("unchecked")
279271
public void testStandardLdapConnection() throws Exception {
280272
String groupSearchBase = "DC=ad,DC=test,DC=elasticsearch,DC=com";
281273
String userTemplate = "CN={0},CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com";
@@ -341,7 +333,6 @@ public void testHandlingLdapReferralErrors() throws Exception {
341333
}
342334
}
343335

344-
@SuppressWarnings("unchecked")
345336
public void testStandardLdapWithAttributeGroups() throws Exception {
346337
String userTemplate = "CN={0},CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com";
347338
Settings settings = LdapTestCase.buildLdapSettings(new String[]{AD_LDAP_URL}, userTemplate, false);

x-pack/qa/third-party/active-directory/src/test/java/org/elasticsearch/xpack/security/authc/ldap/UserAttributeGroupsResolverTests.java

-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public class UserAttributeGroupsResolverTests extends GroupsResolverTestCase {
2929
public static final String BRUCE_BANNER_DN = "cn=Bruce Banner,CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com";
3030
private static final RealmConfig.RealmIdentifier REALM_ID = new RealmConfig.RealmIdentifier("ldap", "realm1");
3131

32-
@SuppressWarnings("unchecked")
3332
public void testResolve() throws Exception {
3433
//falling back on the 'memberOf' attribute
3534
UserAttributeGroupsResolver resolver = new UserAttributeGroupsResolver(config(REALM_ID, Settings.EMPTY));
@@ -42,7 +41,6 @@ public void testResolve() throws Exception {
4241
containsString("Philanthropists")));
4342
}
4443

45-
@SuppressWarnings("unchecked")
4644
public void testResolveFromPreloadedAttributes() throws Exception {
4745
SearchRequest preSearch = new SearchRequest(BRUCE_BANNER_DN, SearchScope.BASE, LdapUtils.OBJECT_CLASS_PRESENCE_FILTER, "memberOf");
4846
final Collection<Attribute> attributes = ldapConnection.searchForEntry(preSearch).getAttributes();
@@ -57,7 +55,6 @@ public void testResolveFromPreloadedAttributes() throws Exception {
5755
containsString("Philanthropists")));
5856
}
5957

60-
@SuppressWarnings("unchecked")
6158
public void testResolveCustomGroupAttribute() throws Exception {
6259
Settings settings = Settings.builder()
6360
.put("user_group_attribute", "seeAlso")

0 commit comments

Comments
 (0)