You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by si...@apache.org on 2019/04/09 14:44:40 UTC

[sling-whiteboard] branch master updated: [api-region] scanning package via tokenizer rather than regex

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

simonetripodi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new ec4e600  [api-region] scanning package via tokenizer rather than regex
ec4e600 is described below

commit ec4e600e951fa273e991c54ceb5ed8a90d18724e
Author: stripodi <st...@192.168.1.111>
AuthorDate: Tue Apr 9 16:44:33 2019 +0200

    [api-region] scanning package via tokenizer rather than regex
---
 .../main/java/org/apache/sling/feature/apiregions/ApiRegion.java   | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/ApiRegion.java b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/ApiRegion.java
index c44532f..78f34d3 100644
--- a/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/ApiRegion.java
+++ b/feature-api-regions/src/main/java/org/apache/sling/feature/apiregions/ApiRegion.java
@@ -24,6 +24,7 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
+import java.util.StringTokenizer;
 import java.util.regex.Pattern;
 
 public final class ApiRegion implements Iterable<String> {
@@ -31,6 +32,8 @@ public final class ApiRegion implements Iterable<String> {
     private static final Pattern PACKAGE_NAME_VALIDATION =
             Pattern.compile("^[a-z]+(\\.[a-zA-Z_][a-zA-Z0-9_]*)*$");
 
+    private static final String PACKAGE_DELIM = ".";
+
     private static final Set<String> KEYWORDS = new HashSet<>();
 
     static {
@@ -119,7 +122,9 @@ public final class ApiRegion implements Iterable<String> {
         }
 
         // ignore packages with reserved keywords, i.e. org.apache.commons.lang.enum
-        for (String apiPart : api.split("\\.")) {
+        StringTokenizer tokenizer = new StringTokenizer(api, PACKAGE_DELIM);
+        while (tokenizer.hasMoreTokens()) {
+            String apiPart = tokenizer.nextToken();
             if (KEYWORDS.contains(apiPart)) {
                 return false;
             }