db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1729326 - in /db/derby/code/trunk: ./ java/testing/ java/testing/org/apache/derbyTesting/functionTests/harness/ java/testing/org/apache/derbyTesting/functionTests/util/ tools/ant/properties/ tools/ide/netbeans/nbproject/ tools/java/ tools/...
Date Tue, 09 Feb 2016 07:58:06 GMT
Author: kahatlen
Date: Tue Feb  9 07:58:06 2016
New Revision: 1729326

URL: http://svn.apache.org/viewvc?rev=1729326&view=rev
Log:
DERBY-6868: Remove the dependency on Jakarta ORO

Rewrite the Sed class so that it uses java.util.regex instead of
Jakarta ORO for regular expression matching and substitution.

Remove tools/java/jakarta-oro-2.0.8.jar and all references to it.

Removed:
    db/derby/code/trunk/tools/java/jakarta-oro-2.0.8.jar
Modified:
    db/derby/code/trunk/build.xml
    db/derby/code/trunk/java/testing/README.htm
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/build.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
    db/derby/code/trunk/tools/ant/properties/extrapath.properties
    db/derby/code/trunk/tools/ide/netbeans/nbproject/project.xml
    db/derby/code/trunk/tools/release/build.xml
    db/derby/code/trunk/tools/testing/reporting/TEMPLATES/testenv.sh

Modified: db/derby/code/trunk/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/build.xml?rev=1729326&r1=1729325&r2=1729326&view=diff
==============================================================================
--- db/derby/code/trunk/build.xml (original)
+++ db/derby/code/trunk/build.xml Tue Feb  9 07:58:06 2016
@@ -2706,7 +2706,6 @@
       <fileset dir="${derby.junit.test.jars}" includes="*.jar"/>
    	  <pathelement path="${derby.junit.classpath}"/>
       <pathelement location="${javatools.dir}/junit.jar"/>
-      <pathelement location="${javatools.dir}/jakarta-oro-2.0.8.jar"/>
     </path>
     <echo message="Classpath used for derbyall: ${toString:derbyall.classpath}"/>
     <mkdir dir="junit_${derby.junit.timestamp}/derbyall"/>

Modified: db/derby/code/trunk/java/testing/README.htm
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/README.htm?rev=1729326&r1=1729325&r2=1729326&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/README.htm (original)
+++ db/derby/code/trunk/java/testing/README.htm Tue Feb  9 07:58:06 2016
@@ -217,15 +217,6 @@ have any colons or spaces in it.</p>
 following jars: </p>
     <ul>
       <li>
-        <p style="margin-bottom: 0in;"><font size="2">jakarta-oro-2.0.8.jar</font>
-&nbsp;&nbsp;&nbsp; <font size="2">oromatcher, obtain from the svn source
tree, or from <a
- href="http://jakarta.apache.org/oro/index.html">http://jakarta.apache.org/oro/index.html</a>,
-or follow this link for <a
- href="http://apache.roweboat.net/jakarta/oro/source/jakarta-oro-2.0.8.zip">zip</a>
-file, or <a
- href="http://apache.roweboat.net/jakarta/oro/source/jakarta-oro-2.0.8.tar.gz">tar</a>.gz)</font></p>
-      </li>
-      <li>
         <p style="margin-bottom: 0in;"><font size="2">derbyTesting.jar<br>
         </font>&nbsp;&nbsp;&nbsp;&nbsp; <font size="2">test files
and
 classes</font></p>
@@ -264,11 +255,11 @@ classpath</b> </font>&nbsp;&nbsp;&nbsp;
           <p><font size="2">(note that $jardir is only a convenience
 variable that points to the directory containing the Derby jar files,
 and $tstjardir ia a convenience variable that points to the directory
-containing the jar files for Jakarta ORO and JUnit):<br>
+containing the jar file for JUnit):<br>
 set jardir=/local/derbyjar<br>
 set tstjardir=/local/testingjars<br>
 set
