Solr
  1. Solr
  2. SOLR-1053

SolrWriter.getResourceAsString IndexOutOfBoundsException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.4
    • Labels:
      None
    • Environment:

      All

      Description

      It will got excexception when the size of data-config.xml are times of 1024bytes.
      Maybe it should check the sz==-1 when in.read(buf) reach the EOF.

      #### ORIGINAL CODE ####
      static String getResourceAsString(InputStream in) throws IOException {
          ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
          byte[] buf = new byte[1024];
          int sz = 0;
          try {
            while (true) {
              sz = in.read(buf);
              
              baos.write(buf, 0, sz);
              if (sz < buf.length)
                break;
            }
          } finally {
            try {
              in.close();
            } catch (Exception e) {
      
            }
          }
          return new String(baos.toByteArray());
        }
      
      1. SOLR-1053.patch
        0.7 kB
        Shalin Shekhar Mangar

        Activity

        Hide
        Shalin Shekhar Mangar added a comment -

        Patch to fix the issue. I'll commit shortly.

        Show
        Shalin Shekhar Mangar added a comment - Patch to fix the issue. I'll commit shortly.
        Hide
        Shalin Shekhar Mangar added a comment -

        Committed revision 751696.

        Thanks Herb!

        Show
        Shalin Shekhar Mangar added a comment - Committed revision 751696. Thanks Herb!
        Hide
        Grant Ingersoll added a comment -

        Bulk close for Solr 1.4

        Show
        Grant Ingersoll added a comment - Bulk close for Solr 1.4

          People

          • Assignee:
            Shalin Shekhar Mangar
            Reporter:
            Herb Jiang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development