From 51c9a3ef425c243920b0ca7f05f66b00fdc97460 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sun, 8 Apr 2018 15:56:18 +0200 Subject: [PATCH] Reducing compiler warnings --- pom.xml | 6 ++++++ .../common/ldap/role/DefaultLdapRoleMapper.java | 12 ++++++------ .../archiva/redback/keys/jpa/JpaKeyManager.java | 2 +- .../archiva/redback/keys/KeyManagerTestCase.java | 2 +- redback-rbac/redback-rbac-model/pom.xml | 4 ++-- .../archiva/redback/rbac/AbstractRBACManager.java | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index d09bb386..4c6a29c3 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,7 @@ 4.3.10.RELEASE 1.7.25 2.8.2 + 4.1 UTF-8 true @@ -410,6 +411,11 @@ 3.2 + + org.apache.commons + commons-collections4 + ${commons-collections.version} + commons-codec commons-codec diff --git a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java index a8348f92..8cfffc35 100644 --- a/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java +++ b/redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/role/DefaultLdapRoleMapper.java @@ -312,10 +312,10 @@ public class DefaultLdapRoleMapper if ( uniqueMemberAttr != null ) { - NamingEnumeration allMembersEnum = (NamingEnumeration) uniqueMemberAttr.getAll(); + NamingEnumeration allMembersEnum = uniqueMemberAttr.getAll(); while ( allMembersEnum.hasMore() ) { - String userName = allMembersEnum.next(); + String userName = allMembersEnum.next().toString(); // uid=blabla we only want bla bla userName = StringUtils.substringAfter( userName, "=" ); userName = StringUtils.substringBefore( userName, "," ); @@ -420,11 +420,11 @@ public class DefaultLdapRoleMapper if ( uniqueMemberAttr != null ) { - NamingEnumeration allMembersEnum = (NamingEnumeration) uniqueMemberAttr.getAll(); + NamingEnumeration allMembersEnum = uniqueMemberAttr.getAll(); while ( allMembersEnum.hasMore() ) { - String userName = allMembersEnum.next(); + String userName = allMembersEnum.next().toString(); //the original dn allMembers.add( userName ); // uid=blabla we only want bla bla @@ -621,7 +621,7 @@ public class DefaultLdapRoleMapper namingEnumeration = context.search( "cn=" + groupName + "," + getGroupsDn(), filter, searchControls ); - while ( namingEnumeration.hasMore() ) + if ( namingEnumeration.hasMore() ) { SearchResult searchResult = namingEnumeration.next(); Attribute attribute = searchResult.getAttributes().get( getLdapGroupMember() ); @@ -692,7 +692,7 @@ public class DefaultLdapRoleMapper namingEnumeration = context.search( "cn=" + groupName + "," + getGroupsDn(), filter, searchControls ); - while ( namingEnumeration.hasMore() ) + if ( namingEnumeration.hasMore() ) { SearchResult searchResult = namingEnumeration.next(); Attribute attribute = searchResult.getAttributes().get( getLdapGroupMember() ); diff --git a/redback-keys/redback-keys-providers/redback-keys-jpa/src/main/java/org/apache/archiva/redback/keys/jpa/JpaKeyManager.java b/redback-keys/redback-keys-providers/redback-keys-jpa/src/main/java/org/apache/archiva/redback/keys/jpa/JpaKeyManager.java index 0a934b41..6d2affdc 100644 --- a/redback-keys/redback-keys-providers/redback-keys-jpa/src/main/java/org/apache/archiva/redback/keys/jpa/JpaKeyManager.java +++ b/redback-keys/redback-keys-providers/redback-keys-jpa/src/main/java/org/apache/archiva/redback/keys/jpa/JpaKeyManager.java @@ -166,7 +166,7 @@ public class JpaKeyManager extends AbstractKeyManager { @Override public List getAllKeys() { final EntityManager em = getEm(); - Query q= em.createQuery("SELECT x from JpaAuthenticationKey x"); + TypedQuery q= em.createQuery("SELECT x from JpaAuthenticationKey x", AuthenticationKey.class); return q.getResultList(); } diff --git a/redback-keys/redback-keys-tests/src/main/java/org/apache/archiva/redback/keys/KeyManagerTestCase.java b/redback-keys/redback-keys-tests/src/main/java/org/apache/archiva/redback/keys/KeyManagerTestCase.java index b3c0f3c7..dbdf8fe9 100644 --- a/redback-keys/redback-keys-tests/src/main/java/org/apache/archiva/redback/keys/KeyManagerTestCase.java +++ b/redback-keys/redback-keys-tests/src/main/java/org/apache/archiva/redback/keys/KeyManagerTestCase.java @@ -114,7 +114,7 @@ public class KeyManagerTestCase System.out.println("foo key "+created1.getKey()); System.out.println("bar key "+created2.getKey()); - List keys = new ArrayList(getKeyManager().getAllKeys()); + List keys = new ArrayList<>(getKeyManager().getAllKeys()); Collections.sort( keys, new Comparator() { public int compare( AuthenticationKey key1, AuthenticationKey key2 ) diff --git a/redback-rbac/redback-rbac-model/pom.xml b/redback-rbac/redback-rbac-model/pom.xml index 07366c00..ed6219ae 100644 --- a/redback-rbac/redback-rbac-model/pom.xml +++ b/redback-rbac/redback-rbac-model/pom.xml @@ -37,8 +37,8 @@ commons-lang - commons-collections - commons-collections + org.apache.commons + commons-collections4 org.codehaus.plexus diff --git a/redback-rbac/redback-rbac-model/src/main/java/org/apache/archiva/redback/rbac/AbstractRBACManager.java b/redback-rbac/redback-rbac-model/src/main/java/org/apache/archiva/redback/rbac/AbstractRBACManager.java index ce495da6..537ad167 100644 --- a/redback-rbac/redback-rbac-model/src/main/java/org/apache/archiva/redback/rbac/AbstractRBACManager.java +++ b/redback-rbac/redback-rbac-model/src/main/java/org/apache/archiva/redback/rbac/AbstractRBACManager.java @@ -16,7 +16,7 @@ package org.apache.archiva.redback.rbac; * limitations under the License. */ -import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory;