You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 10:03:37 UTC

[lucene] branch branch_5_4 created (now 7d52c25)

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

dweiss pushed a change to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git.


      at 7d52c25  LUCENE-6976 SOLR-8541: BytesTermAttributeImpl.copyTo could NPE. Could be triggered by trying to highlight a spatial RPT field.

This branch includes the following new commits:

     new 53dabab  LUCENE-7018: Fix GeoPointTermQueryConstantScoreWrapper to add document on first GeoPointField match
     new 7f9506c  LUCENE-6938: Convert build to work with Git rather than SVN. (Mark Miller via Dawid Weiss).
     new f4b228b  LUCENE-6938: Fix Lucene's src.tgz file; remove svnkit stuff
     new 8311297  LUCENE-6938: fix typo, sorry
     new 016b266  LUCENE-6938: Maven build: Switch SCM descriptors from svn to git; buildnumber-maven-plugin's buildNumberPropertyName property (used in Maven-built artifact manifests) renamed from svn.revision to checkoutid; removed Subversion-specific stuff from README.maven
     new d4a8bbb  LUCENE-6938: Improve output of Git Hash if no GIT available or no GIT checkout (this restores previous behaviour)
     new 0d53dce  LUCENE-6938: Add WC checks back, now based on JGit
     new b0e769c  LUCENE-6995, LUCENE-6938: Add branch change trigger to common-build.xml to keep sane build on GIT branch change
     new b8f5723  LUCENE-7019: add two-phase iteration to GeoPointTermQueryConstantScoreWrapper
     new ad2c18c  LUCENE-6932: RAMDirectory's IndexInput should always throw EOFE if you seek beyond the end of the file and then try to read
     new 9041c1c  LUCENE-6932: RAMInputStream now throws EOFException if you seek beyond the end of the file
     new b4fa82b  LUCENE-6932: also fix NIOFSIndexInput to throw EOFE if you seek beyond end of file
     new 041cd94  LUCENE-6932: fix test bug that was not always using the dir impl being tested; fix SimpleFSIndexInput to throw EOFException if you seek beyond end of file
     new 2512ab6  LUCENE-6932: also fix RAFIndexInput to throw EOFE if you seek beyond end of file
     new 3100f1b  LUCENE-6932: improve exception messages; rename length parameter to sliceLength, and return it as the length, for clarity
     new df30bc6  LUCENE-6998: fix a couple places to better detect truncated index files; improve corruption testing
     new 96624a6  LUCENE-7002: Fixed MultiCollector to not throw a NPE if setScorer is called after one of the sub collectors is done collecting.
     new 7d52c25  LUCENE-6976 SOLR-8541: BytesTermAttributeImpl.copyTo could NPE. Could be triggered by trying to highlight a spatial RPT field.

The 18 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[lucene] 07/18: LUCENE-6938: Add WC checks back, now based on JGit

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 0d53dce184674dfc8c23879c0e0648b0bd6ae1b8
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Sun Jan 24 22:05:38 2016 +0100

    LUCENE-6938: Add WC checks back, now based on JGit
---
 build.xml | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 70 insertions(+), 5 deletions(-)

diff --git a/build.xml b/build.xml
index 4448841..a37de95 100644
--- a/build.xml
+++ b/build.xml
@@ -20,6 +20,8 @@
 <project name="lucene-solr" default="-projecthelp" basedir=".">
   <import file="lucene/common-build.xml"/>
 
+  <property name="jgit-version" value="4.2.0.201601211800-r"/>
+  
   <property name="tests.heap-dump-dir" location="heapdumps"/>
   
   <property name="maven-build-dir" value="maven-build"/>
@@ -559,8 +561,71 @@ File | Project Structure | Platform Settings | SDKs):
     <delete dir="${smokeTestRelease.tmp}"/>
   </target>
   
-  <target name="check-working-copy">
-    <echo>This task is currently disabled due to migration to GIT</echo>
+  <macrodef xmlns:ivy="antlib:org.apache.ivy.ant" name="wc-checker">
+    <attribute name="failonmodifications"/><!-- fail if modifications were found, otherwise it only fails on unversioned files -->
+    <sequential>
+      <local name="wc.unversioned.files"/>
+      <local name="wc.modified.files"/>
+      <ivy:cachepath xmlns:ivy="antlib:org.apache.ivy.ant"
+        organisation="org.eclipse.jgit" module="org.eclipse.jgit" revision="${jgit-version}"
+        inline="true" conf="default" transitive="true" pathid="jgit.classpath"/>
+      <groovy taskname="wc-checker" classpathref="jgit.classpath"><![CDATA[
+        import org.apache.tools.ant.BuildException;
+        import org.apache.tools.ant.Project;
+        import org.eclipse.jgit.api.Git;
+        import org.eclipse.jgit.api.Status;
+        import org.eclipse.jgit.lib.Repository;
+        import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+        import org.eclipse.jgit.errors.*;
+
+        def setProjectPropertyFromSet(prop, set) {
+          if (set) {
+            properties[prop] = '* ' + set.join(properties['line.separator'] + '* ');
+          }
+        };
+
+        try {
+          task.log('Initializing working copy...', Project.MSG_INFO);
+          final Repository repository = new FileRepositoryBuilder()
+            .setWorkTree(project.getBaseDir())
+            .setMustExist(true)
+            .build();
+
+          task.log('Checking working copy status...', Project.MSG_INFO);
+          final Status status = new Git(repository).status().call();
+          if (!status.isClean()) {
+            final SortedSet unversioned = new TreeSet(), modified = new TreeSet();
+            status.properties.each{ prop, val ->
+              if (val instanceof Set) {
+                if (prop in ['untracked', 'untrackedFolders', 'missing']) {
+                  unversioned.addAll(val);
+                } else if (prop != 'ignoredNotInIndex') {
+                  modified.addAll(val);
+                }
+              }
+            };
+            setProjectPropertyFromSet('wc.unversioned.files', unversioned);
+            setProjectPropertyFromSet('wc.modified.files', modified);
+          }
+        } catch (RepositoryNotFoundException | NoWorkTreeException | NotSupportedException e) {
+          task.log('WARNING: Development directory is not a valid GIT checkout! Disabling checks...', Project.MSG_WARN);
+        }
+      ]]></groovy>
+      <fail if="wc.unversioned.files"
+        message="Source checkout is dirty (unversioned/missing files) after running tests!!! Offending files:${line.separator}${wc.unversioned.files}"/>
+      <fail message="Source checkout is modified!!! Offending files:${line.separator}${wc.modified.files}">
+        <condition>
+          <and>
+             <istrue value="@{failonmodifications}"/>
+             <isset property="wc.modified.files"/>
+          </and>
+        </condition>
+      </fail>
+    </sequential>
+  </macrodef>
+  
+  <target name="check-working-copy" description="Checks working copy for unversioned changes" depends="resolve-groovy">
+    <wc-checker failonmodifications="${is.jenkins.build}"/>
   </target>
 
   <target name="run-clover" description="Runs all tests to measure coverage and generates report (pass &quot;ANT_OPTS=-Xmx1536M&quot; as environment)" depends="clean">
@@ -653,13 +718,13 @@ File | Project Structure | Platform Settings | SDKs):
   </target>
 
   <!-- should only be called by jenkins, not precommit! -->
-  <target name="-check-after-regeneration">
-    <!-- TODO -->
+  <target name="-check-after-regeneration" depends="resolve-groovy">
+    <wc-checker failonmodifications="true"/>
   </target>
 
   <!-- TODO: remove me when jenkins works -->
   <target name="regenerateAndCheck" depends="regenerate,-check-after-regeneration"/>
-
+  
   <target name="-append-all-modules-dependencies-properties">
     <delete file="lucene/build/module.dependencies.properties"/>
     <subant target="-append-module-dependencies-properties" inheritall="false" failonerror="true">


[lucene] 10/18: LUCENE-6932: RAMDirectory's IndexInput should always throw EOFE if you seek beyond the end of the file and then try to read

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit ad2c18cd72751cd80c11b4916980fb510eaf8f9f
Author: Michael McCandless <mi...@apache.org>
AuthorDate: Sun Jan 17 19:28:10 2016 +0000

    LUCENE-6932: RAMDirectory's IndexInput should always throw EOFE if you seek beyond the end of the file and then try to read
    
    git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x@1725112 13f79535-47bb-0310-9956-ffa450edef68
    
    Conflicts:
    	lucene/CHANGES.txt
---
 lucene/CHANGES.txt                                 |  4 +++
 .../org/apache/lucene/store/RAMInputStream.java    |  7 +++--
 .../org/apache/lucene/store/TestRAMDirectory.java  | 30 +++++++++++++++++++++-
 3 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index d3fa220..fa48106 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -14,6 +14,10 @@ Bug Fixes
 * LUCENE-7019: add two-phase iteration to GeoPointTermQueryConstantScoreWrapper.
   (Robert Muir via Nick Knize)
 
+* LUCENE-6932: RAMDirectory's IndexInput should always throw
+  EOFException if you seek past the end of the file and then try to
+  read (Stéphane Campinas via Mike McCandless)
+
 ======================= Lucene 5.4.1 =======================
 
 Bug Fixes
diff --git a/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java b/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
index 6cd2e16..46d5dc1 100644
--- a/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
+++ b/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
@@ -97,7 +97,7 @@ public class RAMInputStream extends IndexInput implements Cloneable {
       if (enforceEOF) {
         throw new EOFException("read past EOF: " + this);
       } else {
-        // Force EOF if a read takes place at this position
+        // Force EOF if a read later takes place at this position
         currentBufferIndex--;
         bufferPosition = BUFFER_SIZE;
       }
@@ -120,7 +120,10 @@ public class RAMInputStream extends IndexInput implements Cloneable {
       currentBufferIndex = (int) (pos / BUFFER_SIZE);
       switchCurrentBuffer(false);
     }
-    bufferPosition = (int) (pos % BUFFER_SIZE);
+    if (pos < BUFFER_SIZE * (long) file.numBuffers()) {
+      // do not overwrite bufferPosition if EOF should be thrown on the next read
+      bufferPosition = (int) (pos % BUFFER_SIZE);
+    }
   }
 
   @Override
diff --git a/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java b/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java
index fa3f71e..30ceba5 100644
--- a/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java
+++ b/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java
@@ -17,12 +17,14 @@ package org.apache.lucene.store;
  * limitations under the License.
  */
 
+import java.io.EOFException;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Random;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
@@ -160,4 +162,30 @@ public class TestRAMDirectory extends BaseDirectoryTestCase {
     
     writer.close();
   }
-}
+
+  public void testShouldThrowEOFException() throws Exception {
+    final Random random = random();
+
+    try (Directory dir = newDirectory()) {
+      final int len = 16 + random().nextInt(2048) / 16 * 16;
+      final byte[] bytes = new byte[len];
+
+      try (IndexOutput os = dir.createOutput("foo", newIOContext(random))) {
+        os.writeBytes(bytes, bytes.length);
+      }
+
+      try (IndexInput is = dir.openInput("foo", newIOContext(random))) {
+        try {
+          is.seek(0);
+          // Here, I go past EOF.
+          is.seek(len + random().nextInt(2048));
+          // since EOF is not enforced by the previous call in RAMInputStream
+          // this call to readBytes should throw the exception.
+          is.readBytes(bytes, 0, 16);
+          fail("Did not get EOFException");
+        } catch (EOFException eof) {
+          // expected!
+        }
+      }
+    }
+  }}


[lucene] 01/18: LUCENE-7018: Fix GeoPointTermQueryConstantScoreWrapper to add document on first GeoPointField match

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 53dababd0a958097ee87883f4e991ecdf66693d2
Author: nknize <nk...@apache.org>
AuthorDate: Mon Feb 8 16:49:44 2016 -0600

    LUCENE-7018: Fix GeoPointTermQueryConstantScoreWrapper to add document on first GeoPointField match
---
 lucene/CHANGES.txt                                                | 7 +++++++
 .../lucene/search/GeoPointTermQueryConstantScoreWrapper.java      | 8 ++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 324299e..fa3eab3 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -4,6 +4,13 @@ For more information on past and future Lucene versions, please see:
 http://s.apache.org/luceneversions
 
 
+======================= Lucene 5.4.2 =======================
+
+Bug Fixes
+
+* LUCENE-7018: Fix GeoPointTermQueryConstantScoreWrapper to add document on
+  first GeoPointField match. (Nick Knize)
+
 ======================= Lucene 5.4.1 =======================
 
 Bug Fixes
diff --git a/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java b/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java
index 81f64c2..e9099ac 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java
@@ -82,14 +82,14 @@ final class GeoPointTermQueryConstantScoreWrapper <Q extends GeoPointTermQuery>
           // boundary terms need post filtering by
           if (termsEnum.boundaryTerm()) {
             int docId = docs.nextDoc();
+            long hash;
             do {
               sdv.setDocument(docId);
               for (int i=0; i<sdv.count(); ++i) {
-                final long hash = sdv.valueAt(i);
-                final double lon = GeoUtils.mortonUnhashLon(hash);
-                final double lat = GeoUtils.mortonUnhashLat(hash);
-                if (termsEnum.postFilter(lon, lat)) {
+                hash = sdv.valueAt(i);
+                if (termsEnum.postFilter(GeoUtils.mortonUnhashLon(hash), GeoUtils.mortonUnhashLat(hash))) {
                   builder.add(docId);
+                  break;
                 }
               }
             } while ((docId = docs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS);


[lucene] 04/18: LUCENE-6938: fix typo, sorry

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 83112977e8fa66615d23e57697b2743052c71098
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Sat Jan 23 14:09:49 2016 +0100

    LUCENE-6938: fix typo, sorry
---
 lucene/build.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lucene/build.xml b/lucene/build.xml
index e37c659..23c321a 100644
--- a/lucene/build.xml
+++ b/lucene/build.xml
@@ -349,7 +349,7 @@
     <!-- Exclude clover license files incompatible with the ASL -->
     <delete dir="${src.export.dir}/tools/clover"/>
 
-    <!-- because we only package the "lucene/" folder, we have to adjust dir to work on: ->
+    <!-- because we only package the "lucene/" folder, we have to adjust dir to work on: -->
     <property name="local.src.export.dir" location="${src.export.dir}/lucene"/>
     
     <build-changes changes.src.file="${local.src.export.dir}/CHANGES.txt"


[lucene] 08/18: LUCENE-6995, LUCENE-6938: Add branch change trigger to common-build.xml to keep sane build on GIT branch change

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit b0e769c3ec598dd7398cc8df123bc4c41069e2c3
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Tue Jan 26 22:06:35 2016 +0100

    LUCENE-6995, LUCENE-6938: Add branch change trigger to common-build.xml to keep sane build on GIT branch change
---
 lucene/common-build.xml | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index 890a50b..065e57f 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -288,6 +288,7 @@
     <propertyref regex=".*\.loaded$$"/>
     <propertyref name="lucene.javadoc.url"/><!-- for Solr -->
     <propertyref name="tests.totals.tmpfile" />
+    <propertyref name="git-autoclean.disabled"/>
   </propertyset>
 
   <patternset id="lucene.local.src.package.patterns"
@@ -403,9 +404,41 @@
     <delete file="velocity.log"/>
   </target>
 
-  <target name="init" depends="resolve">
+  <target name="init" depends="git-autoclean,resolve">
     <!-- currently empty -->
   </target>
+  
+  <!-- Keep track of GIT branch and do "ant clean" on root folder when changed, to prevent bad builds... -->
+  
+  <property name="gitHeadFile" location="${common.dir}/../.git/HEAD"/>
+  <property name="gitHeadLocal" location="${common.dir}/build/git-HEAD"/>
+  <available file="${gitHeadFile}" property="isGitCheckout"/>
+
+  <target name="git-autoclean" depends="-check-git-state,-git-cleanroot,-copy-git-state"/>
+  
+  <target name="-check-git-state" if="isGitCheckout" unless="git-autoclean.disabled">
+    <condition property="gitHeadChanged">
+      <and>
+        <available file="${gitHeadLocal}"/>
+        <not><filesmatch file1="${gitHeadFile}" file2="${gitHeadLocal}"/></not>
+      </and>
+    </condition>
+  </target>
+
+  <target name="-git-cleanroot" depends="-check-git-state" if="gitHeadChanged" unless="git-autoclean.disabled">
+    <echo message="Git branch changed, cleaning up for sane build..."/>
+    <ant dir="${common.dir}/.." target="clean" inheritall="false">
+      <propertyset refid="uptodate.and.compiled.properties"/>
+    </ant>
+  </target>
+  
+  <target name="-copy-git-state" if="isGitCheckout" unless="git-autoclean.disabled">
+    <mkdir dir="${common.dir}/build"/>
+    <copy file="${gitHeadFile}" tofile="${gitHeadLocal}"/>
+    <property name="git-autoclean.disabled" value="true"/>
+  </target>
+
+  <!-- IVY stuff -->
 
   <target name="ivy-configure">
      <!-- [DW] ivy loses its configuration for some reason. cannot explain this. if


[lucene] 12/18: LUCENE-6932: also fix NIOFSIndexInput to throw EOFE if you seek beyond end of file

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit b4fa82b0772718d84db3d177f8ce7450be3c51ac
Author: Michael McCandless <mi...@apache.org>
AuthorDate: Fri Jan 22 15:21:20 2016 +0000

    LUCENE-6932: also fix NIOFSIndexInput to throw EOFE if you seek beyond end of file
    
    git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x@1726231 13f79535-47bb-0310-9956-ffa450edef68
---
 lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java b/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java
index 84f1a7f..b739290 100644
--- a/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java
+++ b/lucene/core/src/java/org/apache/lucene/store/NIOFSDirectory.java
@@ -192,6 +192,10 @@ public class NIOFSDirectory extends FSDirectory {
     }
 
     @Override
-    protected void seekInternal(long pos) throws IOException {}
+    protected void seekInternal(long pos) throws IOException {
+      if (pos > length()) {
+        throw new EOFException("read past EOF: pos=" + pos + " vs length=" + length() + ": " + this);
+      }
+    }
   }
 }


[lucene] 18/18: LUCENE-6976 SOLR-8541: BytesTermAttributeImpl.copyTo could NPE. Could be triggered by trying to highlight a spatial RPT field.

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 7d52c2523c7a4ff70612742b76b934a12b493331
Author: David Wayne Smiley <ds...@apache.org>
AuthorDate: Fri Jan 15 20:59:14 2016 +0000

    LUCENE-6976 SOLR-8541: BytesTermAttributeImpl.copyTo could NPE.
    Could be triggered by trying to highlight a spatial RPT field.
    
    git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x@1724877 13f79535-47bb-0310-9956-ffa450edef68
    
    Conflicts:
    	lucene/CHANGES.txt
    	solr/CHANGES.txt
---
 lucene/CHANGES.txt                                 |  3 ++
 .../tokenattributes/BytesTermAttributeImpl.java    | 17 +++++++-
 .../tokenattributes/TestBytesRefAttImpl.java       | 48 ++++++++++++++++++++++
 solr/CHANGES.txt                                   |  8 ++++
 .../org/apache/solr/search/TestSolr4Spatial2.java  | 17 ++++++++
 5 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index cb22e23..c3a321b 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -24,6 +24,9 @@ Bug Fixes
 * LUCENE-7002: Fixed MultiCollector to not throw a NPE if setScorer is called
   after one of the sub collectors is done collecting. (John Wang, Adrien Grand)
 
+* LUCENE-6976: BytesRefTermAttributeImpl.copyTo NPE'ed if BytesRef was null.
+  Added equals & hashCode, and a new test for these things. (David Smiley)
+
 ======================= Lucene 5.4.1 =======================
 
 Bug Fixes
diff --git a/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/BytesTermAttributeImpl.java b/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/BytesTermAttributeImpl.java
index d3f8163..81fa816 100644
--- a/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/BytesTermAttributeImpl.java
+++ b/lucene/core/src/java/org/apache/lucene/analysis/tokenattributes/BytesTermAttributeImpl.java
@@ -17,6 +17,8 @@ package org.apache.lucene.analysis.tokenattributes;
  * limitations under the License.
  */
 
+import java.util.Objects;
+
 import org.apache.lucene.util.AttributeImpl;
 import org.apache.lucene.util.AttributeReflector;
 import org.apache.lucene.util.BytesRef;
@@ -48,7 +50,7 @@ public class BytesTermAttributeImpl extends AttributeImpl implements BytesTermAt
   @Override
   public void copyTo(AttributeImpl target) {
     BytesTermAttributeImpl other = (BytesTermAttributeImpl) target;
-    other.bytes = BytesRef.deepCopyOf(bytes);
+    other.bytes = bytes == null ? null : BytesRef.deepCopyOf(bytes);
   }
 
   @Override
@@ -62,4 +64,17 @@ public class BytesTermAttributeImpl extends AttributeImpl implements BytesTermAt
   public void reflectWith(AttributeReflector reflector) {
     reflector.reflect(TermToBytesRefAttribute.class, "bytes", bytes);
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (!(o instanceof BytesTermAttributeImpl)) return false;
+    BytesTermAttributeImpl that = (BytesTermAttributeImpl) o;
+    return Objects.equals(bytes, that.bytes);
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(bytes);
+  }
 }
\ No newline at end of file
diff --git a/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestBytesRefAttImpl.java b/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestBytesRefAttImpl.java
new file mode 100644
index 0000000..9bf21de
--- /dev/null
+++ b/lucene/core/src/test/org/apache/lucene/analysis/tokenattributes/TestBytesRefAttImpl.java
@@ -0,0 +1,48 @@
+package org.apache.lucene.analysis.tokenattributes;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.util.AttributeImpl;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.LuceneTestCase;
+
+public class TestBytesRefAttImpl extends LuceneTestCase {
+
+  public void testCopyTo() throws Exception {
+    BytesTermAttributeImpl t = new BytesTermAttributeImpl();
+    BytesTermAttributeImpl copy = assertCopyIsEqual(t);
+
+    // first do empty
+    assertEquals(t.getBytesRef(), copy.getBytesRef());
+    assertNull(copy.getBytesRef());
+    // now after setting it
+    t.setBytesRef(new BytesRef("hello"));
+    copy = assertCopyIsEqual(t);
+    assertEquals(t.getBytesRef(), copy.getBytesRef());
+    assertNotSame(t.getBytesRef(), copy.getBytesRef());
+  }
+
+  public static <T extends AttributeImpl> T assertCopyIsEqual(T att) throws Exception {
+    @SuppressWarnings("unchecked")
+    T copy = (T) att.getClass().newInstance();
+    att.copyTo(copy);
+    assertEquals("Copied instance must be equal", att, copy);
+    assertEquals("Copied instance's hashcode must be equal", att.hashCode(), copy.hashCode());
+    return copy;
+  }
+}
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 452be4a..cf12274 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -8,6 +8,14 @@ caching, replication, and a web administration interface.
 
 See http://lucene.apache.org/solr for more information.
 
+==================  5.4.2 ==================
+
+Bug Fixes
+----------------------
+
+* SOLR-8541: Highlighting a geo RPT field would throw an NPE instead of doing nothing.
+  (Pawel Rog via David Smiley)
+
 ==================  5.4.1 ==================
 
 Bug Fixes
diff --git a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
index c190310..b163db0 100644
--- a/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
+++ b/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
@@ -17,9 +17,13 @@ package org.apache.solr.search;
  * limitations under the License.
  */
 
+import org.apache.lucene.analysis.CachingTokenFilter;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.index.memory.MemoryIndex;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.FacetParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.request.SolrQueryRequest;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -160,4 +164,17 @@ public class TestSolr4Spatial2 extends SolrTestCaseJ4 {
     return getSearcher().getRawReader().leaves().get(0).reader().getCoreCacheKey();
   }
 
+  @Test// SOLR-8541
+  public void testConstantScoreQueryWithFilterPartOnly() {
+    final String[] doc1 = {"id", "1", "srptgeom", "56.9485,24.0980"};
+    assertU(adoc(doc1));
+    assertU(commit());
+
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.add("q", "{!geofilt sfield=\"srptgeom\" pt=\"56.9484,24.0981\" d=100}");
+    params.add("hl", "true");
+    params.add("hl.fl", "srptgeom");
+    assertQ(req(params), "*[count(//doc)=1]", "count(//lst[@name='highlighting']/*)=1");
+  }
+
 }


[lucene] 02/18: LUCENE-6938: Convert build to work with Git rather than SVN. (Mark Miller via Dawid Weiss).

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 7f9506ca82032804f2354fef71201366fcbf9932
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Sat Jan 23 02:46:55 2016 +0100

    LUCENE-6938: Convert build to work with Git rather than SVN. (Mark Miller
    via Dawid Weiss).
---
 .gitignore              |  3 ++
 lucene/build.xml        | 16 +++++------
 lucene/common-build.xml | 75 ++++++++++++-------------------------------------
 solr/build.xml          | 20 ++++++-------
 4 files changed, 39 insertions(+), 75 deletions(-)

diff --git a/.gitignore b/.gitignore
index 03a42f4..7d712b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,3 +47,6 @@ solr/contrib/dataimporthandler/test-lib/
 solr/contrib/morphlines-core/test-lib/
 
 solr/core/test-lib/
+
+solr/server/solr-webapp
+solr/server/start.jar
diff --git a/lucene/build.xml b/lucene/build.xml
index 99e108a..712e14b 100644
--- a/lucene/build.xml
+++ b/lucene/build.xml
@@ -335,25 +335,25 @@
     </target>
 
   <!-- ================================================================== -->
-  <!-- Packages the sources from "svn export" with tar-gzip               -->
+  <!-- Packages the sources with tar-gzip               -->
   <!-- ================================================================== -->
   <target name="package-tgz-src" depends="init-dist"
-          description="--> Generates the Lucene source distribution from 'svn export' as .tgz">
+          description="--> Generates the Lucene source distribution as .tgz">
     <property name="source.package.file"
               value="${dist.dir}/lucene-${version}-src.tgz"/>
     <delete file="${source.package.file}"/>
-    <svn-export-source source.dir="."/>
+    <export-source source.dir="."/>
 
     <!-- Exclude javadoc package-list files under licenses incompatible with the ASL -->
-    <delete dir="${svn.export.dir}/tools/javadoc/java7"/>
+    <delete dir="${src.export.dir}/tools/javadoc/java8"/>
     <!-- Exclude clover license files incompatible with the ASL -->
-    <delete dir="${svn.export.dir}/tools/clover"/>
+    <delete dir="${src.export.dir}/tools/clover"/>
 
-    <build-changes changes.src.file="${svn.export.dir}/CHANGES.txt"
-                   changes.target.dir="${svn.export.dir}/docs/changes"
+    <build-changes changes.src.file="${src.export.dir}/CHANGES.txt"
+                   changes.target.dir="${src.export.dir}/docs/changes"
                    changes.product="LUCENE"/>
     <tar tarfile="${source.package.file}" compression="gzip" longfile="gnu">
-      <tarfileset prefix="lucene-${version}" dir="${svn.export.dir}"/>
+      <tarfileset prefix="lucene-${version}" dir="${src.export.dir}"/>
     </tar>
     <make-checksums file="${source.package.file}"/>
   </target>
diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index 5153450..d6167c1 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -248,14 +248,7 @@
 
   <property name="manifest.file" location="${build.dir}/MANIFEST.MF"/>
 
-  <!-- 
-    we attempt to exec svnversion to get details build information
-    for jar manifests.  this property can be set at runtime to an
-    explicit path as needed, or ant will just try to find it in the
-    default PATH. (this is useful for Hudson)
-  -->
-  <property name="svnversion.exe" value="svnversion" />
-  <property name="svn.exe" value="svn" />
+  <property name="git.exe" value="git" />
   <property name="perl.exe" value="perl" />
   
   <property name="python.exe" value="python" />
@@ -639,14 +632,12 @@
     <attribute name="manifest.file" default="${manifest.file}"/>
     <element name="additional-manifest-attributes" optional="true"/>
     <sequential>
-      <local name="-svnversion-raw"/>
-      <local name="svnversion"/>
-      
-      <!-- If possible, include the svnversion -->
-      <exec dir="." executable="${svnversion.exe}" outputproperty="-svnversion-raw" failifexecutionfails="false"/>
-      <condition property="svnversion" value="${-svnversion-raw}" else="unknown">
-        <matches pattern="^\s*[\d:MSP]+\s*$" string="${-svnversion-raw}" casesensitive="true"/>
-      </condition>
+      <exec dir="." executable="${git.exe}" outputproperty="checkoutid" failifexecutionfails="false">
+        <arg value="log"/>
+        <arg value="--format='%H'"/>
+        <arg value="-n"/>
+        <arg value="1"/>
+      </exec>
 
       <manifest file="@{manifest.file}">
         <!--
@@ -678,7 +669,7 @@
         <attribute name="Implementation-Title" value="@{implementation.title}"/>
         <!-- impl version can be any string -->
         <attribute name="Implementation-Version"
-                   value="${version} ${svnversion} - ${user.name} - ${DSTAMP} ${TSTAMP}"/>
+                   value="${version} ${checkoutid} - ${user.name} - ${DSTAMP} ${TSTAMP}"/>
         <attribute name="Implementation-Vendor"
                    value="The Apache Software Foundation"/>
         <attribute name="X-Compile-Source-JDK" value="${javac.source}"/>
@@ -1568,7 +1559,7 @@ ${tests-output}/junit4-*.suites     - per-JVM executed suites
   
   $ ant -Dclover.license.path=/path/to/clover.license -Drun.clover=true ...
   
-  Apache Lucene/Solr source checkouts from SVN already contain the
+  Apache Lucene/Solr source checkouts from Git already contain the
   file, but source distributions cannot because of legal reasons.
   #########################################################################
   
@@ -2264,51 +2255,21 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}
   <target name="validate">
   </target>
 
