Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-1825: Additional incorrect getAttribute usage

Uwe Schindlerc2f95d474bc0
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/sinks/DateRecognizerSinkFilter.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/sinks/DateRecognizerSinkFilter.java
index 14ae4753631..d997abca379 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/sinks/DateRecognizerSinkFilter.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/sinks/DateRecognizerSinkFilter.java
@@ -51,17 +51,15 @@ public class DateRecognizerSinkFilter extends SinkFilter {
public boolean accept(AttributeSource source) {
if (termAtt == null) {
- termAtt = (TermAttribute) source.getAttribute(TermAttribute.class);
+ termAtt = (TermAttribute) source.addAttribute(TermAttribute.class);
}
- if (termAtt != null) {
- try {
- Date date = dateFormat.parse(termAtt.term());//We don't care about the date, just that we can parse it as a date
- if (date != null) {
- return true;
- }
- } catch (ParseException e) {
-
+ try {
+ Date date = dateFormat.parse(termAtt.term());//We don't care about the date, just that we can parse it as a date
+ if (date != null) {
+ return true;
}
+ } catch (ParseException e) {
+
}
return false;
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/sinks/TokenTypeSinkFilter.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/sinks/TokenTypeSinkFilter.java
index 437d98da1ec..bff4ac8779e 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/sinks/TokenTypeSinkFilter.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/sinks/TokenTypeSinkFilter.java
@@ -31,15 +31,11 @@ public class TokenTypeSinkFilter extends SinkFilter {
public boolean accept(AttributeSource source) {
if (typeAtt == null) {
- typeAtt = (TypeAttribute) source.getAttribute(TypeAttribute.class);
+ typeAtt = (TypeAttribute) source.addAttribute(TypeAttribute.class);
}
//check to see if this is a Category
- if (typeAtt != null && typeToMatch.equals(typeAtt.type())){
- return true;
- }
-
- return false;
+ return (typeToMatch.equals(typeAtt.type()));
}
}