Bug 89494

Summary: StringBuffers should not be reused
Product: [Retired] Red Hat Web Application Framework Reporter: Vadim Nasardinov <vnasardinov>
Component: otherAssignee: ccm-bugs-list
Status: CLOSED EOL QA Contact: Jon Orris <jorris>
Severity: medium Docs Contact:
Priority: low    
Version: nightly   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://post-office.corp.redhat.com/archives/ccm-engineering-list/2003-April/msg00038.html
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-27 16:50:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vadim Nasardinov 2003-04-23 15:16:20 UTC
In the latest installment of his newsletter, Dr. Heinz Kabutz argues
that StringBuffers should not be reused.  If you use JDK 1.3, reusing
a string buffer is a misguided optimization.  If you use JDK 1.4, it
is a memory leak. For details, see
http://www.javaspecialists.co.za/archive/Issue068.html

We do have a couple of places in our code where StringBuffers are
reused:

$ find src/ -name \*.java | xargs grep -E 'setLength\( *0 *\)' | \
  sed 's/: */:/'
src/com/arsdigita/bebop/Table.java:coords.setLength(0);
src/com/arsdigita/bebop/parameters/ArrayParameter.java:buf.setLength(0);
src/com/arsdigita/dispatcher/BaseDispatcherServlet.java:m_buffer.setLength(0);
src/com/arsdigita/dispatcher/MapDispatcher.java:m_buffer.setLength(0);
src/com/arsdigita/persistence/metadata/Operation.java:m_key.setLength(0);
src/com/arsdigita/templating/html/XHTMLParser.java:m_buffer.setLength(0);
src/com/arsdigita/templating/html/XHTMLParser.java:m_buffer.setLength(0);
src/com/arsdigita/templating/html/XHTMLParser.java:m_buffer.setLength(0);
src/com/arsdigita/templating/html/demo/DemoTagHandler.java:m_footnoteBuffer.setLength(0);
$ cd ../../cms/dev/
$ find src/ -name \*.java | xargs grep -E 'setLength\( *0 *\)' | \
  sed 's/: */:/'
src/com/arsdigita/cms/dispatcher/ContentCenterDispatcher.java:m_buffer.setLength(0);
src/com/arsdigita/cms/dispatcher/ServiceDispatcher.java:m_buffer.setLength(0);



Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. grep as described above


Additional info:

Comment 1 Vadim Nasardinov 2003-11-12 20:53:50 UTC
Someone (probably Jon) seems to have rooted out all of the
occurrences of sb.setLength(0).  The following commands finds nothing:

$ find core/src/ cms/src/ -name \*.java |
  xargs grep -E 'setLength\( *0 *\)' | sed 's/: */:/'

Marking QA_READY.



Comment 2 David Lawrence 2006-07-18 03:05:15 UTC
QA_READY has been deprecated in favor of ON_QA. Please use ON_QA in the future.
Moving to ON_QA.