-  <property name="svn.export.dir" location="${build.dir}/svn-export"/>
-  <macrodef name="svn-export-source"
-            description="Runs 'svn export' with the same URL and revision as the current working copy.">
+  <property name="src.export.dir" location="${build.dir}/src-export"/>
+  <macrodef name="export-source"
+            description="Exports the source to src.export.dir.">
     <attribute name="source.dir"/>
     <sequential>
-      <delete dir="${svn.export.dir}" includeemptydirs="true" failonerror="false"/>
-      <get-svn-info directory="@{source.dir}"/>
-      <exec dir="@{source.dir}" executable="${svn.exe}" failonerror="true">
-        <arg value="export"/>
-        <arg value="--native-eol"/>
-        <arg value="LF"/>
-        <arg value="-r"/>
-        <arg value="${svn.Revision}"/>
-        <arg value="${svn.URL}"/>
-        <arg value="${svn.export.dir}"/>
+      <delete dir="${src.export.dir}" includeemptydirs="true" failonerror="false"/>
+      <exec dir="@{source.dir}" executable="${git.exe}" failonerror="true">
+        <arg value="checkout-index"/>
+        <arg value="-a"/>
+        <arg value="-f"/>
+        <arg value="--prefix=${src.export.dir}/"/>
       </exec>
     </sequential>
   </macrodef>
 
-  <macrodef name="get-svn-info"
-            description="Populates properties svn.URL and svn.Revision using 'svn info'.">
-    <attribute name="directory"/>
-    <sequential>
-      <exec dir="@{directory}" executable="${svnversion.exe}" outputproperty="svn.ver"/>
-      <fail message="A subversion checkout is required for this target">
-        <condition>
-          <matches pattern="(exported|unversioned.*)" string="${svn.ver}" casesensitive="false"/>
-        </condition>
-      </fail>
-      <exec dir="@{directory}" executable="${svn.exe}" outputproperty="svn.info" failonerror="true">
-        <arg value="info"/>
-      </exec>
-      <loadproperties>
-        <propertyresource name="svn.info"/>
-        <filterchain>
-          <linecontainsregexp>
-            <regexp pattern="(URL|Revision):"/>
-          </linecontainsregexp>
-          <replacestring from=": " to="="/>
-          <prefixlines prefix="svn."/>
-        </filterchain>
-      </loadproperties>
-    </sequential>
-  </macrodef>
-
   <macrodef name="make-checksums" description="Macro for building checksum files">
     <attribute name="file"/>
     <sequential>
diff --git a/solr/build.xml b/solr/build.xml
index 215c949..1b30dc9 100644
--- a/solr/build.xml
+++ b/solr/build.xml
@@ -447,36 +447,36 @@
         dest="${package.dir}/KEYS"/>
   </target>
  
-  <!-- Makes a tarball from running "svn export" at the root level.    -->
+  <!-- Makes a tarball of the source.    -->
   <!-- Copies NOTICE.txt and LICENSE.txt from solr/ to the root level. -->
   <target name="package-src-tgz" depends="init-dist"
           description="Packages the Solr Source Distribution">
     <property name="source.package.file"
               value="${package.dir}/${fullnamever}-src.tgz"/>
     <delete file="${source.package.file}" failonerror="false" />
-    <svn-export-source source.dir=".."/>
+    <export-source source.dir=".."/>
 
     <!-- Exclude javadoc package-list files under licenses incompatible with the ASL -->
-    <delete dir="${svn.export.dir}/lucene/tools/javadoc/java7"/>
+    <delete dir="${src.export.dir}/lucene/tools/javadoc/java8"/>
     <!-- Exclude clover license files incompatible with the ASL -->
-    <delete dir="${svn.export.dir}/lucene/tools/clover"/>
+    <delete dir="${src.export.dir}/lucene/tools/clover"/>
 
-    <build-changes changes.src.file="${svn.export.dir}/solr/CHANGES.txt"
-                   changes.target.dir="${svn.export.dir}/solr/docs/changes"
+    <build-changes changes.src.file="${src.export.dir}/solr/CHANGES.txt"
+                   changes.target.dir="${src.export.dir}/solr/docs/changes"
                    changes.product="SOLR"/>
 
     <tar destfile="${source.package.file}" compression="gzip" longfile="gnu">
-      <tarfileset dir="${svn.export.dir}/lucene"
+      <tarfileset dir="${src.export.dir}/lucene"
                   includes="CHANGES.txt"
                   fullpath="${fullnamever}/solr/LUCENE_CHANGES.txt" />
-      <tarfileset dir="${svn.export.dir}"
+      <tarfileset dir="${src.export.dir}"
                   prefix="${fullnamever}"
                   excludes="solr/example/**/*.sh solr/example/**/bin/ solr/scripts/**"/>
-      <tarfileset dir="${svn.export.dir}"
+      <tarfileset dir="${src.export.dir}"
                   prefix="${fullnamever}"
                   filemode="755"
                   includes="solr/example/**/*.sh solr/example/**/bin/ solr/scripts/**"/>
-      <tarfileset dir="${svn.export.dir}/solr" prefix="${fullnamever}"
+      <tarfileset dir="${src.export.dir}/solr" prefix="${fullnamever}"
                   includes="NOTICE.txt,LICENSE.txt"/>
     </tar>
     <make-checksums file="${source.package.file}"/>


[lucene] 17/18: LUCENE-7002: Fixed MultiCollector to not throw a NPE if setScorer is called after one of the sub collectors is done collecting.

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 96624a676f5f2bfe3f267e6c1db889e2fe7a1781
Author: Adrien Grand <jp...@gmail.com>
AuthorDate: Mon Feb 8 16:41:42 2016 +0100

    LUCENE-7002: Fixed MultiCollector to not throw a NPE if setScorer is called after one of the sub collectors is done collecting.
    
    Conflicts:
    	lucene/CHANGES.txt
---
 lucene/CHANGES.txt                                 |  3 +
 .../org/apache/lucene/search/MultiCollector.java   |  3 +-
 .../apache/lucene/search/TestMultiCollector.java   | 71 ++++++++++++++++++++++
 3 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index c93d601..cb22e23 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -21,6 +21,9 @@ Bug Fixes
 * LUCENE-6998: Fix a couple places to better detect truncated index files
   as corruption.  (Robert Muir, Mike McCandless)
 
+* LUCENE-7002: Fixed MultiCollector to not throw a NPE if setScorer is called
+  after one of the sub collectors is done collecting. (John Wang, Adrien Grand)
+
 ======================= Lucene 5.4.1 =======================
 
 Bug Fixes
diff --git a/lucene/core/src/java/org/apache/lucene/search/MultiCollector.java b/lucene/core/src/java/org/apache/lucene/search/MultiCollector.java
index 36202e5..a8f872d 100644
--- a/lucene/core/src/java/org/apache/lucene/search/MultiCollector.java
+++ b/lucene/core/src/java/org/apache/lucene/search/MultiCollector.java
@@ -152,7 +152,8 @@ public class MultiCollector implements Collector {
       if (cacheScores) {
         scorer = new ScoreCachingWrappingScorer(scorer);
       }
-      for (LeafCollector c : collectors) {
+      for (int i = 0; i < numCollectors; ++i) {
+        final LeafCollector c = collectors[i];
         c.setScorer(scorer);
       }
     }
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestMultiCollector.java b/lucene/core/src/test/org/apache/lucene/search/TestMultiCollector.java
index 7ba1e00..261395f 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestMultiCollector.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestMultiCollector.java
@@ -19,9 +19,12 @@ package org.apache.lucene.search;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.IndexReader;
@@ -63,6 +66,27 @@ public class TestMultiCollector extends LuceneTestCase {
     
   }
 
+  private static class SetScorerCollector extends FilterCollector {
+
+    private final AtomicBoolean setScorerCalled;
+
+    public SetScorerCollector(Collector in, AtomicBoolean setScorerCalled) {
+      super(in);
+      this.setScorerCalled = setScorerCalled;
+    }
+
+    @Override
+    public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
+      return new FilterLeafCollector(super.getLeafCollector(context)) {
+        @Override
+        public void setScorer(Scorer scorer) throws IOException {
+          super.setScorer(scorer);
+          setScorerCalled.set(true);
+        }
+      };
+    }
+  }
+
   public void testCollectionTerminatedExceptionHandling() throws IOException {
     final int iters = atLeast(3);
     for (int iter = 0; iter < iters; ++iter) {
@@ -95,4 +119,51 @@ public class TestMultiCollector extends LuceneTestCase {
     }
   }
 
+  public void testSetScorerAfterCollectionTerminated() throws IOException {
+    Collector collector1 = new TotalHitCountCollector();
+    Collector collector2 = new TotalHitCountCollector();
+
+    AtomicBoolean setScorerCalled1 = new AtomicBoolean();
+    collector1 = new SetScorerCollector(collector1, setScorerCalled1);
+    
+    AtomicBoolean setScorerCalled2 = new AtomicBoolean();
+    collector2 = new SetScorerCollector(collector2, setScorerCalled2);
+
+    collector1 = new TerminateAfterCollector(collector1, 1);
+    collector2 = new TerminateAfterCollector(collector2, 2);
+
+    Scorer scorer = new FakeScorer();
+
+    List<Collector> collectors = Arrays.asList(collector1, collector2);
+    Collections.shuffle(collectors, random());
+    Collector collector = MultiCollector.wrap(collectors);
+
+    LeafCollector leafCollector = collector.getLeafCollector(null);
+    leafCollector.setScorer(scorer);
+    assertTrue(setScorerCalled1.get());
+    assertTrue(setScorerCalled2.get());
+
+    leafCollector.collect(0);
+    leafCollector.collect(1);
+
+    setScorerCalled1.set(false);
+    setScorerCalled2.set(false);
+    leafCollector.setScorer(scorer);
+    assertFalse(setScorerCalled1.get());
+    assertTrue(setScorerCalled2.get());
+
+    try {
+      leafCollector.collect(1);
+      fail();
+    } catch (CollectionTerminatedException e) {
+      // expected
+    }
+
+    setScorerCalled1.set(false);
+    setScorerCalled2.set(false);
+    leafCollector.setScorer(scorer);
+    assertFalse(setScorerCalled1.get());
+    assertFalse(setScorerCalled2.get());
+  }
+
 }


[lucene] 13/18: LUCENE-6932: fix test bug that was not always using the dir impl being tested; fix SimpleFSIndexInput to throw EOFException if you seek beyond end of file

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 041cd9483ec082bc3848cd400c62d50092fc5016
Author: Michael McCandless <mi...@apache.org>
AuthorDate: Fri Jan 22 18:39:32 2016 +0000

    LUCENE-6932: fix test bug that was not always using the dir impl being tested; fix SimpleFSIndexInput to throw EOFException if you seek beyond end of file
    
    git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x@1726277 13f79535-47bb-0310-9956-ffa450edef68
---
 lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java | 6 +++++-
 .../src/java/org/apache/lucene/store/BaseDirectoryTestCase.java     | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java b/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
index f30b383..2daf98f 100644
--- a/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
+++ b/lucene/core/src/java/org/apache/lucene/store/SimpleFSDirectory.java
@@ -190,6 +190,10 @@ public class SimpleFSDirectory extends FSDirectory {
     }
 
     @Override
-    protected void seekInternal(long pos) throws IOException {}
+    protected void seekInternal(long pos) throws IOException {
+      if (pos > length()) {
+        throw new EOFException("read past EOF: pos=" + pos + " vs length=" + length() + ": " + this);
+      }
+    }
   }
 }
