zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sy...@apache.org
Subject [zookeeper] branch branch-3.6 updated: ZOOKEEPER-3952: Remove commons-lang from ZooKeeper
Date Tue, 06 Oct 2020 11:05:46 GMT
This is an automated email from the ASF dual-hosted git repository.

symat pushed a commit to branch branch-3.6
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/branch-3.6 by this push:
     new 82f43bf  ZOOKEEPER-3952: Remove commons-lang from ZooKeeper
82f43bf is described below

commit 82f43bf85b1341ab0b5f3ffeb830c7fc7aefb64f
Author: Tamas Penzes <tamaas@cloudera.com>
AuthorDate: Tue Oct 6 10:39:37 2020 +0000

    ZOOKEEPER-3952: Remove commons-lang from ZooKeeper
    
    Removed commons-lang from main project, replaced functionality with standard Java code.
    
    Author: Tamas Penzes <tamaas@cloudera.com>
    
    Reviewers: Christopher Tubbs <ctubbsii@apache.org>, Enrico Olivelli <eolivelli@apache.org>,
Mate Szalay-Beko <symat@apache.org>, tison <wander4096@gmail.com>
    
    Closes #1478 from tamaashu/ZOOKEEPER-3952
    
    (cherry picked from commit d3282c62ddb30a8ce265dcebca0e106c51f07ca3)
    Signed-off-by: Mate Szalay-Beko <symat@apache.org>
---
 pom.xml                                            | 48 +++++++++++++++++++---
 .../zookeeper-contrib-zooinspector/ivy.xml         |  8 +---
 .../zookeeper-contrib-zooinspector/pom.xml         |  6 ---
 zookeeper-server/pom.xml                           |  4 --
 .../java/org/apache/zookeeper/common/PathTrie.java | 23 +++++++----
 .../zookeeper/server/FinalRequestProcessor.java    |  3 +-
 6 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/pom.xml b/pom.xml
index aefb575..7c42d2a 100755
--- a/pom.xml
+++ b/pom.xml
@@ -364,10 +364,10 @@
     <kerby.version>2.0.0</kerby.version>
     <bouncycastle.version>1.60</bouncycastle.version>
     <commons-collections.version>3.2.2</commons-collections.version>
-    <commons-lang.version>2.6</commons-lang.version>
     <dropwizard.version>3.2.5</dropwizard.version>
     <spotbugsannotations.version>4.0.2</spotbugsannotations.version>
     <checkstyle.version>8.17</checkstyle.version>
+    <enforcer.version>3.0.0-M3</enforcer.version>
 
     <!-- parameter to pass to C client build -->
     <c-client-openssl>yes</c-client-openssl>
@@ -387,11 +387,6 @@
         <version>${commons-collections.version}</version>
       </dependency>
       <dependency>
-        <groupId>commons-lang</groupId>
-        <artifactId>commons-lang</artifactId>
-        <version>${commons-lang.version}</version>
-      </dependency>
-      <dependency>
         <groupId>org.apache.yetus</groupId>
         <artifactId>audience-annotations</artifactId>
         <version>${audience-annotations.version}</version>
@@ -938,6 +933,47 @@
             </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <version>${enforcer.version}</version>
+        <executions>
+          <execution>
+            <id>banned-commons-lang</id>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <bannedDependencies>
+                  <excludes>
+                    <exclude>commons-lang:commons-lang</exclude>
+                  </excludes>
+                  <searchTransitive>false</searchTransitive>
+                  <message>We don't use commons-lang any more, so do not depend on
it directly.</message>
+                </bannedDependencies>
+              </rules>
+            </configuration>
+          </execution>
+          <execution>
+            <id>banned-commons-lang3</id>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <bannedDependencies>
+                  <excludes>
+                    <exclude>org.apache.commons:commons-lang3</exclude>
+                  </excludes>
+                  <searchTransitive>false</searchTransitive>
+                  <message>We don't use commons-lang3, so do not depend on it directly.</message>
+                </bannedDependencies>
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
     <resources>
       <resource>
diff --git a/zookeeper-contrib/zookeeper-contrib-zooinspector/ivy.xml b/zookeeper-contrib/zookeeper-contrib-zooinspector/ivy.xml
index d841d18..96acdde 100644
--- a/zookeeper-contrib/zookeeper-contrib-zooinspector/ivy.xml
+++ b/zookeeper-contrib/zookeeper-contrib-zooinspector/ivy.xml
@@ -39,12 +39,8 @@
             
     <dependency org="log4j" name="log4j" rev="1.2.17" transitive="false"/>
     <dependency org="junit" name="junit" rev="4.12" conf="test->default"/>
-    <dependency org="org.apache.rat" name="apache-rat-tasks" 
-                rev="0.6" conf="releaseaudit->default"/>
-    <dependency org="commons-lang" name="commons-lang" 
-                rev="2.4" conf="releaseaudit->default"/>
-    <dependency org="commons-collections" name="commons-collections" 
-                rev="3.2.2" conf="releaseaudit->default"/>
+    <dependency org="org.apache.rat" name="apache-rat-tasks" rev="0.6" conf="releaseaudit->default"/>
+    <dependency org="commons-collections" name="commons-collections" rev="3.2.2" conf="releaseaudit->default"/>
   </dependencies>
 
 </ivy-module>
