sebb wrote:

Sorry, my last e-mail mentioned that QueryRunner was not thread-safe,
but I did not provide a patch.

Dang; I skimmed through other classes looking for unsafe members but overlooked your main point.

Or you could change the API further and insist that the DataSource is provided at construction time; the variable could be then made final.

This is the right fix. (In fact, in my haste I thought you'd already done it!) We should change the API as necessary to make the class immutable.

Two of the constructors would need to be removed as well.

No, you could just set the DataSource to "null" in the constructor; its Connection-less methods wouldn't work until you created a new object, but I think that's fine.

SqlNullCheckedResultSet has many variables that cannot be made final, but the Javadoc does not claim it is thread-safe.

It could be made thread-safe by synchronizing (or making volatile) all the variables, but this might be too much overhead. Depends whether this class is likely to be used from multiple threads or not.

I would not attempt to synchronize this class, just leave it unsafe and let users synchronize. We should document more explicitly that (unlike some other classes in DbUtils) it's unsafe.

-Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to