diff --git a/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
index af6b7b5..4748f37 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
@@ -1167,7 +1167,7 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
   }
 
   public void testSeekToEndOfFile() throws IOException {
-    try (Directory dir = newDirectory()) {
+    try (Directory dir = getDirectory(createTempDir())) {
       try (IndexOutput out = dir.createOutput("a", IOContext.DEFAULT)) {
         for (int i = 0; i < 1024; ++i) {
           out.writeByte((byte) 0);
@@ -1183,7 +1183,7 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
   }
 
   public void testSeekBeyondEndOfFile() throws IOException {
-    try (Directory dir = newDirectory()) {
+    try (Directory dir = getDirectory(createTempDir())) {
       try (IndexOutput out = dir.createOutput("a", IOContext.DEFAULT)) {
         for (int i = 0; i < 1024; ++i) {
           out.writeByte((byte) 0);


[lucene] 15/18: LUCENE-6932: improve exception messages; rename length parameter to sliceLength, and return it as the length, for clarity

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 3100f1b187ffaeee35dfbad1d26b5c44e5e4c1f7
Author: Michael McCandless <ma...@mikemccandless.com>
AuthorDate: Sun Jan 24 06:25:45 2016 -0500

    LUCENE-6932: improve exception messages; rename length parameter to sliceLength, and return it as the length, for clarity
---
 .../src/java/org/apache/lucene/store/RAMInputStream.java   | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java b/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
index 3e86a60..193a088 100644
--- a/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
+++ b/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
@@ -104,16 +104,16 @@ public class RAMInputStream extends IndexInput implements Cloneable {
     bufferPosition = (int) (pos % BUFFER_SIZE);
 
     // This is not >= because seeking to exact end of file is OK: this is where
-    // you'd also be if you did a readBytes of all bytes in the file)
+    // you'd also be if you did a readBytes of all bytes in the file
     if (getFilePointer() > length()) {
-      throw new EOFException("read past EOF: pos=" + getFilePointer() + " vs length=" + length() + ": " + this);
+      throw new EOFException("seek beyond EOF: pos=" + getFilePointer() + " vs length=" + length() + ": " + this);
     }
   }
 
   private void nextBuffer() throws IOException {
     // This is >= because we are called when there is at least 1 more byte to read:
     if (getFilePointer() >= length()) {
-      throw new EOFException("read past EOF: pos=" + getFilePointer() + " vs length=" + length() + ": " + this);
+      throw new EOFException("cannot read another byte at EOF: pos=" + getFilePointer() + " vs length=" + length() + ": " + this);
     }
     currentBufferIndex++;
     setCurrentBuffer();
@@ -133,11 +133,11 @@ public class RAMInputStream extends IndexInput implements Cloneable {
   }
 
   @Override
-  public IndexInput slice(String sliceDescription, final long offset, final long length) throws IOException {
-    if (offset < 0 || length < 0 || offset + length > this.length) {
+  public IndexInput slice(String sliceDescription, final long offset, final long sliceLength) throws IOException {
+    if (offset < 0 || sliceLength < 0 || offset + sliceLength > this.length) {
       throw new IllegalArgumentException("slice() " + sliceDescription + " out of bounds: "  + this);
     }
-    return new RAMInputStream(getFullSliceDescription(sliceDescription), file, offset + length) {
+    return new RAMInputStream(getFullSliceDescription(sliceDescription), file, offset + sliceLength) {
       {
         seek(0L);
       }
@@ -157,7 +157,7 @@ public class RAMInputStream extends IndexInput implements Cloneable {
 
       @Override
       public long length() {
-        return super.length() - offset;
+        return sliceLength;
       }
 
       @Override


[lucene] 11/18: LUCENE-6932: RAMInputStream now throws EOFException if you seek beyond the end of the file

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 9041c1cfe3a7162b77ba2aeb8ba58985ec167528
Author: Michael McCandless <mi...@apache.org>
AuthorDate: Thu Jan 21 18:40:02 2016 +0000

    LUCENE-6932: RAMInputStream now throws EOFException if you seek beyond the end of the file
    
    git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x@1726056 13f79535-47bb-0310-9956-ffa450edef68
    
    Conflicts:
    	lucene/CHANGES.txt
---
 lucene/CHANGES.txt                                 |  6 +-
 .../java/org/apache/lucene/store/IndexInput.java   |  5 +-
 .../org/apache/lucene/store/RAMInputStream.java    | 84 ++++++++++++----------
 .../org/apache/lucene/store/TestRAMDirectory.java  | 10 +--
 .../apache/lucene/store/BaseDirectoryTestCase.java | 46 ++++++++++--
 5 files changed, 99 insertions(+), 52 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index fa48106..9795dae 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -14,9 +14,9 @@ Bug Fixes
 * LUCENE-7019: add two-phase iteration to GeoPointTermQueryConstantScoreWrapper.
   (Robert Muir via Nick Knize)
 
-* LUCENE-6932: RAMDirectory's IndexInput should always throw
-  EOFException if you seek past the end of the file and then try to
-  read (Stéphane Campinas via Mike McCandless)
+* LUCENE-6932: RAMDirectory's IndexInput was failing to throw
+  EOFException in some cases (Stéphane Campinas, Adrien Grand via Mike
+  McCandless)
 
 ======================= Lucene 5.4.1 =======================
 
diff --git a/lucene/core/src/java/org/apache/lucene/store/IndexInput.java b/lucene/core/src/java/org/apache/lucene/store/IndexInput.java
index 6815776..02a1734 100644
--- a/lucene/core/src/java/org/apache/lucene/store/IndexInput.java
+++ b/lucene/core/src/java/org/apache/lucene/store/IndexInput.java
@@ -63,7 +63,10 @@ public abstract class IndexInput extends DataInput implements Cloneable,Closeabl
    */
   public abstract long getFilePointer();
 
-  /** Sets current position in this file, where the next read will occur.
+  /** Sets current position in this file, where the next read will occur.  If this is
+   *  beyond the end of the file then this will throw {@code EOFException} and then the
+   *  stream is in an undetermined state.
+   *
    * @see #getFilePointer()
    */
   public abstract void seek(long pos) throws IOException;
diff --git a/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java b/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
index 46d5dc1..3e86a60 100644
--- a/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
+++ b/lucene/core/src/java/org/apache/lucene/store/RAMInputStream.java
@@ -17,14 +17,15 @@ package org.apache.lucene.store;
  * limitations under the License.
  */
 
-import java.io.IOException;
 import java.io.EOFException;
+import java.io.IOException;
+
+import static org.apache.lucene.store.RAMOutputStream.BUFFER_SIZE;
 
 /** A memory-resident {@link IndexInput} implementation. 
  *  
  *  @lucene.internal */
 public class RAMInputStream extends IndexInput implements Cloneable {
-  static final int BUFFER_SIZE = RAMOutputStream.BUFFER_SIZE;
 
   private final RAMFile file;
   private final long length;
@@ -33,7 +34,6 @@ public class RAMInputStream extends IndexInput implements Cloneable {
   private int currentBufferIndex;
   
   private int bufferPosition;
-  private long bufferStart;
   private int bufferLength;
 
   public RAMInputStream(String name, RAMFile f) throws IOException {
@@ -48,10 +48,7 @@ public class RAMInputStream extends IndexInput implements Cloneable {
       throw new IOException("RAMInputStream too large length=" + length + ": " + name); 
     }
 
-    // make sure that we switch to the
-    // first needed buffer lazily
-    currentBufferIndex = -1;
-    currentBuffer = null;
+    setCurrentBuffer();
   }
 
   @Override
@@ -66,9 +63,8 @@ public class RAMInputStream extends IndexInput implements Cloneable {
 
   @Override
   public byte readByte() throws IOException {
-    if (bufferPosition >= bufferLength) {
-      currentBufferIndex++;
-      switchCurrentBuffer(true);
+    if (bufferPosition == bufferLength) {
+      nextBuffer();
     }
     return currentBuffer[bufferPosition++];
   }
@@ -76,9 +72,9 @@ public class RAMInputStream extends IndexInput implements Cloneable {
   @Override
   public void readBytes(byte[] b, int offset, int len) throws IOException {
     while (len > 0) {
-      if (bufferPosition >= bufferLength) {
-        currentBufferIndex++;
-        switchCurrentBuffer(true);
+
+      if (bufferPosition == bufferLength) {
+        nextBuffer();
       }
 
       int remainInBuffer = bufferLength - bufferPosition;
@@ -90,39 +86,49 @@ public class RAMInputStream extends IndexInput implements Cloneable {
     }
   }
 
-  private final void switchCurrentBuffer(boolean enforceEOF) throws IOException {
-    bufferStart = (long) BUFFER_SIZE * (long) currentBufferIndex;
-    if (bufferStart > length || currentBufferIndex >= file.numBuffers()) {
-      // end of file reached, no more buffers left
-      if (enforceEOF) {
-        throw new EOFException("read past EOF: " + this);
-      } else {
-        // Force EOF if a read later takes place at this position
-        currentBufferIndex--;
-        bufferPosition = BUFFER_SIZE;
-      }
-    } else {
-      currentBuffer = file.getBuffer(currentBufferIndex);
-      bufferPosition = 0;
-      long buflen = length - bufferStart;
-      bufferLength = buflen > BUFFER_SIZE ? BUFFER_SIZE : (int) buflen;
-    }
-  }
-
   @Override
   public long getFilePointer() {
-    return currentBufferIndex < 0 ? 0 : bufferStart + bufferPosition;
+    return (long) currentBufferIndex * BUFFER_SIZE + bufferPosition;
   }
 
   @Override
   public void seek(long pos) throws IOException {
-    if (currentBuffer == null || pos < bufferStart || pos >= bufferStart + BUFFER_SIZE) {
-      currentBufferIndex = (int) (pos / BUFFER_SIZE);
-      switchCurrentBuffer(false);
+    int newBufferIndex = (int) (pos / BUFFER_SIZE);
+
+    if (newBufferIndex != currentBufferIndex) {
+      // we seek'd to a different buffer:
+      currentBufferIndex = newBufferIndex;
+      setCurrentBuffer();
     }
-    if (pos < BUFFER_SIZE * (long) file.numBuffers()) {
-      // do not overwrite bufferPosition if EOF should be thrown on the next read
-      bufferPosition = (int) (pos % BUFFER_SIZE);
+
+    bufferPosition = (int) (pos % BUFFER_SIZE);
+
+    // This is not >= because seeking to exact end of file is OK: this is where
+    // you'd also be if you did a readBytes of all bytes in the file)
+    if (getFilePointer() > length()) {
+      throw new EOFException("read past EOF: pos=" + getFilePointer() + " vs length=" + length() + ": " + this);
+    }
+  }
+
+  private void nextBuffer() throws IOException {
+    // This is >= because we are called when there is at least 1 more byte to read:
+    if (getFilePointer() >= length()) {
+      throw new EOFException("read past EOF: pos=" + getFilePointer() + " vs length=" + length() + ": " + this);
+    }
+    currentBufferIndex++;
+    setCurrentBuffer();
+    assert currentBuffer != null;
+    bufferPosition = 0;
+  }
+
+  private final void setCurrentBuffer() throws IOException {
+    if (currentBufferIndex < file.numBuffers()) {
+      currentBuffer = file.getBuffer(currentBufferIndex);
+      assert currentBuffer != null;
+      long bufferStart = (long) BUFFER_SIZE * (long) currentBufferIndex;
+      bufferLength = (int) Math.min(BUFFER_SIZE, length - bufferStart);
+    } else {
+      currentBuffer = null;
     }
   }
 
diff --git a/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java b/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java
index 30ceba5..70cd054 100644
--- a/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java
+++ b/lucene/core/src/test/org/apache/lucene/store/TestRAMDirectory.java
@@ -21,7 +21,6 @@ import java.io.EOFException;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Random;
@@ -152,10 +151,12 @@ public class TestRAMDirectory extends BaseDirectoryTestCase {
         }
       };
     }
-    for (int i=0; i<numThreads; i++)
+    for (int i=0; i<numThreads; i++) {
       threads[i].start();
-    for (int i=0; i<numThreads; i++)
+    }
+    for (int i=0; i<numThreads; i++) {
       threads[i].join();
+    }
 
     writer.forceMerge(1);
     assertEquals(ramDir.sizeInBytes(), ramDir.getRecomputedSizeInBytes());
@@ -188,4 +189,5 @@ public class TestRAMDirectory extends BaseDirectoryTestCase {
         }
       }
     }
-  }}
+  }
+}
diff --git a/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
index 4650ac2..af6b7b5 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
@@ -586,15 +586,15 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
     Directory dir = getDirectory(createTempDir("testSeekToEOFThenBack"));
 
     IndexOutput o = dir.createOutput("out", newIOContext(random()));
-    byte[] bytes = new byte[3*RAMInputStream.BUFFER_SIZE];
+    byte[] bytes = new byte[3*RAMOutputStream.BUFFER_SIZE];
     o.writeBytes(bytes, 0, bytes.length);
     o.close();
 
     IndexInput i = dir.openInput("out", newIOContext(random()));
-    i.seek(2*RAMInputStream.BUFFER_SIZE-1);
-    i.seek(3*RAMInputStream.BUFFER_SIZE);
-    i.seek(RAMInputStream.BUFFER_SIZE);
-    i.readBytes(bytes, 0, 2*RAMInputStream.BUFFER_SIZE);
+    i.seek(2*RAMOutputStream.BUFFER_SIZE-1);
+    i.seek(3*RAMOutputStream.BUFFER_SIZE);
+    i.seek(RAMOutputStream.BUFFER_SIZE);
+    i.readBytes(bytes, 0, 2*RAMOutputStream.BUFFER_SIZE);
     i.close();
     dir.close();
   }
@@ -1165,4 +1165,40 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
     in.close(); // close again
     dir.close();
   }
+
+  public void testSeekToEndOfFile() throws IOException {
+    try (Directory dir = newDirectory()) {
+      try (IndexOutput out = dir.createOutput("a", IOContext.DEFAULT)) {
+        for (int i = 0; i < 1024; ++i) {
+          out.writeByte((byte) 0);
+        }
+      }
+      try (IndexInput in = dir.openInput("a", IOContext.DEFAULT)) {
+        in.seek(100);
+        assertEquals(100, in.getFilePointer());
+        in.seek(1024);
+        assertEquals(1024, in.getFilePointer());
+      }
+    }
+  }
+
+  public void testSeekBeyondEndOfFile() throws IOException {
+    try (Directory dir = newDirectory()) {
+      try (IndexOutput out = dir.createOutput("a", IOContext.DEFAULT)) {
+        for (int i = 0; i < 1024; ++i) {
+          out.writeByte((byte) 0);
+        }
+      }
+      try (IndexInput in = dir.openInput("a", IOContext.DEFAULT)) {
+        in.seek(100);
+        assertEquals(100, in.getFilePointer());
+        try {
+          in.seek(1025);
+          fail("didn't hit expected exception");
+        } catch (EOFException eofe) {
+          // expected
+        }
+      }
+    }
+  }
 }


[lucene] 16/18: LUCENE-6998: fix a couple places to better detect truncated index files; improve corruption testing

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit df30bc6c5b4855fcd95c3660fdd2991d0e9c58bf
Author: Mike McCandless <mi...@apache.org>
AuthorDate: Thu Jan 28 05:01:15 2016 -0500

    LUCENE-6998: fix a couple places to better detect truncated index files; improve corruption testing
    
    Conflicts:
    	lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointFormat.java
    	lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointReader.java
    	lucene/core/src/java/org/apache/lucene/codecs/lucene60/Lucene60PointWriter.java
    
    Conflicts:
    	lucene/CHANGES.txt
---
 lucene/CHANGES.txt                                 |   3 +
 .../java/org/apache/lucene/codecs/CodecUtil.java   |   4 +-
 .../codecs/lucene50/Lucene50CompoundReader.java    |  14 +++
 .../lucene/index/TestAllFilesCheckIndexHeader.java | 132 +++++++++++++++++++++
 .../lucene/index/TestAllFilesDetectTruncation.java | 127 ++++++++++++++++++++
 .../index/TestAllFilesHaveChecksumFooter.java      |  24 ++--
 .../lucene/index/TestAllFilesHaveCodecHeader.java  |  31 ++---
 .../apache/lucene/index/TestSwappedIndexFiles.java | 127 ++++++++++++++++++++
 8 files changed, 422 insertions(+), 40 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 9795dae..c93d601 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -18,6 +18,9 @@ Bug Fixes
   EOFException in some cases (Stéphane Campinas, Adrien Grand via Mike
   McCandless)
 
+* LUCENE-6998: Fix a couple places to better detect truncated index files
+  as corruption.  (Robert Muir, Mike McCandless)
+
 ======================= Lucene 5.4.1 =======================
 
 Bug Fixes
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java b/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java
index ca6497a..3ca7569 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java
@@ -17,7 +17,6 @@ package org.apache.lucene.codecs;
  * limitations under the License.
  */
 
-
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
@@ -397,6 +396,9 @@ public final class CodecUtil {
    * @throws IOException if the footer is invalid
    */
   public static long retrieveChecksum(IndexInput in) throws IOException {
+    if (in.length() < footerLength()) {
+      throw new CorruptIndexException("misplaced codec footer (file truncated?): length=" + in.length() + " but footerLength==" + footerLength(), in);
+    }
     in.seek(in.length() - footerLength());
     validateFooter(in);
     return readCRC(in);
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java
index 5c14b86..99df7f2 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java
@@ -68,6 +68,13 @@ final class Lucene50CompoundReader extends Directory {
     String entriesFileName = IndexFileNames.segmentFileName(segmentName, "", Lucene50CompoundFormat.ENTRIES_EXTENSION);
     this.entries = readEntries(si.getId(), directory, entriesFileName);
     boolean success = false;
+
+    long expectedLength = CodecUtil.indexHeaderLength(Lucene50CompoundFormat.DATA_CODEC, "");
+    for(Map.Entry<String,FileEntry> ent : entries.entrySet()) {
+      expectedLength += ent.getValue().length;
+    }
+    expectedLength += CodecUtil.footerLength(); 
+
     handle = directory.openInput(dataFileName, context);
     try {
       CodecUtil.checkIndexHeader(handle, Lucene50CompoundFormat.DATA_CODEC, version, version, si.getId(), "");
@@ -77,6 +84,13 @@ final class Lucene50CompoundReader extends Directory {
       // for FOOTER_MAGIC + algorithmID. This is cheap and can detect some forms of corruption
       // such as file truncation.
       CodecUtil.retrieveChecksum(handle);
+
+      // We also validate length, because e.g. if you strip 16 bytes off the .cfs we otherwise
+      // would not detect it:
+      if (handle.length() != expectedLength) {
+        throw new CorruptIndexException("length should be " + expectedLength + " bytes, but is " + handle.length() + " instead", handle);
+      }
+
       success = true;
     } finally {
       if (!success) {
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesCheckIndexHeader.java b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesCheckIndexHeader.java
new file mode 100644
index 0000000..9dffaa8
--- /dev/null
+++ b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesCheckIndexHeader.java
@@ -0,0 +1,132 @@
+package org.apache.lucene.index;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.util.Collections;
+
+import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.store.BaseDirectoryWrapper;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.IOContext;
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.IndexOutput;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.util.LineFileDocs;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
+
+/**
+ * Test that a plain default detects broken index headers early (on opening a reader).
+ */
+public class TestAllFilesCheckIndexHeader extends LuceneTestCase {
+  public void test() throws Exception {
+    Directory dir = newDirectory();
+
+    if (dir instanceof MockDirectoryWrapper) {
+      // otherwise we can have unref'd files left in the index that won't be visited when opening a reader and lead to scary looking false failures:
+      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
+    }
+
+    IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
+    conf.setCodec(TestUtil.getDefaultCodec());
+
+    // Disable CFS 80% of the time so we can truncate individual files, but the other 20% of the time we test truncation of .cfs/.cfe too:
+    if (random().nextInt(5) != 1) {
+      conf.setUseCompoundFile(false);
+      conf.getMergePolicy().setNoCFSRatio(0.0);
+    }
+
+    RandomIndexWriter riw = new RandomIndexWriter(random(), dir, conf);
+    // Use LineFileDocs so we (hopefully) get most Lucene features
+    // tested, e.g. IntPoint was recently added to it:
+    LineFileDocs docs = new LineFileDocs(random());
+    for (int i = 0; i < 100; i++) {
+      riw.addDocument(docs.nextDoc());
+      if (random().nextInt(7) == 0) {
+        riw.commit();
+      }
+      if (random().nextInt(20) == 0) {
+        riw.deleteDocuments(new Term("docid", Integer.toString(i)));
+      }
+      if (random().nextInt(15) == 0) {
+        riw.updateNumericDocValue(new Term("docid", Integer.toString(i)), "docid_intDV", Long.valueOf(i));
+      }
+    }
+
+    if (TEST_NIGHTLY == false) {
+      riw.forceMerge(1);
+    }
+    riw.close();
+    checkIndexHeader(dir);
+    dir.close();
+  }
+  
+  private void checkIndexHeader(Directory dir) throws IOException {
+    for(String name : dir.listAll()) {
+      checkOneFile(dir, name);
+    }
+  }
+  
+  private void checkOneFile(Directory dir, String victim) throws IOException {
+    try (BaseDirectoryWrapper dirCopy = newDirectory()) {
+      dirCopy.setCheckIndexOnClose(false);
+      long victimLength = dir.fileLength(victim);
+      int wrongBytes = TestUtil.nextInt(random(), 1, (int) Math.min(100, victimLength));
+      assert victimLength > 0;
+
+      if (VERBOSE) {
+        System.out.println("TEST: now break file " + victim + " by randomizing first " + wrongBytes + " of " + victimLength);
+      }
+
+      for(String name : dir.listAll()) {
+        if (name.equals(victim) == false) {
+          dirCopy.copyFrom(dir, name, name, IOContext.DEFAULT);
+        } else {
+          try(IndexOutput out = dirCopy.createOutput(name, IOContext.DEFAULT);
+              IndexInput in = dir.openInput(name, IOContext.DEFAULT)) {
+              // keeps same file length, but replaces the first wrongBytes with random bytes:
+              byte[] bytes = new byte[wrongBytes];
+              random().nextBytes(bytes);
+              out.writeBytes(bytes, 0, bytes.length);
+              in.seek(wrongBytes);
+              out.copyBytes(in, victimLength - wrongBytes);
+            }
+        }
+        dirCopy.sync(Collections.singleton(name));
+      }
+
+      try {
+        // NOTE: we .close so that if the test fails (truncation not detected) we don't also get all these confusing errors about open files:
+        DirectoryReader.open(dirCopy).close();
+        fail("wrong bytes not detected after randomizing first " + wrongBytes + " bytes out of " + victimLength + " for file " + victim);
+      } catch (CorruptIndexException | EOFException | IndexFormatTooOldException e) {
+        // expected
+      }
+
+      // CheckIndex should also fail:
+      try {
+        TestUtil.checkIndex(dirCopy, true, true);
+        fail("wrong bytes not detected after randomizing first " + wrongBytes + " bytes out of " + victimLength + " for file " + victim);
+      } catch (CorruptIndexException | EOFException | IndexFormatTooOldException e) {
+        // expected
+      }
+    }
+  }
+}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesDetectTruncation.java b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesDetectTruncation.java
new file mode 100644
index 0000000..bda5857
--- /dev/null
+++ b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesDetectTruncation.java
@@ -0,0 +1,127 @@
+package org.apache.lucene.index;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+
+import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.store.BaseDirectoryWrapper;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.IOContext;
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.IndexOutput;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.util.LineFileDocs;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
+
+/**
+ * Test that a plain default detects index file truncation early (on opening a reader).
+ */
+public class TestAllFilesDetectTruncation extends LuceneTestCase {
+  public void test() throws Exception {
+    Directory dir = newDirectory();
+
+    if (dir instanceof MockDirectoryWrapper) {
+      // otherwise we can have unref'd files left in the index that won't be visited when opening a reader and lead to scary looking false failures:
+      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
+    }
+
+    IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
+    conf.setCodec(TestUtil.getDefaultCodec());
+
+    // Disable CFS 80% of the time so we can truncate individual files, but the other 20% of the time we test truncation of .cfs/.cfe too:
+    if (random().nextInt(5) != 1) {
+      conf.setUseCompoundFile(false);
+      conf.getMergePolicy().setNoCFSRatio(0.0);
+    }
+
+    RandomIndexWriter riw = new RandomIndexWriter(random(), dir, conf);
+    // Use LineFileDocs so we (hopefully) get most Lucene features
+    // tested, e.g. IntPoint was recently added to it:
+    LineFileDocs docs = new LineFileDocs(random());
+    for (int i = 0; i < 100; i++) {
+      riw.addDocument(docs.nextDoc());
+      if (random().nextInt(7) == 0) {
+        riw.commit();
+      }
+      if (random().nextInt(20) == 0) {
+        riw.deleteDocuments(new Term("docid", Integer.toString(i)));
+      }
+      if (random().nextInt(15) == 0) {
+        riw.updateNumericDocValue(new Term("docid", Integer.toString(i)), "docid_intDV", Long.valueOf(i));
+      }
+    }
+    if (TEST_NIGHTLY == false) {
+      riw.forceMerge(1);
+    }
+    riw.close();
+    checkTruncation(dir);
+    dir.close();
+  }
+  
+  private void checkTruncation(Directory dir) throws IOException {
+    for(String name : dir.listAll()) {
+      truncateOneFile(dir, name);
+    }
+  }
+  
+  private void truncateOneFile(Directory dir, String victim) throws IOException {
+    try (BaseDirectoryWrapper dirCopy = newDirectory()) {
+      dirCopy.setCheckIndexOnClose(false);
+      long victimLength = dir.fileLength(victim);
+      int lostBytes = TestUtil.nextInt(random(), 1, (int) Math.min(100, victimLength));
+      assert victimLength > 0;
+
+      if (VERBOSE) {
+        System.out.println("TEST: now truncate file " + victim + " by removing " + lostBytes + " of " + victimLength + " bytes");
+      }
+
+      for(String name : dir.listAll()) {
+        if (name.equals(victim) == false) {
+          dirCopy.copyFrom(dir, name, name, IOContext.DEFAULT);
+        } else {
+          try(IndexOutput out = dirCopy.createOutput(name, IOContext.DEFAULT);
+              IndexInput in = dir.openInput(name, IOContext.DEFAULT)) {
+              out.copyBytes(in, victimLength - lostBytes);
+            }
+        }
+        dirCopy.sync(Collections.singleton(name));
+      }
+
+      try {
+        // NOTE: we .close so that if the test fails (truncation not detected) we don't also get all these confusing errors about open files:
+        DirectoryReader.open(dirCopy).close();
+        fail("truncation not detected after removing " + lostBytes + " bytes out of " + victimLength + " for file " + victim);
+      } catch (CorruptIndexException | EOFException e) {
+        // expected
+      }
+
+      // CheckIndex should also fail:
+      try {
+        TestUtil.checkIndex(dirCopy, true, true);
+        fail("truncation not detected after removing " + lostBytes + " bytes out of " + victimLength + " for file " + victim);
+      } catch (CorruptIndexException | EOFException e) {
+        // expected
+      }
+    }
+  }
+}
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveChecksumFooter.java b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveChecksumFooter.java
index 66eb343..710d20f 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveChecksumFooter.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveChecksumFooter.java
@@ -21,11 +21,9 @@ import java.io.IOException;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.codecs.CodecUtil;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.NumericDocValuesField;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
 
@@ -38,23 +36,19 @@ public class TestAllFilesHaveChecksumFooter extends LuceneTestCase {
     IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
     conf.setCodec(TestUtil.getDefaultCodec());
     RandomIndexWriter riw = new RandomIndexWriter(random(), dir, conf);
-    Document doc = new Document();
-    // these fields should sometimes get term vectors, etc
-    Field idField = newStringField("id", "", Field.Store.NO);
-    Field bodyField = newTextField("body", "", Field.Store.NO);
-    Field dvField = new NumericDocValuesField("dv", 5);
-    doc.add(idField);
-    doc.add(bodyField);
-    doc.add(dvField);
+    // Use LineFileDocs so we (hopefully) get most Lucene features
+    // tested, e.g. IntPoint was recently added to it:
+    LineFileDocs docs = new LineFileDocs(random());
     for (int i = 0; i < 100; i++) {
-      idField.setStringValue(Integer.toString(i));
-      bodyField.setStringValue(TestUtil.randomUnicodeString(random()));
-      riw.addDocument(doc);
+      riw.addDocument(docs.nextDoc());
       if (random().nextInt(7) == 0) {
         riw.commit();
       }
       if (random().nextInt(20) == 0) {
-        riw.deleteDocuments(new Term("id", Integer.toString(i)));
+        riw.deleteDocuments(new Term("docid", Integer.toString(i)));
+      }
+      if (random().nextInt(15) == 0) {
+        riw.updateNumericDocValue(new Term("docid", Integer.toString(i)), "docid_intDV", Long.valueOf(i));
       }
     }
     riw.close();
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java
index c2b515d..d726019 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestAllFilesHaveCodecHeader.java
@@ -23,13 +23,9 @@ import java.util.Map;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.codecs.CodecUtil;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.document.TextField;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
 
@@ -43,32 +39,19 @@ public class TestAllFilesHaveCodecHeader extends LuceneTestCase {
     IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
     conf.setCodec(TestUtil.getDefaultCodec());
     RandomIndexWriter riw = new RandomIndexWriter(random(), dir, conf);
-    Document doc = new Document();
-    Field idField = newStringField("id", "", Field.Store.YES);
-    Field bodyField = newTextField("body", "", Field.Store.YES);
-    FieldType vectorsType = new FieldType(TextField.TYPE_STORED);
-    vectorsType.setStoreTermVectors(true);
-    vectorsType.setStoreTermVectorPositions(true);
-    Field vectorsField = new Field("vectors", "", vectorsType);
-    Field dvField = new NumericDocValuesField("dv", 5);
-    doc.add(idField);
-    doc.add(bodyField);
-    doc.add(vectorsField);
-    doc.add(dvField);
+    // Use LineFileDocs so we (hopefully) get most Lucene features
+    // tested, e.g. IntPoint was recently added to it:
+    LineFileDocs docs = new LineFileDocs(random());
     for (int i = 0; i < 100; i++) {
-      idField.setStringValue(Integer.toString(i));
-      bodyField.setStringValue(TestUtil.randomUnicodeString(random()));
-      dvField.setLongValue(random().nextInt(5));
-      vectorsField.setStringValue(TestUtil.randomUnicodeString(random()));
-      riw.addDocument(doc);
+      riw.addDocument(docs.nextDoc());
       if (random().nextInt(7) == 0) {
         riw.commit();
       }
       if (random().nextInt(20) == 0) {
-        riw.deleteDocuments(new Term("id", Integer.toString(i)));
+        riw.deleteDocuments(new Term("docid", Integer.toString(i)));
       }
       if (random().nextInt(15) == 0) {
-        riw.updateNumericDocValue(new Term("id"), "dv", Long.valueOf(i));
+        riw.updateNumericDocValue(new Term("docid", Integer.toString(i)), "docid_intDV", Long.valueOf(i));
       }
     }
     riw.close();
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestSwappedIndexFiles.java b/lucene/core/src/test/org/apache/lucene/index/TestSwappedIndexFiles.java
new file mode 100644
index 0000000..008e9a6
--- /dev/null
+++ b/lucene/core/src/test/org/apache/lucene/index/TestSwappedIndexFiles.java
@@ -0,0 +1,127 @@
+package org.apache.lucene.index;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Random;
+
+import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.store.BaseDirectoryWrapper;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.IOContext;
+import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.util.LineFileDocs;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
+
+/**
+ * Test that the same file name, but from a different index, is detected as foreign.
+ */
+public class TestSwappedIndexFiles extends LuceneTestCase {
+  public void test() throws Exception {
+    Directory dir1 = newDirectory();
+    Directory dir2 = newDirectory();
+
+    if (dir1 instanceof MockDirectoryWrapper) {
+      // otherwise we can have unref'd files left in the index that won't be visited when opening a reader and lead to scary looking false failures:
+      ((MockDirectoryWrapper) dir1).setEnableVirusScanner(false);
+    }
+    if (dir2 instanceof MockDirectoryWrapper) {
+      // otherwise we can have unref'd files left in the index that won't be visited when opening a reader and lead to scary looking false failures:
+      ((MockDirectoryWrapper) dir2).setEnableVirusScanner(false);
+    }
+
+    // Disable CFS 80% of the time so we can truncate individual files, but the other 20% of the time we test truncation of .cfs/.cfe too:
+    boolean useCFS = random().nextInt(5) == 1;
+
+    // Use LineFileDocs so we (hopefully) get most Lucene features
+    // tested, e.g. IntPoint was recently added to it:
+    LineFileDocs docs = new LineFileDocs(random());
+    Document doc = docs.nextDoc();
+    long seed = random().nextLong();
+
+    indexOneDoc(seed, dir1, doc, useCFS);
+    indexOneDoc(seed, dir2, doc, useCFS);
+
+    swapFiles(dir1, dir2);
+    dir1.close();
+    dir2.close();
+  }
+
+  private void indexOneDoc(long seed, Directory dir, Document doc, boolean useCFS) throws IOException {
+    Random random = new Random(seed);
+    IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random));
+    conf.setCodec(TestUtil.getDefaultCodec());
+
+    if (useCFS == false) {
+      conf.setUseCompoundFile(false);
+      conf.getMergePolicy().setNoCFSRatio(0.0);
+    } else {
+      conf.setUseCompoundFile(true);
+      conf.getMergePolicy().setNoCFSRatio(1.0);
+    }
+
+    RandomIndexWriter w = new RandomIndexWriter(random, dir, conf);
+    w.addDocument(doc);
+    w.close();
+  }
+  
+  private void swapFiles(Directory dir1, Directory dir2) throws IOException {
+    for(String name : dir1.listAll()) {
+      if (name.equals(IndexWriter.WRITE_LOCK_NAME)) {
+        continue;
+      }
+      swapOneFile(dir1, dir2, name);
+    }
+  }
+  
+  private void swapOneFile(Directory dir1, Directory dir2, String victim) throws IOException {
+    try (BaseDirectoryWrapper dirCopy = newDirectory()) {
+      dirCopy.setCheckIndexOnClose(false);
+
+      // Copy all files from dir1 to dirCopy, except victim which we copy from dir2:
+      for(String name : dir1.listAll()) {
+        if (name.equals(victim) == false) {
+          dirCopy.copyFrom(dir1, name, name, IOContext.DEFAULT);
+        } else {
+          dirCopy.copyFrom(dir2, name, name, IOContext.DEFAULT);
+        }
+        dirCopy.sync(Collections.singleton(name));
+      }
+
+      try {
+        // NOTE: we .close so that if the test fails (truncation not detected) we don't also get all these confusing errors about open files:
+        DirectoryReader.open(dirCopy).close();
+        fail("wrong file " + victim + " not detected");
+      } catch (CorruptIndexException | EOFException | IndexFormatTooOldException e) {
+        // expected
+      }
+
+      // CheckIndex should also fail:
+      try {
+        TestUtil.checkIndex(dirCopy, true, true);
+        fail("wrong file " + victim + " not detected");
+      } catch (CorruptIndexException | EOFException | IndexFormatTooOldException e) {
+        // expected
+      }
+    }
+  }
+}


[lucene] 09/18: LUCENE-7019: add two-phase iteration to GeoPointTermQueryConstantScoreWrapper

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit b8f57232f2d3ea2304b530f10576922a665786b2
Author: nknize <nk...@apache.org>
AuthorDate: Tue Feb 9 14:46:52 2016 -0600

    LUCENE-7019: add two-phase iteration to GeoPointTermQueryConstantScoreWrapper
---
 lucene/CHANGES.txt                                 |  3 +
 .../GeoPointTermQueryConstantScoreWrapper.java     | 83 ++++++++++++----------
 2 files changed, 50 insertions(+), 36 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index fa3eab3..d3fa220 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -11,6 +11,9 @@ Bug Fixes
 * LUCENE-7018: Fix GeoPointTermQueryConstantScoreWrapper to add document on
   first GeoPointField match. (Nick Knize)
 
+* LUCENE-7019: add two-phase iteration to GeoPointTermQueryConstantScoreWrapper.
+  (Robert Muir via Nick Knize)
+
 ======================= Lucene 5.4.1 =======================
 
 Bug Fixes
diff --git a/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java b/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java
index e9099ac..0a18796 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/search/GeoPointTermQueryConstantScoreWrapper.java
@@ -24,8 +24,11 @@ import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.PostingsEnum;
 import org.apache.lucene.index.SortedNumericDocValues;
 import org.apache.lucene.index.Terms;
+import org.apache.lucene.util.BitSet;
 import org.apache.lucene.util.DocIdSetBuilder;
+import org.apache.lucene.util.FixedBitSet;
 import org.apache.lucene.util.GeoUtils;
+import org.apache.lucene.util.SparseFixedBitSet;
 
 /**
  * Custom ConstantScoreWrapper for {@code GeoPointTermQuery} that cuts over to DocValues
@@ -63,10 +66,11 @@ final class GeoPointTermQueryConstantScoreWrapper <Q extends GeoPointTermQuery>
   public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
     return new ConstantScoreWeight(this) {
 
-      private DocIdSet getDocIDs(LeafReaderContext context) throws IOException {
+      @Override
+      public Scorer scorer(LeafReaderContext context) throws IOException {
         final Terms terms = context.reader().terms(query.field);
         if (terms == null) {
-          return DocIdSet.EMPTY;
+          return null;
         }
 
         final GeoPointTermsEnum termsEnum = (GeoPointTermsEnum)(query.getTermsEnum(terms));
@@ -74,56 +78,63 @@ final class GeoPointTermQueryConstantScoreWrapper <Q extends GeoPointTermQuery>
 
         LeafReader reader = context.reader();
         DocIdSetBuilder builder = new DocIdSetBuilder(reader.maxDoc());
+        // subset of documents that need no postfiltering, this is purely an optimization
+        final BitSet preApproved;
+        // dumb heuristic: if the field is really sparse, use a sparse impl
+        if (terms.getDocCount() * 100L < reader.maxDoc()) {
+          preApproved = new SparseFixedBitSet(reader.maxDoc());
+        } else {
+          preApproved = new FixedBitSet(reader.maxDoc());
+        }
         PostingsEnum docs = null;
-        SortedNumericDocValues sdv = reader.getSortedNumericDocValues(query.field);
 
         while (termsEnum.next() != null) {
           docs = termsEnum.postings(docs, PostingsEnum.NONE);
           // boundary terms need post filtering by
           if (termsEnum.boundaryTerm()) {
-            int docId = docs.nextDoc();
-            long hash;
-            do {
-              sdv.setDocument(docId);
-              for (int i=0; i<sdv.count(); ++i) {
-                hash = sdv.valueAt(i);
-                if (termsEnum.postFilter(GeoUtils.mortonUnhashLon(hash), GeoUtils.mortonUnhashLat(hash))) {
-                  builder.add(docId);
-                  break;
-                }
-              }
-            } while ((docId = docs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS);
-          } else {
             builder.add(docs);
+          } else {
+            int docId;
+            while ((docId = docs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
+              builder.add(docId);
+              preApproved.set(docId);
+            }
           }
         }
 
-        return builder.build();
-      }
-
-      private Scorer scorer(DocIdSet set) throws IOException {
-        if (set == null) {
-          return null;
-        }
+        DocIdSet set = builder.build();
         final DocIdSetIterator disi = set.iterator();
         if (disi == null) {
           return null;
         }
-        return new ConstantScoreScorer(this, score(), disi);
-      }
 
-      @Override
-      public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
-        final Scorer scorer = scorer(getDocIDs(context));
-        if (scorer == null) {
-          return null;
-        }
-        return new DefaultBulkScorer(scorer);
-      }
+        // return two-phase iterator using docvalues to postfilter candidates
+        final SortedNumericDocValues sdv = reader.getSortedNumericDocValues(query.getField());
+        TwoPhaseIterator iterator = new TwoPhaseIterator(disi) {
+          @Override
+          public boolean matches() throws IOException {
+            int docId = disi.docID();
+            if (preApproved.get(docId)) {
+              return true;
+            } else {
+              sdv.setDocument(docId);
+              int count = sdv.count();
+              for (int i = 0; i < count; i++) {
+                long hash = sdv.valueAt(i);
+                if (termsEnum.postFilter(GeoUtils.mortonUnhashLon(hash), GeoUtils.mortonUnhashLat(hash))) {
+                  return true;
+                }
+              }
+              return false;
+            }
+          }
 
-      @Override
-      public Scorer scorer(LeafReaderContext context) throws IOException {
-        return scorer(getDocIDs(context));
+          @Override
+          public float matchCost() {
+            return 20; // TODO: make this fancier
+          }
+        };
+        return new ConstantScoreScorer(this, score(), iterator);
       }
     };
   }


[lucene] 03/18: LUCENE-6938: Fix Lucene's src.tgz file; remove svnkit stuff

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit f4b228b34174e87b1ed43e330b500d8b795604ca
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Sat Jan 23 13:47:14 2016 +0100

    LUCENE-6938: Fix Lucene's src.tgz file; remove svnkit stuff
---
 build.xml        | 121 +++----------------------------------------------------
 lucene/build.xml |  11 +++--
 solr/build.xml   |   2 +-
 3 files changed, 14 insertions(+), 120 deletions(-)

diff --git a/build.xml b/build.xml
index 486f793..4448841 100644
--- a/build.xml
+++ b/build.xml
@@ -20,8 +20,6 @@
 <project name="lucene-solr" default="-projecthelp" basedir=".">
   <import file="lucene/common-build.xml"/>
 
-  <property name="svnkit.version" value="1.8.10"/>
-
   <property name="tests.heap-dump-dir" location="heapdumps"/>
   
   <property name="maven-build-dir" value="maven-build"/>
@@ -45,7 +43,7 @@
   </target>
 
   <target name="precommit" description="Run basic checks before committing"
-          depends="check-svn-working-copy,validate,documentation-lint"/>
+          depends="check-working-copy,validate,documentation-lint"/>
 
   <target name="test" description="Test both Lucene and Solr" depends="resolve-groovy">
     <mkdir dir="lucene/build" />
@@ -561,115 +559,8 @@ File | Project Structure | Platform Settings | SDKs):
     <delete dir="${smokeTestRelease.tmp}"/>
   </target>
   
-  <macrodef xmlns:ivy="antlib:org.apache.ivy.ant" name="svn-checker">
-    <attribute name="failonmodifications" default="true"/> <!-- false if file modifications are allowed -->
-    <sequential>
-      <ivy:cachepath organisation="org.tmatesoft.svnkit" module="svnkit" revision="${svnkit.version}"
-        inline="true" conf="default" transitive="true" pathid="svnkit.classpath"/>
-      <local name="svn.checkprops.failed"/>
-      <local name="svn.unversioned.failed"/>
-      <local name="svn.keywords.failed"/>
-      <local name="svn.changed.failed"/>
-      <groovy taskname="svn" classpathref="svnkit.classpath"><![CDATA[
-        import org.tmatesoft.svn.core.*;
-        import org.tmatesoft.svn.core.wc.*;
-        import org.apache.tools.ant.Project;
-        
-        SVNClientManager manager = SVNClientManager.newInstance();
-        SVNStatusClient statusClient = manager.getStatusClient();
-        SVNWCClient wcClient = manager.getWCClient();
-        
-        File basedir = new File(properties['basedir']).getAbsoluteFile();
-        int baseLen = basedir.toString().length();
-
-        // do some fake check, to verify if this is valid SVN working copy. If this fails ignore checks but log some useful message.
-        task.log('Initializing working copy...');
-        try {
-          wcClient.doInfo(basedir, SVNRevision.WORKING);
-        } catch (SVNException ex) {
-          def ec = ex.getErrorMessage().getErrorCode();
-          int code = ec.getCode();
-          int category = ec.getCategory();
-          if (code == SVNErrorCode.WC_NOT_DIRECTORY.getCode() || code == SVNErrorCode.WC_NOT_FILE.getCode()) {
-            task.log('WARNING: Development directory is not an SVN checkout! Disabling checks...', Project.MSG_WARN);
-            return;
-          } else if (category == SVNErrorCode.WC_CATEGORY) {
-            task.log('WARNING: Development directory is not a valid SVN checkout (' + ex.getErrorMessage() + '). Disabling checks...', Project.MSG_WARN);
-            return;
-          } else {
-            throw ex;
-          }
-        }
-        
-        def convertRelative = {
-          file -> '.' + file.getAbsolutePath().substring(baseLen).replace(File.separatorChar, (char)'/');
-        }
-
-        Set missingProps = new TreeSet(), withKeywords = new TreeSet(), unversioned = new TreeSet(), changed = new TreeSet();
-
-        task.log('Getting all versioned and unversioned files...');
-        statusClient.doStatus(basedir, SVNRevision.WORKING, SVNDepth.fromRecurse(true), false, true, false, false, {
-          status ->
-          SVNStatusType nodeStatus = status.getNodeStatus();
-          if (nodeStatus == SVNStatusType.STATUS_UNVERSIONED || nodeStatus == SVNStatusType.STATUS_MISSING) {
-            unversioned.add(convertRelative(status.getFile()));
-          } else if (status.getKind() == SVNNodeKind.FILE && nodeStatus != SVNStatusType.STATUS_DELETED) {
-            missingProps.add(convertRelative(status.getFile()));
-          }
-          if (nodeStatus == SVNStatusType.STATUS_MODIFIED || nodeStatus == SVNStatusType.STATUS_REPLACED ||
-              nodeStatus == SVNStatusType.STATUS_DELETED  || nodeStatus == SVNStatusType.STATUS_ADDED) {
-            changed.add(convertRelative(status.getFile()));
-          }
-        } as ISVNStatusHandler, null);
-
-        task.log('Filtering files with existing svn:eol-style...');
-        wcClient.doGetProperty(basedir, 'svn:eol-style', SVNRevision.WORKING, SVNRevision.WORKING, true, {
-          file, prop -> missingProps.remove(convertRelative(file));
-        } as ISVNPropertyHandler);
-        
-        task.log('Filtering files with binary svn:mime-type...');
-        wcClient.doGetProperty(basedir, 'svn:mime-type', SVNRevision.WORKING, SVNRevision.WORKING, true, {
-          file, prop ->
-          prop = SVNPropertyValue.getPropertyAsString(prop.getValue());
-          if (prop.startsWith('application/') || prop.startsWith('image/')) {
-            missingProps.remove(convertRelative(file));
-          }
-        } as ISVNPropertyHandler);
-        
-        task.log('Scanning for files with svn:keywords property...');
-        wcClient.doGetProperty(basedir, 'svn:keywords', SVNRevision.WORKING, SVNRevision.WORKING, true, {
-          file, prop -> withKeywords.add(convertRelative(file));
-        } as ISVNPropertyHandler);
-        
-        def setProjectPropertyFromSet(prop, set) {
-          if (set) {
-            properties[prop] = '* ' + set.join(properties['line.separator'] + '* ');
-          }
-        };
-        setProjectPropertyFromSet('svn.checkprops.failed', missingProps);
-        setProjectPropertyFromSet('svn.keywords.failed', withKeywords);
-        setProjectPropertyFromSet('svn.unversioned.failed', unversioned);
-        setProjectPropertyFromSet('svn.changed.failed', changed);
-      ]]></groovy>
-      <fail if="svn.checkprops.failed"
-        message="The following files are missing svn:eol-style (or binary svn:mime-type):${line.separator}${svn.checkprops.failed}"/>
-      <fail if="svn.keywords.failed"
-        message="The following files have the svn:keywords property set:${line.separator}${svn.keywords.failed}"/>
-      <fail if="svn.unversioned.failed"
-        message="Source checkout is dirty after running tests!!! Offending files:${line.separator}${svn.unversioned.failed}"/>
-      <fail message="Source checkout is modified !!! Offending files:${line.separator}${svn.changed.failed}">
-        <condition>
-          <and>
-             <istrue value="@{failonmodifications}"/>
-             <isset property="svn.changed.failed"/>
-          </and>
-        </condition>
-      </fail>
-    </sequential>
-  </macrodef>
-
-  <target name="check-svn-working-copy" depends="ivy-availability-check,ivy-fail,ivy-configure,resolve-groovy">
-    <svn-checker failonmodifications="false"/>
+  <target name="check-working-copy">
+    <echo>This task is currently disabled due to migration to GIT</echo>
   </target>
 
   <target name="run-clover" description="Runs all tests to measure coverage and generates report (pass &quot;ANT_OPTS=-Xmx1536M&quot; as environment)" depends="clean">
@@ -762,8 +653,8 @@ File | Project Structure | Platform Settings | SDKs):
   </target>
 
   <!-- should only be called by jenkins, not precommit! -->
-  <target name="-check-after-regeneration" depends="ivy-availability-check,ivy-fail,ivy-configure,resolve-groovy">
-    <svn-checker failonmodifications="true"/>
+  <target name="-check-after-regeneration">
+    <!-- TODO -->
   </target>
 
   <!-- TODO: remove me when jenkins works -->
@@ -779,7 +670,7 @@ File | Project Structure | Platform Settings | SDKs):
   </target>
   
   <!-- Jenkins tasks -->
-  <target name="-jenkins-base" depends="-print-java-info,clean,test-with-heapdumps,validate,documentation-lint,jar-checksums,check-svn-working-copy"/>
+  <target name="-jenkins-base" depends="-print-java-info,clean,test-with-heapdumps,validate,documentation-lint,jar-checksums,check-working-copy"/>
   
   <target name="-print-java-info">
     <echo level="info" taskname="java-info">java version &quot;${java.version}&quot;
diff --git a/lucene/build.xml b/lucene/build.xml
index 712e14b..e37c659 100644
--- a/lucene/build.xml
+++ b/lucene/build.xml
@@ -340,7 +340,7 @@
   <target name="package-tgz-src" depends="init-dist"
           description="--> Generates the Lucene source distribution as .tgz">
     <property name="source.package.file"
-              value="${dist.dir}/lucene-${version}-src.tgz"/>
+              location="${dist.dir}/lucene-${version}-src.tgz"/>
     <delete file="${source.package.file}"/>
     <export-source source.dir="."/>
 
@@ -349,11 +349,14 @@
     <!-- Exclude clover license files incompatible with the ASL -->
     <delete dir="${src.export.dir}/tools/clover"/>
 
-    <build-changes changes.src.file="${src.export.dir}/CHANGES.txt"
-                   changes.target.dir="${src.export.dir}/docs/changes"
+    <!-- because we only package the "lucene/" folder, we have to adjust dir to work on: ->
+    <property name="local.src.export.dir" location="${src.export.dir}/lucene"/>
+    
+    <build-changes changes.src.file="${local.src.export.dir}/CHANGES.txt"
+                   changes.target.dir="${local.src.export.dir}/docs/changes"
                    changes.product="LUCENE"/>
     <tar tarfile="${source.package.file}" compression="gzip" longfile="gnu">
-      <tarfileset prefix="lucene-${version}" dir="${src.export.dir}"/>
+      <tarfileset prefix="lucene-${version}" dir="${local.src.export.dir}"/>
     </tar>
     <make-checksums file="${source.package.file}"/>
   </target>
diff --git a/solr/build.xml b/solr/build.xml
index 1b30dc9..c984243 100644
--- a/solr/build.xml
+++ b/solr/build.xml
@@ -452,7 +452,7 @@
   <target name="package-src-tgz" depends="init-dist"
           description="Packages the Solr Source Distribution">
     <property name="source.package.file"
-              value="${package.dir}/${fullnamever}-src.tgz"/>
+              location="${package.dir}/${fullnamever}-src.tgz"/>
     <delete file="${source.package.file}" failonerror="false" />
     <export-source source.dir=".."/>
 


[lucene] 06/18: LUCENE-6938: Improve output of Git Hash if no GIT available or no GIT checkout (this restores previous behaviour)

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit d4a8bbbf2b1effc2f166530fcd4720127eafc9a9
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Sun Jan 24 00:03:25 2016 +0100

    LUCENE-6938: Improve output of Git Hash if no GIT available or no GIT checkout (this restores previous behaviour)
---
 lucene/common-build.xml | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index d6167c1..890a50b 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -632,13 +632,22 @@
     <attribute name="manifest.file" default="${manifest.file}"/>
     <element name="additional-manifest-attributes" optional="true"/>
     <sequential>
-      <exec dir="." executable="${git.exe}" outputproperty="checkoutid" failifexecutionfails="false">
+      <local name="-checkoutid"/>
+      <local name="-giterr"/>
+      <local name="checkoutid"/>
+      
+      <!-- If possible, include the GIT hash into manifest: -->
+      <exec dir="." executable="${git.exe}" outputproperty="-checkoutid" errorproperty="-giterr" failifexecutionfails="false">
         <arg value="log"/>
-        <arg value="--format='%H'"/>
+        <arg value="--format=%H"/>
         <arg value="-n"/>
         <arg value="1"/>
       </exec>
+      <condition property="checkoutid" value="${-checkoutid}" else="unknown">
+        <matches pattern="^[0-9a-z]+$" string="${-checkoutid}" casesensitive="false" multiline="true"/>
+      </condition>
 
+      <!-- create manifest: -->
       <manifest file="@{manifest.file}">
         <!--
         http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#JAR%20Manifest


[lucene] 05/18: LUCENE-6938: Maven build: Switch SCM descriptors from svn to git; buildnumber-maven-plugin's buildNumberPropertyName property (used in Maven-built artifact manifests) renamed from svn.revision to checkoutid; removed Subversion-specific stuff from README.maven

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 016b26675efbd25b9907115b400bacb55b840af3
Author: Steve Rowe <sa...@apache.org>
AuthorDate: Sat Jan 23 16:29:28 2016 -0500

    LUCENE-6938: Maven build: Switch SCM descriptors from svn to git; buildnumber-maven-plugin's buildNumberPropertyName property (used in Maven-built artifact manifests) renamed from svn.revision to checkoutid; removed Subversion-specific stuff from README.maven
---
 dev-tools/maven/README.maven                             |  9 +++------
 dev-tools/maven/lucene/analysis/common/pom.xml.template  |  6 +++---
 dev-tools/maven/lucene/analysis/icu/pom.xml.template     |  6 +++---
 .../maven/lucene/analysis/kuromoji/pom.xml.template      |  6 +++---
 .../maven/lucene/analysis/morfologik/pom.xml.template    |  6 +++---
 .../maven/lucene/analysis/phonetic/pom.xml.template      |  6 +++---
 dev-tools/maven/lucene/analysis/smartcn/pom.xml.template |  6 +++---
 dev-tools/maven/lucene/analysis/stempel/pom.xml.template |  6 +++---
 dev-tools/maven/lucene/analysis/uima/pom.xml.template    |  6 +++---
 dev-tools/maven/lucene/backward-codecs/pom.xml.template  |  6 +++---
 dev-tools/maven/lucene/benchmark/pom.xml.template        |  6 +++---
 dev-tools/maven/lucene/classification/pom.xml.template   |  6 +++---
 dev-tools/maven/lucene/codecs/src/java/pom.xml.template  |  6 +++---
 dev-tools/maven/lucene/core/src/java/pom.xml.template    |  6 +++---
 dev-tools/maven/lucene/demo/pom.xml.template             |  6 +++---
 dev-tools/maven/lucene/facet/pom.xml.template            |  6 +++---
 dev-tools/maven/lucene/grouping/pom.xml.template         |  6 +++---
 dev-tools/maven/lucene/highlighter/pom.xml.template      |  6 +++---
 dev-tools/maven/lucene/join/pom.xml.template             |  6 +++---
 dev-tools/maven/lucene/memory/pom.xml.template           |  6 +++---
 dev-tools/maven/lucene/misc/pom.xml.template             |  6 +++---
 dev-tools/maven/lucene/pom.xml.template                  |  6 +++---
 dev-tools/maven/lucene/queries/pom.xml.template          |  6 +++---
 dev-tools/maven/lucene/queryparser/pom.xml.template      |  6 +++---
 dev-tools/maven/lucene/replicator/pom.xml.template       |  6 +++---
 dev-tools/maven/lucene/sandbox/pom.xml.template          |  6 +++---
 dev-tools/maven/lucene/suggest/pom.xml.template          |  6 +++---
 dev-tools/maven/lucene/test-framework/pom.xml.template   |  6 +++---
 dev-tools/maven/pom.xml.template                         | 16 ++++++++--------
 .../maven/solr/contrib/analysis-extras/pom.xml.template  |  6 +++---
 dev-tools/maven/solr/contrib/analytics/pom.xml.template  |  6 +++---
 dev-tools/maven/solr/contrib/clustering/pom.xml.template |  6 +++---
 .../contrib/dataimporthandler-extras/pom.xml.template    |  6 +++---
 .../solr/contrib/dataimporthandler/pom.xml.template      |  6 +++---
 dev-tools/maven/solr/contrib/extraction/pom.xml.template |  6 +++---
 dev-tools/maven/solr/contrib/langid/pom.xml.template     |  6 +++---
 dev-tools/maven/solr/contrib/map-reduce/pom.xml.template |  6 +++---
 .../maven/solr/contrib/morphlines-cell/pom.xml.template  |  6 +++---
 .../maven/solr/contrib/morphlines-core/pom.xml.template  |  6 +++---
 dev-tools/maven/solr/contrib/uima/pom.xml.template       |  6 +++---
 dev-tools/maven/solr/contrib/velocity/pom.xml.template   |  6 +++---
 dev-tools/maven/solr/core/src/java/pom.xml.template      |  6 +++---
 dev-tools/maven/solr/pom.xml.template                    |  6 +++---
 dev-tools/maven/solr/solrj/src/java/pom.xml.template     |  6 +++---
 dev-tools/maven/solr/test-framework/pom.xml.template     |  6 +++---
 45 files changed, 140 insertions(+), 143 deletions(-)

diff --git a/dev-tools/maven/README.maven b/dev-tools/maven/README.maven
index 8bd031c..0d8e22b 100644
--- a/dev-tools/maven/README.maven
+++ b/dev-tools/maven/README.maven
@@ -71,7 +71,6 @@ D. How to use Maven to build Lucene/Solr
 
    In summary, to enable Maven builds, perform the following:
 
-         svn update
          ant get-maven-poms
          cd maven-build
 
@@ -79,9 +78,7 @@ D. How to use Maven to build Lucene/Solr
 
    1. Prerequisites: JDK 1.7+ and Maven 2.2.1 or 3.X
 
-   2. Make sure your sources are up to date.  If you checked your sources out
-      from the Apache Subversion repository, run "svn update" from the top
-      level.
+   2. Make sure your sources are up to date.
 
    3. Copy the Maven POM templates from under dev-tools/maven/ to the
       maven-build/ directory using the following command from the top-level
@@ -90,8 +87,8 @@ D. How to use Maven to build Lucene/Solr
          ant get-maven-poms
 
       Note that you will need to do this whenever changes to the POM
-      templates are committed.  It's a good idea to follow every "svn update"
-      with "ant get-maven-poms" for this reason.
+      templates are committed.  For this reason, it's a good idea run
+      "ant get-maven-poms" after you update from origin.
 
       The above command copies all of the POM templates from dev-tools/maven/,
       filling in the project version with the default "X.X-SNAPSHOT".  If you
diff --git a/dev-tools/maven/lucene/analysis/common/pom.xml.template b/dev-tools/maven/lucene/analysis/common/pom.xml.template
index 0440fef..95a0487 100644
--- a/dev-tools/maven/lucene/analysis/common/pom.xml.template
+++ b/dev-tools/maven/lucene/analysis/common/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/analysis/icu/pom.xml.template b/dev-tools/maven/lucene/analysis/icu/pom.xml.template
index 6745136..40b5f34 100644
--- a/dev-tools/maven/lucene/analysis/icu/pom.xml.template
+++ b/dev-tools/maven/lucene/analysis/icu/pom.xml.template
@@ -40,9 +40,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/analysis/kuromoji/pom.xml.template b/dev-tools/maven/lucene/analysis/kuromoji/pom.xml.template
index 1c77ce2..e5877a4 100644
--- a/dev-tools/maven/lucene/analysis/kuromoji/pom.xml.template
+++ b/dev-tools/maven/lucene/analysis/kuromoji/pom.xml.template
@@ -39,9 +39,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/analysis/morfologik/pom.xml.template b/dev-tools/maven/lucene/analysis/morfologik/pom.xml.template
index 542497b..3472711 100644
--- a/dev-tools/maven/lucene/analysis/morfologik/pom.xml.template
+++ b/dev-tools/maven/lucene/analysis/morfologik/pom.xml.template
@@ -39,9 +39,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/analysis/phonetic/pom.xml.template b/dev-tools/maven/lucene/analysis/phonetic/pom.xml.template
index 41ff220..06dcb9c 100644
--- a/dev-tools/maven/lucene/analysis/phonetic/pom.xml.template
+++ b/dev-tools/maven/lucene/analysis/phonetic/pom.xml.template
@@ -39,9 +39,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/analysis/smartcn/pom.xml.template b/dev-tools/maven/lucene/analysis/smartcn/pom.xml.template
index 07df187..30c46aa 100644
--- a/dev-tools/maven/lucene/analysis/smartcn/pom.xml.template
+++ b/dev-tools/maven/lucene/analysis/smartcn/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/analysis/stempel/pom.xml.template b/dev-tools/maven/lucene/analysis/stempel/pom.xml.template
index 44f2b0b..7e1346b 100644
--- a/dev-tools/maven/lucene/analysis/stempel/pom.xml.template
+++ b/dev-tools/maven/lucene/analysis/stempel/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/analysis/uima/pom.xml.template b/dev-tools/maven/lucene/analysis/uima/pom.xml.template
index c2a8092..667a2f4 100644
--- a/dev-tools/maven/lucene/analysis/uima/pom.xml.template
+++ b/dev-tools/maven/lucene/analysis/uima/pom.xml.template
@@ -41,9 +41,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/backward-codecs/pom.xml.template b/dev-tools/maven/lucene/backward-codecs/pom.xml.template
index 0d892ca..8522880 100644
--- a/dev-tools/maven/lucene/backward-codecs/pom.xml.template
+++ b/dev-tools/maven/lucene/backward-codecs/pom.xml.template
@@ -39,9 +39,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/benchmark/pom.xml.template b/dev-tools/maven/lucene/benchmark/pom.xml.template
index b5e2581..1aa8e1a 100644
--- a/dev-tools/maven/lucene/benchmark/pom.xml.template
+++ b/dev-tools/maven/lucene/benchmark/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/classification/pom.xml.template b/dev-tools/maven/lucene/classification/pom.xml.template
index e1de676..ad26925 100644
--- a/dev-tools/maven/lucene/classification/pom.xml.template
+++ b/dev-tools/maven/lucene/classification/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/lucene/codecs/src/java/pom.xml.template b/dev-tools/maven/lucene/codecs/src/java/pom.xml.template
index 5a203cb..d23093f 100644
--- a/dev-tools/maven/lucene/codecs/src/java/pom.xml.template
+++ b/dev-tools/maven/lucene/codecs/src/java/pom.xml.template
@@ -39,9 +39,9 @@
     <module-path>${relative-top-level}/${module-directory}/src/java</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
 @lucene-codecs.internal.dependencies@
diff --git a/dev-tools/maven/lucene/core/src/java/pom.xml.template b/dev-tools/maven/lucene/core/src/java/pom.xml.template
index 6baced8..43302bf 100644
--- a/dev-tools/maven/lucene/core/src/java/pom.xml.template
+++ b/dev-tools/maven/lucene/core/src/java/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}/src/java</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <build>
     <sourceDirectory>${module-path}</sourceDirectory>
diff --git a/dev-tools/maven/lucene/demo/pom.xml.template b/dev-tools/maven/lucene/demo/pom.xml.template
index a034701..7e8eda4 100644
--- a/dev-tools/maven/lucene/demo/pom.xml.template
+++ b/dev-tools/maven/lucene/demo/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/facet/pom.xml.template b/dev-tools/maven/lucene/facet/pom.xml.template
index 59330f3..6953b67 100644
--- a/dev-tools/maven/lucene/facet/pom.xml.template
+++ b/dev-tools/maven/lucene/facet/pom.xml.template
@@ -39,9 +39,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/grouping/pom.xml.template b/dev-tools/maven/lucene/grouping/pom.xml.template
index c6499aa..daff88e 100644
--- a/dev-tools/maven/lucene/grouping/pom.xml.template
+++ b/dev-tools/maven/lucene/grouping/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/highlighter/pom.xml.template b/dev-tools/maven/lucene/highlighter/pom.xml.template
index bc00fac..e6d81c3 100644
--- a/dev-tools/maven/lucene/highlighter/pom.xml.template
+++ b/dev-tools/maven/lucene/highlighter/pom.xml.template
@@ -39,9 +39,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/join/pom.xml.template b/dev-tools/maven/lucene/join/pom.xml.template
index e2b8bd0..61567d8 100644
--- a/dev-tools/maven/lucene/join/pom.xml.template
+++ b/dev-tools/maven/lucene/join/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/memory/pom.xml.template b/dev-tools/maven/lucene/memory/pom.xml.template
index 08b15cb..b42d8b8 100644
--- a/dev-tools/maven/lucene/memory/pom.xml.template
+++ b/dev-tools/maven/lucene/memory/pom.xml.template
@@ -39,9 +39,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/misc/pom.xml.template b/dev-tools/maven/lucene/misc/pom.xml.template
index 16a44b7..a4ea5bc 100644
--- a/dev-tools/maven/lucene/misc/pom.xml.template
+++ b/dev-tools/maven/lucene/misc/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/pom.xml.template b/dev-tools/maven/lucene/pom.xml.template
index 9a7d1ec..f49a60e 100644
--- a/dev-tools/maven/lucene/pom.xml.template
+++ b/dev-tools/maven/lucene/pom.xml.template
@@ -35,9 +35,9 @@
     <module-directory>lucene</module-directory>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <modules>
     <module>core</module>
diff --git a/dev-tools/maven/lucene/queries/pom.xml.template b/dev-tools/maven/lucene/queries/pom.xml.template
index 395618f..7e555c5 100644
--- a/dev-tools/maven/lucene/queries/pom.xml.template
+++ b/dev-tools/maven/lucene/queries/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/queryparser/pom.xml.template b/dev-tools/maven/lucene/queryparser/pom.xml.template
index a03970a..d5a9570 100644
--- a/dev-tools/maven/lucene/queryparser/pom.xml.template
+++ b/dev-tools/maven/lucene/queryparser/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/replicator/pom.xml.template b/dev-tools/maven/lucene/replicator/pom.xml.template
index 60d0085..c749ba4 100644
--- a/dev-tools/maven/lucene/replicator/pom.xml.template
+++ b/dev-tools/maven/lucene/replicator/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/sandbox/pom.xml.template b/dev-tools/maven/lucene/sandbox/pom.xml.template
index b1de70d..baa8a3c 100644
--- a/dev-tools/maven/lucene/sandbox/pom.xml.template
+++ b/dev-tools/maven/lucene/sandbox/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/suggest/pom.xml.template b/dev-tools/maven/lucene/suggest/pom.xml.template
index baa665d..4e26ca60 100644
--- a/dev-tools/maven/lucene/suggest/pom.xml.template
+++ b/dev-tools/maven/lucene/suggest/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency> 
diff --git a/dev-tools/maven/lucene/test-framework/pom.xml.template b/dev-tools/maven/lucene/test-framework/pom.xml.template
index f17f73a..21a910c 100644
--- a/dev-tools/maven/lucene/test-framework/pom.xml.template
+++ b/dev-tools/maven/lucene/test-framework/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
 @lucene-test-framework.internal.dependencies@
diff --git a/dev-tools/maven/pom.xml.template b/dev-tools/maven/pom.xml.template
index 0c0d7ce..f4c1888 100644
--- a/dev-tools/maven/pom.xml.template
+++ b/dev-tools/maven/pom.xml.template
@@ -38,9 +38,9 @@
     <module>solr</module>
   </modules>
   <properties>
-    <vc-anonymous-base-url>http://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x</vc-anonymous-base-url>
-    <vc-dev-base-url>https://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x</vc-dev-base-url>
-    <vc-browse-base-url>http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x</vc-browse-base-url>
+    <vc-anonymous-base-url>http://git-wip-us.apache.org/repos/asf/lucene-solr.git</vc-anonymous-base-url>
+    <vc-dev-base-url>https://git-wip-us.apache.org/repos/asf/lucene-solr.git</vc-dev-base-url>
+    <vc-browse-base-url>https://git1-us-west.apache.org/repos/asf?p=lucene-solr.git;a=tree</vc-browse-base-url>
     <specification.version>@spec.version@</specification.version>
     <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
     <java.compat.version>1.7</java.compat.version>
@@ -108,8 +108,8 @@
   </mailingLists>
   <inceptionYear>2000</inceptionYear>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}</developerConnection>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
     <url>${vc-browse-base-url}</url>
   </scm>
   <licenses>
@@ -295,7 +295,7 @@
                 <Specification-Version>${specification.version}</Specification-Version>
                 <Specification-Vendor>The Apache Software Foundation</Specification-Vendor>
                 <!-- impl version can be any string -->
-                <Implementation-Version>${project.version} ${svn.revision} - ${user.name} - ${now.timestamp}</Implementation-Version>
+                <Implementation-Version>${project.version} ${checkoutid} - ${user.name} - ${now.timestamp}</Implementation-Version>
                 <Implementation-Vendor>The Apache Software Foundation</Implementation-Vendor>
                 <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
                 <X-Compile-Source-JDK>${java.compat.version}</X-Compile-Source-JDK>
@@ -364,7 +364,7 @@
           <doUpdate>false</doUpdate>
           <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
           <revisionOnScmFailure>NO-REVISION-AVAILABLE</revisionOnScmFailure>
-          <buildNumberPropertyName>svn.revision</buildNumberPropertyName>
+          <buildNumberPropertyName>checkoutid</buildNumberPropertyName>
           <scmDirectory>${top-level}</scmDirectory>
         </configuration>
       </plugin>
@@ -421,7 +421,7 @@
             <Specification-Version>${specification.version}</Specification-Version>
             <Specification-Vendor>The Apache Software Foundation</Specification-Vendor>
             <!-- impl version can be any string -->
-            <Implementation-Version>${project.version} ${svn.revision} - ${user.name} - ${now.timestamp}</Implementation-Version>
+            <Implementation-Version>${project.version} ${checkoutid} - ${user.name} - ${now.timestamp}</Implementation-Version>
             <Implementation-Vendor>The Apache Software Foundation</Implementation-Vendor>
             <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
             <X-Compile-Source-JDK>${java.compat.version}</X-Compile-Source-JDK>
diff --git a/dev-tools/maven/solr/contrib/analysis-extras/pom.xml.template b/dev-tools/maven/solr/contrib/analysis-extras/pom.xml.template
index 8722f58..4d0f322 100644
--- a/dev-tools/maven/solr/contrib/analysis-extras/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/analysis-extras/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/contrib/analytics/pom.xml.template b/dev-tools/maven/solr/contrib/analytics/pom.xml.template
index 757426e..8246e25 100644
--- a/dev-tools/maven/solr/contrib/analytics/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/analytics/pom.xml.template
@@ -39,9 +39,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/contrib/clustering/pom.xml.template b/dev-tools/maven/solr/contrib/clustering/pom.xml.template
index eb2f302..652accb 100644
--- a/dev-tools/maven/solr/contrib/clustering/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/clustering/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/contrib/dataimporthandler-extras/pom.xml.template b/dev-tools/maven/solr/contrib/dataimporthandler-extras/pom.xml.template
index c12a4d2..d8515be 100644
--- a/dev-tools/maven/solr/contrib/dataimporthandler-extras/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/dataimporthandler-extras/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/contrib/dataimporthandler/pom.xml.template b/dev-tools/maven/solr/contrib/dataimporthandler/pom.xml.template
index aff4627..06ccf70 100644
--- a/dev-tools/maven/solr/contrib/dataimporthandler/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/dataimporthandler/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/contrib/extraction/pom.xml.template b/dev-tools/maven/solr/contrib/extraction/pom.xml.template
index 96b3f70..4a0ec2e 100644
--- a/dev-tools/maven/solr/contrib/extraction/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/extraction/pom.xml.template
@@ -40,9 +40,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/contrib/langid/pom.xml.template b/dev-tools/maven/solr/contrib/langid/pom.xml.template
index 67410df..b1165b2 100644
--- a/dev-tools/maven/solr/contrib/langid/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/langid/pom.xml.template
@@ -41,9 +41,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/contrib/map-reduce/pom.xml.template b/dev-tools/maven/solr/contrib/map-reduce/pom.xml.template
index 2c216af..5165e7a 100644
--- a/dev-tools/maven/solr/contrib/map-reduce/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/map-reduce/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/contrib/morphlines-cell/pom.xml.template b/dev-tools/maven/solr/contrib/morphlines-cell/pom.xml.template
index 3d9ecd5..6c5b9c3 100644
--- a/dev-tools/maven/solr/contrib/morphlines-cell/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/morphlines-cell/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/contrib/morphlines-core/pom.xml.template b/dev-tools/maven/solr/contrib/morphlines-core/pom.xml.template
index 51ef6f0..beefa83 100644
--- a/dev-tools/maven/solr/contrib/morphlines-core/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/morphlines-core/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/contrib/uima/pom.xml.template b/dev-tools/maven/solr/contrib/uima/pom.xml.template
index 17038a0..1dae4e7 100644
--- a/dev-tools/maven/solr/contrib/uima/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/uima/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/contrib/velocity/pom.xml.template b/dev-tools/maven/solr/contrib/velocity/pom.xml.template
index d6d24a7..9faab82 100644
--- a/dev-tools/maven/solr/contrib/velocity/pom.xml.template
+++ b/dev-tools/maven/solr/contrib/velocity/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <dependency>
diff --git a/dev-tools/maven/solr/core/src/java/pom.xml.template b/dev-tools/maven/solr/core/src/java/pom.xml.template
index 22bde78..b8408b0 100644
--- a/dev-tools/maven/solr/core/src/java/pom.xml.template
+++ b/dev-tools/maven/solr/core/src/java/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}/src/java</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
 @solr-core.internal.dependencies@
diff --git a/dev-tools/maven/solr/pom.xml.template b/dev-tools/maven/solr/pom.xml.template
index c0d6290..f3c8c81 100644
--- a/dev-tools/maven/solr/pom.xml.template
+++ b/dev-tools/maven/solr/pom.xml.template
@@ -41,9 +41,9 @@
     <module-directory>solr</module-directory>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <issueManagement>
     <system>JIRA</system>
diff --git a/dev-tools/maven/solr/solrj/src/java/pom.xml.template b/dev-tools/maven/solr/solrj/src/java/pom.xml.template
index f120eb0..e384739 100644
--- a/dev-tools/maven/solr/solrj/src/java/pom.xml.template
+++ b/dev-tools/maven/solr/solrj/src/java/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}/src/java</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
 @solr-solrj.internal.dependencies@
diff --git a/dev-tools/maven/solr/test-framework/pom.xml.template b/dev-tools/maven/solr/test-framework/pom.xml.template
index 00530cb..805bffe 100644
--- a/dev-tools/maven/solr/test-framework/pom.xml.template
+++ b/dev-tools/maven/solr/test-framework/pom.xml.template
@@ -37,9 +37,9 @@
     <module-path>${relative-top-level}/${module-directory}</module-path>
   </properties>
   <scm>
-    <connection>scm:svn:${vc-anonymous-base-url}/${module-directory}</connection>
-    <developerConnection>scm:svn:${vc-dev-base-url}/${module-directory}</developerConnection>
-    <url>${vc-browse-base-url}/${module-directory}</url>
+    <connection>scm:git:${vc-anonymous-base-url}</connection>
+    <developerConnection>scm:git:${vc-dev-base-url}</developerConnection>
+    <url>${vc-browse-base-url};f=${module-directory}</url>
   </scm>
   <dependencies>
     <!-- These dependencies are compile scope because this is a test framework. -->


[lucene] 14/18: LUCENE-6932: also fix RAFIndexInput to throw EOFE if you seek beyond end of file

Posted by dw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_5_4
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 2512ab6c1f3089cb8fe534532f0676c3358a5cd4
Author: Michael McCandless <mi...@apache.org>
AuthorDate: Fri Jan 22 19:00:47 2016 +0000

    LUCENE-6932: also fix RAFIndexInput to throw EOFE if you seek beyond end of file
    
    git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/branch_5x@1726290 13f79535-47bb-0310-9956-ffa450edef68
---
 lucene/misc/src/java/org/apache/lucene/store/RAFDirectory.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lucene/misc/src/java/org/apache/lucene/store/RAFDirectory.java b/lucene/misc/src/java/org/apache/lucene/store/RAFDirectory.java
index 9c3e9b0..94be104 100644
--- a/lucene/misc/src/java/org/apache/lucene/store/RAFDirectory.java
+++ b/lucene/misc/src/java/org/apache/lucene/store/RAFDirectory.java
@@ -165,7 +165,10 @@ public class RAFDirectory extends FSDirectory {
     }
   
     @Override
-    protected void seekInternal(long position) {
+    protected void seekInternal(long pos) throws IOException {
+      if (pos > length()) {
+        throw new EOFException("read past EOF: pos=" + pos + " vs length=" + length() + ": " + this);
+      }
     }
     
     boolean isFDValid() throws IOException {