-CLASSPATH="$jardir/derbyrun.jar:$jardir/derbyTesting.jar:$tstjardir/jakarta-oro-2.0.8.jar:$tstjardir/junit.jar"</font><br>
+CLASSPATH="$jardir/derbyrun.jar:$jardir/derbyTesting.jar:$tstjardir/junit.jar"</font><br>
           <font size="2">set PATH=/local/jdk141/bin:$PATH</font></p>
           </td>
         </tr>

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java?rev=1729326&r1=1729325&r2=1729326&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/Sed.java
Tue Feb  9 07:58:06 2016
@@ -25,17 +25,18 @@ package org.apache.derbyTesting.function
  * Sed.java
  *
  * This is a version of "sed" in Java for the Derby Function Tests,
- * written using the OROMatcher Perl5 regular expression classes.
+ * written using the java.util.regex regular expression classes.
  * The substitutions/deletions are based on the original kornshell tests.
  *
  ***/
 
 import java.io.*;
 import java.util.Vector;
-import org.apache.oro.text.regex.*;
-import java.util.Enumeration;
+import java.util.List;
 import java.util.Properties;
 import java.util.StringTokenizer;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 import org.apache.derbyTesting.functionTests.util.TestUtil;
 
 public class Sed
@@ -148,7 +149,7 @@ public class Sed
         timestampFilter.append( "[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]* *" );
         searchStrings.addElement( timestampFilter.toString() );
         // Filter remove transaction id's from deadlock messages
-        searchStrings.addElement("^  Waiting XID : {.*}");
+        searchStrings.addElement("^  Waiting XID : \\{.*\\}");
         searchStrings.addElement("^  Granted XID : .*$");
         searchStrings.addElement("^The selected victim is XID : .*");
         // Filters for build numbers
