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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
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: [hidden email]
          Reporter: [hidden email]
  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: [hidden email]
For additional commands, e-mail: [hidden email]