This is an automated email from the ASF dual-hosted git repository.

stoty pushed a commit to branch 5.1
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/5.1 by this push:
     new 3aa0fed3b7 PHOENIX-7417 Remove commons-collections dependency (#1994)
3aa0fed3b7 is described below

commit 3aa0fed3b7896b78220c283de5cb82c4fbdbdee1
Author: Nihal Jain <[email protected]>
AuthorDate: Fri Nov 8 20:10:08 2024 +0530

    PHOENIX-7417 Remove commons-collections dependency (#1994)
---
 phoenix-core/pom.xml                                      |  4 ----
 .../phoenix/end2end/TableSnapshotReadsMapReduceIT.java    |  3 +--
 .../java/org/apache/phoenix/util/InstanceResolver.java    |  8 ++++----
 .../main/java/org/apache/phoenix/util/QueryBuilder.java   |  8 ++++----
 .../src/build/trace-server-runnable.xml                   |  1 -
 pom.xml                                                   | 15 +++++++++------
 6 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/phoenix-core/pom.xml b/phoenix-core/pom.xml
index 3f6193793a..4068992974 100644
--- a/phoenix-core/pom.xml
+++ b/phoenix-core/pom.xml
@@ -483,10 +483,6 @@
       <groupId>commons-codec</groupId>
       <artifactId>commons-codec</artifactId>
     </dependency>
-    <dependency>
-      <groupId>commons-collections</groupId>
-      <artifactId>commons-collections</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-csv</artifactId>
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableSnapshotReadsMapReduceIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableSnapshotReadsMapReduceIT.java
index 6f4f43a8ba..d21de1b369 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableSnapshotReadsMapReduceIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableSnapshotReadsMapReduceIT.java
@@ -41,7 +41,6 @@ import java.util.Properties;
 import java.util.Random;
 import java.util.UUID;
 
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
@@ -454,7 +453,7 @@ public class TableSnapshotReadsMapReduceIT extends BaseTest 
{
          Admin admin = 
conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
       List<SnapshotDescription> snapshotDescriptions = admin.listSnapshots();
       boolean isSnapshotPresent = false;
-      if (CollectionUtils.isNotEmpty(snapshotDescriptions)) {
+      if (snapshotDescriptions != null && !snapshotDescriptions.isEmpty()) {
         for (SnapshotDescription snapshotDescription : snapshotDescriptions) {
           if (snapshotName.equals(snapshotDescription.getName())) {
             isSnapshotPresent = true;
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/util/InstanceResolver.java 
b/phoenix-core/src/main/java/org/apache/phoenix/util/InstanceResolver.java
index 698c33072b..b3901074d2 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/InstanceResolver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/InstanceResolver.java
@@ -17,9 +17,8 @@
  */
 package org.apache.phoenix.util;
 
-import org.apache.commons.collections.IteratorUtils;
-
 import 
org.apache.phoenix.thirdparty.com.google.common.annotations.VisibleForTesting;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
 
 import java.util.Iterator;
 import java.util.List;
@@ -71,14 +70,15 @@ public class InstanceResolver {
     public static <T> List get(Class<T> clazz, List<T> defaultInstances) {
         Iterator<T> iterator = ServiceLoader.load(clazz).iterator();
         if (defaultInstances != null) {
-            defaultInstances.addAll(IteratorUtils.toList(iterator));
+            defaultInstances.addAll(Lists.newArrayList(iterator));
         } else {
-            defaultInstances = IteratorUtils.toList(iterator);
+            defaultInstances = Lists.newArrayList(iterator);
         }
 
         return defaultInstances;
     }
 
+
     private synchronized static <T> T resolveSingleton(Class<T> clazz, T 
defaultInstance) {
         ServiceLoader<T> loader = ServiceLoader.load(clazz);
         // returns the first registered instance found
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryBuilder.java 
b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryBuilder.java
index 92ad7ab385..200fe984ea 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryBuilder.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryBuilder.java
@@ -17,10 +17,9 @@
  */
 package org.apache.phoenix.util;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
 import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.phoenix.parse.HintNode;
 
 import java.util.Collections;
@@ -56,7 +55,7 @@ public class QueryBuilder {
      */
     public List<String> getRequiredColumns() {
         List<String> allColumns = Lists.newArrayList(selectColumns);
-        if (!CollectionUtils.isEmpty(selectExpressionColumns)) {
+        if (selectExpressionColumns != null && 
!selectExpressionColumns.isEmpty()) {
             allColumns.addAll(selectExpressionColumns);
         }
         return allColumns;
@@ -148,7 +147,8 @@ public class QueryBuilder {
 
     public String build() {
         Preconditions.checkNotNull(fullTableName, "Table name cannot be null");
-        if (CollectionUtils.isEmpty(selectColumns) && 
StringUtils.isBlank(selectExpression)) {
+        if ((selectColumns == null || selectColumns.isEmpty())
+            && StringUtils.isBlank(selectExpression)) {
             throw new IllegalArgumentException("At least one column or select 
expression must be provided");
         }
         StringBuilder query = new StringBuilder();
diff --git a/phoenix-tracing-webapp/src/build/trace-server-runnable.xml 
b/phoenix-tracing-webapp/src/build/trace-server-runnable.xml
index 92d2a17980..c52b637f62 100755
--- a/phoenix-tracing-webapp/src/build/trace-server-runnable.xml
+++ b/phoenix-tracing-webapp/src/build/trace-server-runnable.xml
@@ -54,7 +54,6 @@
         <include>com.fasterxml.woodstox:woodstox-core</include>
         <include>org.codehaus.woodstox:stax2-api</include>
         <include>com.google.guava:guava</include>
-        <include>commons-collections:commons-collections</include>
         <include>commons-cli:commons-cli</include>
       </includes>
     </dependencySet>
diff --git a/pom.xml b/pom.xml
index fcf6b5f1e0..2139f9205d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,7 +128,6 @@
     <snappy.version>0.5</snappy.version>
     <commons-codec.version>1.16.0</commons-codec.version>
     <htrace.version>3.1.0-incubating</htrace.version>
-    <collections.version>3.2.2</collections.version>
     <jodatime.version>2.10.5</jodatime.version>
     <joni.version>2.1.31</joni.version>
     <tephra.version>0.16.1</tephra.version>
@@ -561,6 +560,15 @@
                       <bannedImport>org.apache.commons.lang.**</bannedImport>
                     </bannedImports>
                   </RestrictImports>
+                  <RestrictImports>
+                    <includeTestCode>true</includeTestCode>
+                    <reason>Commons collection is restricted</reason>
+                    <bannedImports>
+                      
<bannedImport>org.apache.commons.collections.**</bannedImport>
+                      <!-- If you really need to use commons-collections 4, 
add as dependency and remove this ban -->
+                      
<bannedImport>org.apache.commons.collections4.**</bannedImport>
+                    </bannedImports>
+                  </RestrictImports>
                   <RestrictImports>
                     <includeTestCode>true</includeTestCode>
                     <reason>Use edu.umd.cs.findbugs.annotations</reason>
@@ -1489,11 +1497,6 @@
         <artifactId>commons-codec</artifactId>
         <version>${commons-codec.version}</version>
       </dependency>
-      <dependency>
-        <groupId>commons-collections</groupId>
-        <artifactId>commons-collections</artifactId>
-        <version>${collections.version}</version>
-      </dependency>
       <!-- Update transitive dependency to a one without CVEs -->
       <dependency>
           <groupId>com.fasterxml.woodstox</groupId>

Reply via email to