Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-16363

DirectUpdateHandler2 should not throw UnknownFormatConversionException

    XMLWordPrintableJSON

Details

    Description

      In certain situation, to handle IllegalArgumentException while adding doc to solr is linked below

      https://github.com/apache/lucene-solr/blob/releases/lucene-solr/8.11.2/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java#L249

      EDIT: Adding Code piece for current main branch: https://github.com/apache/solr/blob/main/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java#L314

       

      This can be problematic if IllegalArgumentException (of the following format) is thrown during processing of docs (in my case it was via Filters to URL-Decode a string)

       

       java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - Error at index 0 in: "sy"

      The iae.getMessage() in this case contains "%)" which conflicts with String.format which would further throw

      java.util.UnknownFormatConversionException: Conversion = ')'
              at java.util.Formatter.checkText(Unknown Source) ~[?:?]
              at java.util.Formatter.parse(Unknown Source) ~[?:?]
              at java.util.Formatter.format(Unknown Source) ~[?:?]
              at java.util.Formatter.format(Unknown Source) ~[?:?]
              at java.lang.String.format(Unknown Source) ~[?:?]
              at org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:249)

      This particular exception is not caught and as a result the BAD_REQUEST was never returned to the client along with failure point in the chain.

      The ticket is a proposal to make this more robust i.e., in this particular situation either getMessage() could replaceAll "%" or perhaps another try?

       

       

      Attachments

        Activity

          People

            krisden Kevin Risden
            averma Aman Verma
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1.5h
                1.5h