Bug 38596 - Unnecessary synchronization and garbage in DataSourceRealm
Summary: Unnecessary synchronization and garbage in DataSourceRealm
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: Nightly Build
Hardware: Other All
: P4 trivial (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL: http://svn.apache.org/repos/asf/tomca...
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-09 17:55 UTC by Sandy McArthur
Modified: 2006-04-14 08:34 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sandy McArthur 2006-02-09 17:55:11 UTC
DataSourceRealm.java declares two StringBuffers fields, preparedRoles and
preparedCredentials, that hold the SQL to be used. After these fields are
assigned they do not change but to use them StringBuffer.toString() must be
called. The toString method is synchronized and creates a new String instance
each time it's called.

The simple fix is to change those fields to Strings and update the start()
method, and remove the toString() calls in credentials(...) and roles(...) methods.

A better, more intrusive, fix is to take advantage of PreparedStatements like
JDBCRealm does.
Comment 1 Yoav Shapira 2006-04-14 15:34:47 UTC
Trivial, as you noted ;)  I did the simple optimization you suggested above, not
the more intrusive one.  If you really think there's good value in doing the
more intrusive one, please submit a patch that does it and reopen this issue. 
Thanks ;)