Skip to content

Prevent race condition in TypeHandlerRegistry #1820

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

Merged
merged 3 commits into from
Jan 23, 2020
Merged

Prevent race condition in TypeHandlerRegistry #1820

merged 3 commits into from
Jan 23, 2020

Conversation

LyubinskiyPavel
Copy link
Contributor

No description provided.

typeHandlerMap.put(javaType, map);
} else {
map.put(jdbcType, handler);
}
Copy link
Member

Choose a reason for hiding this comment

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

Wow...did this actually happen on production?

Regarding the change, how about updating typeHandlerMap at the end?
i.e.

      Map<JdbcType, TypeHandler<?>> map = typeHandlerMap.get(javaType);
      if (map == null || map == NULL_TYPE_HANDLER_MAP) {
        map = new HashMap<>();
      }
      map.put(jdbcType, handler);
      typeHandlerMap.put(javaType, map);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, this happening a couple times in a week on startup. But our apps work like as "lamba" (many cold startups in a loop).

I agree, this will save a couple of code lines 👍

Copy link
Member

Choose a reason for hiding this comment

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

I see. That explains it.
The fix is merged and should be available in the latest 3.5.4-SNAPSHOT.
Please let me know if you noticed anything.

Thank you for the PR, @PVlyubinskiy !

LyubinskiyPavel and others added 2 commits January 22, 2020 21:06
- Moved the test case and simplified it a little bit.
- Updated license years.
@harawata harawata merged commit cad947f into mybatis:master Jan 23, 2020
@harawata harawata self-assigned this Jan 23, 2020
@harawata harawata added the bug label Jan 23, 2020
@harawata harawata added this to the 3.5.4 milestone Jan 23, 2020
@harawata harawata assigned harawata and unassigned harawata Jan 23, 2020
@harawata harawata removed the bug label Jan 23, 2020
@harawata harawata removed this from the 3.5.4 milestone Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants