Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-15071: Fix ArrayIndexOutOfBoundsException in contrib/ltr SolrFeatureScorer (#2196)

Christine Poerschke32e95ddb3f25
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index c07d2513ae9..5e8a25431c7 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -366,6 +366,9 @@ Bug Fixes
* SOLR-15073: Fix ClassCastException in SystemInfoHandler.getSecurityInfo. (Nikolay Ivanov, Christine Poerschke)
+* SOLR-15071: Fix ArrayIndexOutOfBoundsException in contrib/ltr SolrFeatureScorer.
+ (Florin Babes, Ovidiu Mihalcea, David Smiley, Christine Poerschke)
+
Other Changes
---------------------
diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/Feature.java b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/Feature.java
index bc7ff87db9b..52a0cefa7e5 100644
--- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/Feature.java
+++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/feature/Feature.java
@@ -27,7 +27,6 @@ import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.TwoPhaseIterator;
import org.apache.lucene.search.Weight;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.RamUsageEstimator;
@@ -365,10 +364,9 @@ public abstract class Feature extends Query implements Accountable {
return in.iterator();
}
- @Override
- public TwoPhaseIterator twoPhaseIterator() {
- return in.twoPhaseIterator();
- }
+ // Currently (Q1 2021) we intentionally don't delegate twoPhaseIterator()
+ // because it doesn't always work and we don't yet know why, please see
+ // SOLR-15071 for more details.
@Override
public int advanceShallow(int target) throws IOException {
diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestEdisMaxSolrFeature.java b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestEdisMaxSolrFeature.java
index f9401eb9408..bbc881552c1 100644
--- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestEdisMaxSolrFeature.java
+++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestEdisMaxSolrFeature.java
@@ -21,7 +21,6 @@ import org.apache.solr.ltr.TestRerankBase;
import org.apache.solr.ltr.model.LinearModel;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
public class TestEdisMaxSolrFeature extends TestRerankBase {
@@ -75,7 +74,6 @@ public class TestEdisMaxSolrFeature extends TestRerankBase {
assertJQ("/query" + query.toQueryString(), "/response/numFound/==4");
}
- @Ignore("SOLR-15071")
@Test
public void testEdisMaxSolrFeatureCustomMM() throws Exception {
loadFeature(
diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeature.java b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeature.java
index 15fc40df545..6c4dc083081 100644
--- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeature.java
+++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeature.java
@@ -30,6 +30,9 @@ public class TestFeature extends SolrTestCase {
for (final Method scorerClassMethod : Scorer.class.getDeclaredMethods()) {
try {
+ // the FilterFeatureScorer may simply inherit Scorer's default implementation
+ if (scorerClassMethod.getName().equals("twoPhaseIterator")) continue;
+
// the FilterFeatureScorer's implementation does not influence its parent Weight
if (scorerClassMethod.getName().equals("getWeight")) continue;