Adrian Nistor created SOLR-4979:
-----------------------------------

             Summary: Wasted work in DocumentAnalysisRequestHandler.readDocument
                 Key: SOLR-4979
                 URL: https://issues.apache.org/jira/browse/SOLR-4979
             Project: Solr
          Issue Type: Bug
    Affects Versions: 4.3.1
         Environment: any
            Reporter: Adrian Nistor
            Priority: Minor
         Attachments: patch.diff, patchShort.diff

The problem appears in version 4.3.1 and in revision 1498027.  I
attached a two-line patch (patch.diff) that fixes it.

In method "DocumentAnalysisRequestHandler.readDocument", the loop over
"reader.getAttributeLocalName" keeps overriding "fieldName" with
"reader.getAttributeValue(i)".  Therefore, only the last written value
is visible out of the loop and all the other writes and iterations are
not necessary.  The patch iterates from the end of
"reader.getAttributeLocalName" and breaks the first time when
"fieldName" is set.

The above fix (in patch.diff) is certainly correct (it's easy to see
through code inspection), but I think we can have an even shorter
patch (one line, in patchShort.diff): just break as soon as
"fieldName" is set, without reversion the loop order.  patchShort.diff
is correct only if there can be only one "attrName" equal to "name"
(which I think it's the case), or if it doesn't matter which attribute
value "fieldName" gets, as long as the condition
"name".equals(attrName) is satisfied.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to