You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2020/06/03 00:14:52 UTC

[jclouds] branch master updated: JCLOUDS-1491 Jclouds uses a deprecated version of Guava to support Azure storage

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

gaul pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jclouds.git


The following commit(s) were added to refs/heads/master by this push:
     new 20b1394  JCLOUDS-1491 Jclouds uses a deprecated version of Guava to support Azure storage
20b1394 is described below

commit 20b1394f36dd9e522f2173b344f85a04988ae720
Author: Jean-Noël Rouvignac <je...@forgerock.com>
AuthorDate: Tue Jun 2 15:29:02 2020 +0200

    JCLOUDS-1491 Jclouds uses a deprecated version of Guava to support Azure storage
    
    DnsNameValidator.java uses a deprecated guava APIs in code that is used
     to support Azure cloud storage. When forcing the use of more recent guava
     versions, the code fails with NoSuchFieldError.
    
    However, CharMatcher.JAVA_LETTER_OR_DIGIT has been removed in guava 26.0,
     and CharMatcher.javaLetterOrDigit() should be used instead since guava
     19.0. Note that CharMatcher.javaLetterOrDigit() was immediately
     deprecated in Guava 26.0, and java.lang.Character.isLetterOrDigit(int)
     should be used instead.
    
    This commit replaces the use of this deprecated API by
     java.lang.Character.isLetterOrDigit(int).
     It is no worse than the previous code.
    
    (If I understand correctly, updating the guava version is a challenge due to
    dependencies on Apache Karaf anyway)
---
 .../java/org/jclouds/predicates/validators/DnsNameValidator.java     | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/jclouds/predicates/validators/DnsNameValidator.java b/core/src/main/java/org/jclouds/predicates/validators/DnsNameValidator.java
index 1102cb8..046cc06 100644
--- a/core/src/main/java/org/jclouds/predicates/validators/DnsNameValidator.java
+++ b/core/src/main/java/org/jclouds/predicates/validators/DnsNameValidator.java
@@ -46,11 +46,10 @@ public class DnsNameValidator extends Validator<String> {
    }
 
    public void validate(String name) {
-
-      if (name == null || name.length() < min || name.length() > max)
+      if (name == null || name.isEmpty() || name.length() < min || name.length() > max)
          throw exception(name, "Can't be null or empty. Length must be " + min + " to " + max
                   + " symbols.");
-      if (CharMatcher.JAVA_LETTER_OR_DIGIT.indexIn(name) != 0)
+      if (!Character.isLetterOrDigit(name.charAt(0)))
          throw exception(name, "Should start with letter/number");
       if (!name.toLowerCase().equals(name))
          throw exception(name, "Should be only lowercase");