@@ -313,17 +314,8 @@ public class Sed
         Vector<String> subStrings, InputStream isSed, boolean isI18N)
         throws IOException
     {
-		
-        boolean lineDeleted = false;
-        PatternMatcher matcher;
-        Perl5Compiler pcompiler;
-        PatternMatcherInput input;
         BufferedReader inFile;
         PrintWriter outFile;
-        String result = "";
-        String regex;
-        Vector<Pattern> delPatternVector = new Vector<Pattern>();
-        Vector<Pattern> subPatternVector = new Vector<Pattern>();
 
         // ---------------------------------
         // Try loading the sed properties if they exist (see jdbc_sed.properties as an example)
@@ -332,9 +324,8 @@ public class Sed
             Properties sedp = new Properties();
 
             sedp.load(isSed);
-            for (Enumeration e = sedp.propertyNames(); e.hasMoreElements(); )
+            for (String key : sedp.stringPropertyNames())
             {
-                String key = (String)e.nextElement();
                 if (key.equals("substitute"))
                 {
                     String value = sedp.getProperty(key);
@@ -374,10 +365,6 @@ public class Sed
         }
         // ---------------------------------
 
-        //Create Perl5Compiler and Perl5Matcher
-        pcompiler = new Perl5Compiler();
-        matcher = new Perl5Matcher();
-
         // Define the input and output files based on args
         if (is == null && isI18N) {
             // read UTF-8 encoded file
@@ -393,42 +380,12 @@ public class Sed
         ( new BufferedWriter(new FileWriter(dstFile), 10000), true );
 
         // Attempt to compile the patterns for deletes
-        for (int i = 0; i < deleteLines.size(); i++)
-        {
-            try
-            {
-                regex = (String)deleteLines.elementAt(i);
-                //System.out.println("The pattern: " + regex);
-                Pattern pattern = pcompiler.compile(regex);
-                if (pattern == null)
-                    System.out.println("pattern is null");
-                delPatternVector.addElement(pattern);
-            }
-            catch(MalformedPatternException e)
-            {
-                System.out.println("Bad pattern.");
-                System.out.println(e.getMessage());
-            }
-        }
+        List<Pattern> deletePatterns = deleteLines.stream()
+                .map(Pattern::compile).collect(Collectors.toList());
 
         // Attempt to compile the patterns for substitutes
-        for (int i = 0; i < searchStrings.size(); i++)
-        {
-            try
-            {
-                regex = (String)searchStrings.elementAt(i);
-                //System.out.println("The pattern: " + regex);
-                Pattern pattern = pcompiler.compile(regex);
-                if (pattern == null)
-                    System.out.println("pattern is null");
-                subPatternVector.addElement(pattern);
-            }
-            catch(MalformedPatternException e)
-            {
-                System.out.println("Bad pattern.");
-                System.out.println(e.getMessage());
-            }
-        }
+        List<Pattern> substitutePatterns = searchStrings.stream()
+                .map(Pattern::compile).collect(Collectors.toList());
 
         String str;
         int j;
@@ -440,7 +397,7 @@ public class Sed
         
             //System.out.println("***Line no: " + lineCount);
             //System.out.println("***Line is: " + str);
-            lineDeleted = false;
+            boolean lineDeleted = false;
 
             // First delete any nulls (Cafe 1.8 leaves nulls)
             if (str.length() == 1)
@@ -495,68 +452,24 @@ public class Sed
             // Determine if this line should be deleted for delete pattern match
             if ( lineDeleted == false )
             {
-                for (j = 0; j < delPatternVector.size(); j++)
-                {
-                    if ( matcher.contains( str, (Pattern)delPatternVector.elementAt(j) )
)
-                    {
-                        //System.out.println("***Match found to delete line***");
-                        String tmpp = ((Pattern)delPatternVector.elementAt(j)).getPattern();
-                        //System.out.println("***Pattern is: " + tmpp);
-
-                        // In this case we are removing the line, so don't write it out
-                        lineDeleted = true;
-                        break;
-                    }
-                }
+                final String s = str;
+                lineDeleted =
+                    deletePatterns.stream().anyMatch(p -> p.matcher(s).find());
             }
 
             // Determine if any substitutions are needed
             if (lineDeleted == false)
             {
-                Substitution substitution;
-                StringSubstitution strsub = new StringSubstitution("");
-                Perl5Substitution perlsub = new Perl5Substitution("");
-                boolean subDone = false;
-                for (j = 0; j < subPatternVector.size(); j++)
+                for (j = 0; j < substitutePatterns.size(); j++)
                 {
-                    input = new PatternMatcherInput(str);
-                    Pattern patt = (Pattern)subPatternVector.elementAt(j);
-                    String pstr = patt.getPattern();
-                    //System.out.println("Pattern string is " + pstr);
-                    String sub = (String)subStrings.elementAt(j);
-                    if (sub.indexOf("$") > 0)
-                    {
-                        perlsub.setSubstitution(sub);
-                        substitution = (Substitution)perlsub;
-                    } else {
-                        strsub.setSubstitution(sub);
-                        substitution = (Substitution)strsub;
-                    }
+                    Pattern patt = substitutePatterns.get(j);
+                    //System.out.println("Pattern string is " + patt);
+                    String sub = subStrings.get(j);
                     //System.out.println("Substitute str = " + sub);
-                    if ( matcher.contains( input, patt ) )
-                    {
-                        MatchResult mr = matcher.getMatch();
-                        //System.out.println("***Match found for substitute***");
-                        // In this case we do a substitute
-                        result = Util.substitute(matcher, patt, substitution, str,
-                        Util.SUBSTITUTE_ALL);
-                        //System.out.println("New string: " + result);
-                        //outFile.println(result);
-                        str = result;
-                        subDone = true;
-                    }
-                }
-                if (subDone)
-                {
-                    //System.out.println("write the subbed line");
-                    outFile.println(result);
-                }
-                else
-                {
-                    //System.out.println("Write the str: " + str);
-                    outFile.println(str);
-                    outFile.flush();
+                    str = patt.matcher(str).replaceAll(sub);
                 }
+                //System.out.println("Write the str: " + str);
+                outFile.println(str);
             }// end if
         } // end while
         inFile.close();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/build.xml?rev=1729326&r1=1729325&r2=1729326&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/build.xml
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/build.xml
Tue Feb  9 07:58:06 2016
@@ -78,7 +78,6 @@
       srcdir="${derby.testing.src.dir}"
       destdir="${out.dir}">
       <classpath>
-        <pathelement location="${oro}"/>
         <pathelement path="${junit}"/>
       </classpath>
       <include name="${this.dir}/*.java"/>

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml?rev=1729326&r1=1729325&r2=1729326&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
Tue Feb  9 07:58:06 2016
@@ -55,7 +55,6 @@
       srcdir="${derby.testing.src.dir}"
       destdir="${out.dir}">
       <classpath>
-        <pathelement location="${oro}"/>
         <pathelement path="${junit}"/>
       </classpath>
       <include name="${this.dir}/*.java"/> 

Modified: db/derby/code/trunk/tools/ant/properties/extrapath.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/ant/properties/extrapath.properties?rev=1729326&r1=1729325&r2=1729326&view=diff
==============================================================================
--- db/derby/code/trunk/tools/ant/properties/extrapath.properties (original)
+++ db/derby/code/trunk/tools/ant/properties/extrapath.properties Tue Feb  9 07:58:06 2016
@@ -22,7 +22,6 @@
 #
 # Extra jars/zips/classes
 #
-oro=${javatools.dir}/jakarta-oro-2.0.8.jar
 servlet24=${javatools.dir}/geronimo-spec-servlet-2.4-rc4.jar
 osgi=${out.felix.dir}
 javacc=${javatools.dir}/javacc.jar
@@ -37,4 +36,4 @@ json_simple=${javatools.dir}/json_simple
 #
 # Base JavaDoc collection, used for both product and test JavaDocs.
 #
-jars.javadoc=${osgi};${oro};${servlet24}:${lucene_core}:${lucene_a_co}:${lucene_qp}:${json_simple}
+jars.javadoc=${osgi};${servlet24}:${lucene_core}:${lucene_a_co}:${lucene_qp}:${json_simple}

Modified: db/derby/code/trunk/tools/ide/netbeans/nbproject/project.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/ide/netbeans/nbproject/project.xml?rev=1729326&r1=1729325&r2=1729326&view=diff
==============================================================================
--- db/derby/code/trunk/tools/ide/netbeans/nbproject/project.xml (original)
+++ db/derby/code/trunk/tools/ide/netbeans/nbproject/project.xml Tue Feb  9 07:58:06 2016
@@ -262,7 +262,7 @@
                 <package-root>${project.dir}/java/tools</package-root>
                 <package-root>${project.dir}/generated/java</package-root>
                 <package-root>${project.dir}/java/optional</package-root>
-                <classpath mode="compile">${project.dir}/tools/java/geronimo-spec-servlet-2.4-rc4.jar:${project.dir}/tools/java/jakarta-oro-2.0.8.jar:${project.dir}/tools/java/javacc.jar:${project.dir}/tools/java/junit.jar:${ant.core.lib}:${project.dir}/classes/stubs/felix:${project.dir}/tools/java/lucene-analyzers-common.jar:${project.dir}/tools/java/lucene-core.jar:${project.dir}/tools/java/lucene-queryparser.jar</classpath>
+                <classpath mode="compile">${project.dir}/tools/java/geronimo-spec-servlet-2.4-rc4.jar:${project.dir}/tools/java/javacc.jar:${project.dir}/tools/java/junit.jar:${ant.core.lib}:${project.dir}/classes/stubs/felix:${project.dir}/tools/java/lucene-analyzers-common.jar:${project.dir}/tools/java/lucene-core.jar:${project.dir}/tools/java/lucene-queryparser.jar</classpath>
                 <built-to>${project.dir}/jars/sane/derby.jar</built-to>
                 <built-to>${project.dir}/jars/sane/derbyTesting.jar</built-to>
                 <built-to>${project.dir}/jars/sane/derbyclient.jar</built-to>

Modified: db/derby/code/trunk/tools/release/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/release/build.xml?rev=1729326&r1=1729325&r2=1729326&view=diff
==============================================================================
--- db/derby/code/trunk/tools/release/build.xml (original)
+++ db/derby/code/trunk/tools/release/build.xml Tue Feb  9 07:58:06 2016
@@ -260,8 +260,6 @@
       <zipfileset dir="${basedir}/jars/insane" prefix="${derby.bin}/test" includes="derbyTesting.jar"/>
       <zipfileset dir="${basedir}/java/testing" prefix="${derby.bin}/test" 
                   includes="README.htm"/>
-      <zipfileset dir="${basedir}/tools/java" prefix="${derby.bin}/test" 
-                  includes="jakarta-oro-2.0.8.jar"/>
     </zip>
   </target>
 
@@ -318,8 +316,6 @@
       <tarfileset dir="${basedir}/jars/insane" prefix="${derby.bin}/test" includes="derbyTesting.jar"/>
       <tarfileset dir="${basedir}/java/testing" prefix="${derby.bin}/test" 
                   includes="README.htm"/>
-      <tarfileset dir="${basedir}/tools/java" prefix="${derby.bin}/test" 
-                  includes="jakarta-oro-2.0.8.jar"/>
     </tar>
   </target>
 
@@ -335,8 +331,6 @@
       <zipfileset dir="${basedir}/jars/insane" prefix="${derby.lib}/test" includes="derbyTesting.jar"/>
       <zipfileset dir="${basedir}/java/testing" prefix="${derby.lib}/test" 
                   includes="README.htm"/>
-      <zipfileset dir="${basedir}/tools/java" prefix="${derby.lib}/test" 
-                  includes="jakarta-oro-2.0.8.jar"/>
     </zip>
   </target>
   <target name="lib.tgz">
@@ -349,8 +343,6 @@
       <tarfileset dir="${basedir}/jars/insane" prefix="${derby.lib}/test" includes="derbyTesting.jar"/>
       <tarfileset dir="${basedir}/java/testing" prefix="${derby.lib}/test" 
                   includes="README.htm"/>
-      <tarfileset dir="${basedir}/tools/java" prefix="${derby.lib}/test" 
-                  includes="jakarta-oro-2.0.8.jar"/>
     </tar>
   </target>
 
@@ -366,8 +358,6 @@
       <zipfileset dir="${basedir}/jars/sane" prefix="${derby.lib-debug}/test" includes="derbyTesting.jar"/>
       <zipfileset dir="${basedir}/java/testing" prefix="${derby.lib-debug}/test" 
                   includes="README.htm"/>
-      <zipfileset dir="${basedir}/tools/java" prefix="${derby.lib-debug}/test" 
-                  includes="jakarta-oro-2.0.8.jar"/>
     </zip>
   </target>
   <target name="lib-debug.tgz">
@@ -380,8 +370,6 @@
       <tarfileset dir="${basedir}/jars/sane" prefix="${derby.lib-debug}/test" includes="derbyTesting.jar"/>
       <tarfileset dir="${basedir}/java/testing" prefix="${derby.lib-debug}/test" 
                   includes="README.htm"/>
-      <tarfileset dir="${basedir}/tools/java" prefix="${derby.lib-debug}/test" 
-                  includes="jakarta-oro-2.0.8.jar"/>
     </tar>
   </target>
 

Modified: db/derby/code/trunk/tools/testing/reporting/TEMPLATES/testenv.sh
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/testing/reporting/TEMPLATES/testenv.sh?rev=1729326&r1=1729325&r2=1729326&view=diff
==============================================================================
--- db/derby/code/trunk/tools/testing/reporting/TEMPLATES/testenv.sh (original)
+++ db/derby/code/trunk/tools/testing/reporting/TEMPLATES/testenv.sh Tue Feb  9 07:58:06 2016
@@ -24,7 +24,6 @@ export ROOT=${derby_source}
 
 JARDIR=$ROOT/jars/insane # Change if you use sane
 DBTOOLDIR=$ROOT/tools/java
-ORO=$DBTOOLDIR/jakarta-oro-2.0.8.jar
 JUNIT=$DBTOOLDIR/junit.jar
 
 DERBY=$JARDIR/derby.jar
@@ -49,7 +48,7 @@ $JARDIR/derbyLocale_pt_BR.jar:\
 $JARDIR/derbyLocale_zh_CN.jar:\
 $JARDIR/derbyLocale_zh_TW.jar
  
-export CLASSPATH=$DERBY:$DERBYCLIENT:$DERBYTOOLS:$DERBYNET:$DB2JCC:$DERBYTESTING:$DERBYRUN:$ORO:$JUNIT:$LOCALES
+export CLASSPATH=$DERBY:$DERBYCLIENT:$DERBYTOOLS:$DERBYNET:$DB2JCC:$DERBYTESTING:$DERBYRUN:$JUNIT:$LOCALES
 
 # At least needed on SunOs/x86:
 export LC_CTYPE=en_US



Mime
View raw message