diff --git a/zookeeper-contrib/zookeeper-contrib-zooinspector/pom.xml b/zookeeper-contrib/zookeeper-contrib-zooinspector/pom.xml
index df040d2..37429d8 100755
--- a/zookeeper-contrib/zookeeper-contrib-zooinspector/pom.xml
+++ b/zookeeper-contrib/zookeeper-contrib-zooinspector/pom.xml
@@ -35,7 +35,6 @@
 
   <properties>
     <rat.version>0.6</rat.version>
-    <commons-lang.version>2.4</commons-lang.version>
     <guava.version>18.0</guava.version>
   </properties>
 
@@ -85,11 +84,6 @@
       <version>${rat.version}</version>
     </dependency>
     <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-      <version>${commons-lang.version}</version>
-    </dependency>
-    <dependency>
       <groupId>commons-collections</groupId>
       <artifactId>commons-collections</artifactId>
     </dependency>
diff --git a/zookeeper-server/pom.xml b/zookeeper-server/pom.xml
index b27d335..5d61ba4 100755
--- a/zookeeper-server/pom.xml
+++ b/zookeeper-server/pom.xml
@@ -50,10 +50,6 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.apache.zookeeper</groupId>
       <artifactId>zookeeper-jute</artifactId>
       <version>${project.version}</version>
diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/common/PathTrie.java b/zookeeper-server/src/main/java/org/apache/zookeeper/common/PathTrie.java
index 95258b2..86acdd9 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/common/PathTrie.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/common/PathTrie.java
@@ -27,7 +27,7 @@
  import java.util.concurrent.locks.Lock;
  import java.util.concurrent.locks.ReadWriteLock;
  import java.util.concurrent.locks.ReentrantReadWriteLock;
- import org.apache.commons.lang.StringUtils;
+ import java.util.stream.Stream;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
 
@@ -203,10 +203,10 @@
      public void addPath(final String path) {
          Objects.requireNonNull(path, "Path cannot be null");
 
-         final String[] pathComponents = StringUtils.split(path, '/');
-         if (pathComponents.length == 0) {
+         if (path.length() == 0) {
              throw new IllegalArgumentException("Invalid path: " + path);
          }
+         final String[] pathComponents = split(path);
 
          writeLock.lock();
          try {
@@ -233,10 +233,11 @@
      public void deletePath(final String path) {
          Objects.requireNonNull(path, "Path cannot be null");
 
-         final String[] pathComponents = StringUtils.split(path, '/');
-         if (pathComponents.length == 0) {
+         if (path.length() == 0) {
              throw new IllegalArgumentException("Invalid path: " + path);
          }
+         final String[] pathComponents = split(path);
+
 
          writeLock.lock();
          try {
@@ -267,10 +268,10 @@
      public boolean existsNode(final String path) {
          Objects.requireNonNull(path, "Path cannot be null");
 
-         final String[] pathComponents = StringUtils.split(path, '/');
-         if (pathComponents.length == 0) {
+         if (path.length() == 0) {
              throw new IllegalArgumentException("Invalid path: " + path);
          }
+         final String[] pathComponents = split(path);
 
          readLock.lock();
          try {
@@ -299,7 +300,7 @@
      public String findMaxPrefix(final String path) {
          Objects.requireNonNull(path, "Path cannot be null");
 
-         final String[] pathComponents = StringUtils.split(path, '/');
+         final String[] pathComponents = split(path);
 
          readLock.lock();
          try {
@@ -344,4 +345,10 @@
          }
      }
 
+     private static String[] split(final String path){
+         return Stream.of(path.split("/"))
+                 .filter(t -> !t.trim().isEmpty())
+                 .toArray(String[]::new);
+     }
+
  }
diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/FinalRequestProcessor.java
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/FinalRequestProcessor.java
index 9ffde55..b87deab 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/FinalRequestProcessor.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/FinalRequestProcessor.java
@@ -25,7 +25,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
 import java.util.Set;
-import org.apache.commons.lang.StringUtils;
 import org.apache.jute.Record;
 import org.apache.zookeeper.ClientCnxn;
 import org.apache.zookeeper.KeeperException;
@@ -541,7 +540,7 @@ public class FinalRequestProcessor implements RequestProcessor {
                 String prefixPath = getEphemerals.getPrefixPath();
                 Set<String> allEphems = zks.getZKDatabase().getDataTree().getEphemerals(request.sessionId);
                 List<String> ephemerals = new ArrayList<>();
-                if (StringUtils.isBlank(prefixPath) || "/".equals(prefixPath.trim())) {
+                if (prefixPath == null || prefixPath.trim().isEmpty() || "/".equals(prefixPath.trim()))
{
                     ephemerals.addAll(allEphems);
                 } else {
                     for (String p : allEphems) {


Mime
View raw message