You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2019/11/20 06:05:25 UTC

[Bug 63940] New: POI continues to occupy a thread and no response is returned when calling the Excel SUBSTITUTE function.

https://bz.apache.org/bugzilla/show_bug.cgi?id=63940

            Bug ID: 63940
           Summary: POI continues to occupy a thread and no response is
                    returned when calling the Excel SUBSTITUTE function.
           Product: POI
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: SS Common
          Assignee: dev@poi.apache.org
          Reporter: machiko.hashimoto.gc@hitachi.com
  Target Milestone: ---

Created attachment 36889
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36889&action=edit
Data for investigation

A thread is continuously occupied by POI and no response is returned when the
Excel SUBSTITUTE function is called.
It occurs when the second argument is blank(empty character).

However, it doesn't occur when using the same function on Microsoft Excel.(only
occurs when calling from POI)

I called POI, which reads an Excel file with SUBSTITUTE function in some CELLs,
from a web application deployed on GlassFish.
According to the thread dump, it seems that the thread has stopped at the line
marked with "*" on the following code.

-------------------------------------------------------------
org.apache.poi.ss.formula.functions.Substitute


        private static String replaceAllOccurrences(String oldStr, String
searchStr, String newStr) {
                StringBuffer sb = new StringBuffer();
                int startIndex = 0;
                int nextMatch = -1;
                while (true) {
                        nextMatch = oldStr.indexOf(searchStr, startIndex);
                        if (nextMatch < 0) {
                                // store everything from end of last match to
end of string
                                sb.append(oldStr.substring(startIndex));
                                return sb.toString();
                        }
                        // store everything from end of last match to start of
this match
                        sb.append(oldStr.substring(startIndex, nextMatch));
                        sb.append(newStr);
*                       startIndex = nextMatch + searchStr.length();
                }
        }
-------------------------------------------------------------


It occurs when using version 4.1.1, too.
If the allocated Java heap memory is small, java.lang.OutOfMemoryError is
thrown instead.


I've attached the following materials that are necessary for the survey.

1. SUBSTITUTE.xls:Excel file which the problem occurs.
2. OutOfMemory.txt:Stack trace when java.lang.OutOfMemoryError was thrown.
3. ThreadDump.txt:Excerpt of the thread dump obtained when no response
occurred.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 63940] POI continues to occupy a thread and no response is returned when calling the Excel SUBSTITUTE function.

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63940

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Dominik Stadler <do...@gmx.at> ---
Fixed via r1872145, there was an endless loop whenever an empty string was used
as "search string".

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org