Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes a thread safety problem introduced by DBUTILS-124. #3

Closed
wants to merge 1 commit into from

Conversation

hdevalke
Copy link

ColumnHandlers and PropertyHandlers are preloaded in a list as the ServiceLoader instances are not thread safe

@thecarlhall
Copy link
Contributor

Thanks, @hdevalke! Nice catch. I totally missed that ServiceLoader isn't thread safe. I'll work to get this merged into master and cut a new release as soon as I can.


static {
for (PropertyHandler h : ServiceLoader.load(PropertyHandler.class)) {
propertyHandlers.add(h);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What not use a single static block?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why that is problematic?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think of it the other way around: Why use two blocks when you could use one?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see there was already a static block initializing primitiveDefaults. I find it more readable initializing each static variable in their own block. I did an update and put all in one static block.

ColumnHandlers and PropertyHandlers are preloaded in a list as the ServiceLoader instances are not thread safe
@garydgregory
Copy link
Member

I created https://issues.apache.org/jira/browse/DBUTILS-135 to track this fix. Committed to git master.

@objectboy2016
Copy link

objectboy2016 commented Jan 16, 2018

Why not design a named parameter

such as:
string sql="select * from user where name=:name";
.......
runquery.addParameter("name","paul");

So simple and straightforward
No problem with the number, but the parameters of many will be a disaster

such as:
insert into a (a, b, c, d, f, g, i, e, g, k) values (?,?,?,?,?,?,?,?,?)

My eyes have been spent.

eager!!!!!!!!!!!!!!!!!!!!!!!

@hdevalke hdevalke closed this Apr 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants