db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1585774 - in /db/derby/code/trunk/java: engine/org/apache/derby/loc/ optional/org/apache/derby/optional/lucene/ shared/org/apache/derby/shared/common/reference/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Tue, 08 Apr 2014 16:21:42 GMT
Author: rhillegas
Date: Tue Apr  8 16:21:42 2014
New Revision: 1585774

URL: http://svn.apache.org/r1585774
Log:
DERBY-590: Prevent Derby from using an earlier version of Lucene to read an index created
by a later version of Lucene; commit derby-590-21-aa-noTimeTravel.diff.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
    db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneQueryVTI.java
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?rev=1585774&r1=1585773&r2=1585774&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Tue Apr  8 16:21:42
2014
@@ -2376,6 +2376,13 @@ Guide.
                 <arg>columnName</arg>
             </msg>
 
+	        <msg>
+                <name>42XBK</name>
+                <text>The current Lucene version '{0}' cannot read an index created
by Lucene version '{1}'.</text>
+                <arg>luceneVersion</arg>
+                <arg>indexVersion</arg>
+            </msg>
+
             <msg>
                 <name>42Y00</name>
                 <text>Class '{0}' does not implement org.apache.derby.iapi.db.AggregateDefinition
and thus cannot be used as an aggregate expression.</text>

Modified: db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneQueryVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneQueryVTI.java?rev=1585774&r1=1585773&r2=1585774&view=diff
==============================================================================
--- db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneQueryVTI.java
(original)
+++ db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneQueryVTI.java
Tue Apr  8 16:21:42 2014
@@ -432,6 +432,8 @@ public class LuceneQueryVTI extends Stri
             String          analyzerMaker = indexProperties.getProperty( LuceneSupport.ANALYZER_MAKER
);
             Analyzer    analyzer = LuceneSupport.getAnalyzer( analyzerMaker );
 
+            vetLuceneVersion( indexProperties.getProperty( LuceneSupport.LUCENE_VERSION )
);
+
             _indexReader = LuceneSupport.getIndexReader( new File( indexhome.toString() )
);
             _searcher = new IndexSearcher(_indexReader);
 
@@ -465,8 +467,33 @@ public class LuceneQueryVTI extends Stri
 
     /**
      * <p>
+     * Make sure that the index wasn't created with a Lucene version from
+     * the future.
+     * </p>
+     */
+    private void    vetLuceneVersion( String indexVersionString )
+        throws SQLException
+    {
+        Version     currentVersion = LuceneUtils.currentVersion();
+        Version     indexVersion = null;
+
+        try {
+            indexVersion = Version.valueOf( indexVersionString );
+        }
+        catch (Exception e) {}
+
+        if ( (indexVersion == null) || !currentVersion.onOrAfter( indexVersion ) )
+        {
+            throw LuceneSupport.newSQLException
+                ( SQLState.LUCENE_BAD_VERSION, currentVersion.toString(), indexVersionString
);
+        }
+    }
+
+    /**
+     * <p>
      * Make sure that the user has SELECT privilege on the text column and on all
      * the key columns of the underlying table.
+     * </p>
      */
     private void    vetPrivileges() throws SQLException
     {

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=1585774&r1=1585773&r2=1585774&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
Tue Apr  8 16:21:42 2014
@@ -1184,6 +1184,7 @@ public interface SQLState {
     String LUCENE_ALREADY_UNLOADED                                  = "42XBH";
     String LUCENE_BAD_INDEX                                               = "42XBI";
     String LUCENE_BAD_COLUMN_NAME                                   = "42XBJ";
+    String LUCENE_BAD_VERSION                                           = "42XBK";
     
 	// org.apache.derby.impl.sql.execute.rts
 	String RTS_ATTACHED_TO											   = "43X00.U";

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java?rev=1585774&r1=1585773&r2=1585774&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java
Tue Apr  8 16:21:42 2014
@@ -72,6 +72,9 @@ public class LuceneSupportPermsTest exte
     //
     ///////////////////////////////////////////////////////////////////////////////////
 
+    private static  final   String      LUCENE_VERSION_PROPERTY = "derby.tests.lucene.version";
+    private static  String              LUCENE_VERSION = "LUCENE_45";
+
     private static  final   String      TEST_DBO = "TEST_DBO";
     private static  final   String      RUTH = "RUTH";
     private static  final   String      ALICE = "ALICE";
@@ -105,7 +108,6 @@ public class LuceneSupportPermsTest exte
     private static  final   long        MILLIS_IN_HOUR = 1000L * 60L * 60L;
     private static  final   long        MILLIS_IN_DAY = MILLIS_IN_HOUR * 24L;
 
-    private static  final   String      LUCENE_VERSION = "LUCENE_45";
     private static  final   String      LANGUAGE = "en";
     private static  final   String      COUNTRY = "US";
 
@@ -142,6 +144,9 @@ public class LuceneSupportPermsTest exte
      */
     public static Test suite()
     {
+        String      luceneVersion = getSystemProperty( LUCENE_VERSION_PROPERTY );
+        if ( luceneVersion != null ) { LUCENE_VERSION = luceneVersion; }
+        
         TestSuite suite = (TestSuite) TestConfiguration.embeddedSuite(LuceneSupportPermsTest.class);
 
         Test        localizedTest = new LocaleTestSetup( suite, new Locale( LANGUAGE, COUNTRY
) );



Mime
View raw message