sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [sling-org-apache-sling-scripting-sightly] branch master updated: SLING-7523 - Java Use object with trailing whitespace in the package declaration freezes the SightlyJavaCompilerService
Date Tue, 06 Mar 2018 15:20:13 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new ad3c9b1  SLING-7523 - Java Use object with trailing whitespace in the package declaration
freezes the SightlyJavaCompilerService
ad3c9b1 is described below

commit ad3c9b139960c65141301b52ea1ddb239f8ff061
Author: Radu Cotescu <radu@apache.org>
AuthorDate: Tue Mar 6 16:19:05 2018 +0100

    SLING-7523 - Java Use object with trailing whitespace in the package declaration freezes
the SightlyJavaCompilerService
    
    * made Patterns final
    * simplified catastrophic backtracking testing for previous java package delcaration pattern
---
 .../scripting/sightly/impl/utils/Patterns.java     |  4 +++-
 .../scripting/sightly/impl/utils/PatternsTest.java | 25 +++-------------------
 2 files changed, 6 insertions(+), 23 deletions(-)

diff --git a/src/main/java/org/apache/sling/scripting/sightly/impl/utils/Patterns.java b/src/main/java/org/apache/sling/scripting/sightly/impl/utils/Patterns.java
index c034d91..cdc889e 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/impl/utils/Patterns.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/impl/utils/Patterns.java
@@ -20,10 +20,12 @@ package org.apache.sling.scripting.sightly.impl.utils;
 
 import java.util.regex.Pattern;
 
-public class Patterns {
+public final class Patterns {
 
     private static final String JAVA_IDENTIFIER_REGEX = "[\\p{L}\\p{Sc}_][\\p{L}\\p{N}\\p{Sc}_]*";
 
+    private Patterns() {}
+
     /**
      * Pattern matching valid Java package declarations, according to
      * <a href="https://docs.oracle.com/javase/specs/jls/se7/html/index.html">The Java®
Language Specification, 7th edition</a>.
diff --git a/src/test/java/org/apache/sling/scripting/sightly/impl/utils/PatternsTest.java
b/src/test/java/org/apache/sling/scripting/sightly/impl/utils/PatternsTest.java
index 80f049d..22e96ca 100644
--- a/src/test/java/org/apache/sling/scripting/sightly/impl/utils/PatternsTest.java
+++ b/src/test/java/org/apache/sling/scripting/sightly/impl/utils/PatternsTest.java
@@ -53,6 +53,9 @@ public class PatternsTest {
                 "package org.apache.sling.scripting.sightly.impl.utils ; ", true,
         };
         testPattern(Patterns.JAVA_PACKAGE_DECLARATION, inputs);
+        // pattern from org.apache.sling.scripting.sightly.impl.engine.SightlyJavaCompilerService
before SLING-7523
+        // Pattern PACKAGE_DECL_PATTERN = Pattern.compile("(\\s*)package\\s+([a-zA-Z_$][a-zA-Z\\d_$]*\\.?)+;");
+        // testPattern(PACKAGE_DECL_PATTERN, inputs);
     }
 
     @Test
@@ -75,28 +78,6 @@ public class PatternsTest {
         testPattern(Patterns.JAVA_CLASS_NAME, inputs);
     }
 
-//    @Test
-//    public void testSLING_7523Pattern() {
-//        // pattern from org.apache.sling.scripting.sightly.impl.engine.SightlyJavaCompilerService
before SLING-7523
-//        Pattern PACKAGE_DECL_PATTERN = Pattern.compile("(\\s*)package\\s+([a-zA-Z_$][a-zA-Z\\d_$]*\\.?)+;");
-//        Object[] inputs = new Object[]{
-//                "package org.apache.sling.scripting.sightly.impl.utils; ", true,
-//                "package org.apache.sling.scripting.sightly.impl_utils; ", true,
-//                "package org.apache.sling.scripting.sightly.impl_utils;", true,
-//                "package org.apache.sling.scripting.sightly.impl.utils;", true,
-//                "package $org.apache.sling.scripting.sightly.impl.utils;", true,
-//                "package _org.apache.sling.scripting.sightly.impl.utils;", true,
-//                "package org.apa_che.sling.scripting.sightly.impl.utils;", true,
-//                "package org.ap$che.sling.scripting.sightly.impl.utils;", true,
-//                "package org.ap4che.$sling._scripting.sightly.impl.utils;", true,
-//                "package 1org.apache.sling.scripting.sightly.impl.utils;", false,
-//                "package org.1apache.sling.scripting.sightly.impl.utils;", false,
-//                "package\torg.apache.sling.scripting.sightly.impl.utils;\t", true,
-//                "package org.apache.sling.scripting.sightly.impl.utils ; ", true,
-//        };
-//        testPattern(PACKAGE_DECL_PATTERN, inputs);
-//    }
-
     private void testPattern(Pattern pattern, Object[] inputs) {
         StringBuilder errors = new StringBuilder();
         ExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadExecutor();

-- 
To stop receiving notification emails like this one, please contact
radu@apache.org.

Mime
View raw message