Bug #1131 com.mysql.Clob.setCharacterStream inefficient
Submitted: 25 Aug 2003 3:08 Modified: 25 Aug 2003 7:42
Reporter: Roland Littwin Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.0.8 OS:Any (All)
Assigned to: CPU Architecture:Any

[25 Aug 2003 3:08] Roland Littwin
Description:
In com.mysql.setCharacterStream the first assert checks if indexToWriteAt<1 and throws exception thus the second condition indexToWriteAt>0 is always true.
The enclosed statement has only an effect if indexToWriteAt > 1 so a change of the second condition can speed up the method.

How to repeat:
Results are correct. Only unneccassy if statement

Suggested fix:
public Writer setCharacterStream(long indexToWriteAt)
        throws SQLException {
        if (indexToWriteAt < 1) {
            throw new SQLException("indexToWriteAt must be >= 1", "S1009");
        }

        WatchableWriter writer = new WatchableWriter();
        writer.setWatcher(this);

        if (indexToWriteAt > 1) {
            writer.write(this.charData, 0, (int) (indexToWriteAt - 1));
        }

        return writer;
    }
[25 Aug 2003 7:42] Mark Matthews
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html