Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-4520: ValueSource.getSortField() shouldn't throw IOException

Alan Woodwardbebdb3707afc
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 6adc2335e36..88983b9ef69 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -77,6 +77,9 @@ API Changes
* Lucene-4415: TermsFilter is now immutable. All terms need to be provided
as constructor argument. (Simon Willnauer)
+* LUCENE-4520: ValueSource.getSortField no longer throws IOExceptions
+ (Alan Woodward)
+
Bug Fixes
* LUCENE-1822: BaseFragListBuilder hard-coded 6 char margin is too naive.
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSource.java b/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSource.java
index 67b41cbd803..2e40b842fe7 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSource.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/function/ValueSource.java
@@ -89,9 +89,8 @@ public abstract class ValueSource {
*
* @param reverse true if this is a reverse sort.
* @return The {@link org.apache.lucene.search.SortField} for the ValueSource
- * @throws IOException if there was a problem reading the values.
*/
- public SortField getSortField(boolean reverse) throws IOException {
+ public SortField getSortField(boolean reverse) {
return new ValueSourceSortField(reverse);
}
diff --git a/solr/core/src/java/org/apache/solr/schema/CurrencyField.java b/solr/core/src/java/org/apache/solr/schema/CurrencyField.java
index 1b037d48c7f..d0324f0c4dc 100644
--- a/solr/core/src/java/org/apache/solr/schema/CurrencyField.java
+++ b/solr/core/src/java/org/apache/solr/schema/CurrencyField.java
@@ -16,23 +16,20 @@ package org.apache.solr.schema;
* limitations under the License.
*/
+import org.apache.lucene.analysis.util.ResourceLoader;
+import org.apache.lucene.analysis.util.ResourceLoaderAware;
import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.index.GeneralField;
-import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.StorableField;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.SortField;
-import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.response.TextResponseWriter;
-import org.apache.solr.response.XMLWriter;
import org.apache.solr.search.QParser;
import org.apache.solr.search.SolrConstantScoreQuery;
import org.apache.solr.search.function.ValueSourceRangeFilter;
-import org.apache.lucene.analysis.util.ResourceLoaderAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
@@ -247,12 +244,8 @@ public class CurrencyField extends FieldType implements SchemaAware, ResourceLoa
@Override
public SortField getSortField(SchemaField field, boolean reverse) {
- try {
- // Convert all values to default currency for sorting.
- return (new CurrencyValueSource(field, defaultCurrency, null)).getSortField(reverse);
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
- }
+ // Convert all values to default currency for sorting.
+ return (new CurrencyValueSource(field, defaultCurrency, null)).getSortField(reverse);
}
@Override
diff --git a/solr/core/src/java/org/apache/solr/search/QueryParsing.java b/solr/core/src/java/org/apache/solr/search/QueryParsing.java
index ce483cf1087..5c8e162ab0c 100644
--- a/solr/core/src/java/org/apache/solr/search/QueryParsing.java
+++ b/solr/core/src/java/org/apache/solr/search/QueryParsing.java
@@ -305,8 +305,6 @@ public class QueryParsing {
}
continue;
}
- } catch (IOException ioe) {
- throw ioe;
} catch (Exception e) {
// hang onto this in case the string isn't a full field name either
qParserException = e;
@@ -356,8 +354,6 @@ public class QueryParsing {
} catch (ParseException e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "error in sort: " + sortSpec, e);
- } catch (IOException e) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "error in sort: " + sortSpec, e);
}
diff --git a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
index c1374e9e9c3..897dde8ee81 100755
--- a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
+++ b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
@@ -1286,7 +1286,7 @@ class TestValueSource extends ValueSource {
}
@Override
- public SortField getSortField(boolean reverse) throws IOException {
+ public SortField getSortField(boolean reverse) {
return super.getSortField(reverse);
}
}