Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Bad conversion from java source code. For multiple dimention array .length in java returns the number of dimensions. In c# .Length - returns the total number of elements in all dimensions. This bug sometimes lead to IndexOutOfRangeException as reported in http://www.mail-archive.com/lucene-net-dev@incubator.apache.org/msg01277.html

      See the follwing code:
      1)class ByteBlockPool.
      1) Method Reset()
      wrong:
      //Array.Clear(buffers[i], 0, buffers.Length);
      should be:
      Array.Clear(buffers[i], 0, buffers[i].Length);

      2) public void NextBuffer()
      wrong:
      //if (1 + bufferUpto == buffers.Length)
      //byte[][] newBuffers = new byte[(int) (buffers.Length * 1.5)][];
      //Array.Copy(buffers, 0, newBuffers, 0, buffers.Length);
      should be:
      if (1 + bufferUpto == buffers.GetLength(0))
      byte[][] newBuffers = new byte[(int)(buffers.GetLength(0) * 1.5)][];
      Array.Copy(buffers, 0, newBuffers, 0, buffers.GetLength(0));
      2)class CharBlockPool
      1)public void NextBuffer()
      wrong:
      //if (1 + bufferUpto == buffers.Length){
      //char[][] newBuffers = new char[(int) (buffers.Length * 1.5)][];
      //Array.Copy(buffers, 0, newBuffers, 0, buffers.Length);
      should be:
      if (1 + bufferUpto == buffers.GetLength(0)){
      char[][] newBuffers = new char[(int)(buffers.GetLength(0) * 1.5)][];
      Array.Copy(buffers, 0, newBuffers, 0, buffers.GetLength(0));

        Issue Links

          Activity

          Hide
          Andrei Iliev added a comment -

          Replace the code in DocumentsWriter.cs

          1)class ByteBlockPool.
          1) Method Reset()
          wrong:
          //Array.Clear(buffers[i], 0, buffers.Length);
          should be:
          Array.Clear(buffers[i], 0, buffers[i].Length);

          2) public void NextBuffer()
          wrong:
          //if (1 + bufferUpto == buffers.Length)
          //byte[][] newBuffers = new byte[(int) (buffers.Length * 1.5)][];
          //Array.Copy(buffers, 0, newBuffers, 0, buffers.Length);
          should be:
          if (1 + bufferUpto == buffers.GetLength(0))
          byte[][] newBuffers = new byte[(int)(buffers.GetLength(0) * 1.5)][];
          Array.Copy(buffers, 0, newBuffers, 0, buffers.GetLength(0));
          2)class CharBlockPool
          1)public void NextBuffer()
          wrong:
          //if (1 + bufferUpto == buffers.Length){
          //char[][] newBuffers = new char[(int) (buffers.Length * 1.5)][];
          //Array.Copy(buffers, 0, newBuffers, 0, buffers.Length);
          should be:
          if (1 + bufferUpto == buffers.GetLength(0)){
          char[][] newBuffers = new char[(int)(buffers.GetLength(0) * 1.5)][];
          Array.Copy(buffers, 0, newBuffers, 0, buffers.GetLength(0));

          Show
          Andrei Iliev added a comment - Replace the code in DocumentsWriter.cs 1)class ByteBlockPool. 1) Method Reset() wrong: //Array.Clear(buffers [i] , 0, buffers.Length); should be: Array.Clear(buffers [i] , 0, buffers [i] .Length); 2) public void NextBuffer() wrong: //if (1 + bufferUpto == buffers.Length) //byte[][] newBuffers = new byte [(int) (buffers.Length * 1.5)] []; //Array.Copy(buffers, 0, newBuffers, 0, buffers.Length); should be: if (1 + bufferUpto == buffers.GetLength(0)) byte[][] newBuffers = new byte [(int)(buffers.GetLength(0) * 1.5)] []; Array.Copy(buffers, 0, newBuffers, 0, buffers.GetLength(0)); 2)class CharBlockPool 1)public void NextBuffer() wrong: //if (1 + bufferUpto == buffers.Length){ //char[][] newBuffers = new char [(int) (buffers.Length * 1.5)] []; //Array.Copy(buffers, 0, newBuffers, 0, buffers.Length); should be: if (1 + bufferUpto == buffers.GetLength(0)){ char[][] newBuffers = new char [(int)(buffers.GetLength(0) * 1.5)] []; Array.Copy(buffers, 0, newBuffers, 0, buffers.GetLength(0));
          Hide
          Digy added a comment -

          I will attach a patch including LUCENENET-142.

          DIGY

          Show
          Digy added a comment - I will attach a patch including LUCENENET-142 . DIGY
          Hide
          Digy added a comment -

          Patch applied.
          DIGY

          Show
          Digy added a comment - Patch applied. DIGY

            People

            • Assignee:
              Unassigned
              Reporter:
              Andrei Iliev
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

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

                  Development