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

not thread-safe, and advice to use List.foreach #3046

Open
siyuqxxx opened this issue Dec 25, 2023 · 4 comments
Open

not thread-safe, and advice to use List.foreach #3046

siyuqxxx opened this issue Dec 25, 2023 · 4 comments

Comments

@siyuqxxx
Copy link

siyuqxxx commented Dec 25, 2023

https://github.com/mybatis/mybatis-3/blob/1d68154c353b83aed792203c586a83f6e2e3146a/src/main/java/org/apache/ibatis/plugin/InterceptorChain.java#L30C36-L30C48

Caused by: java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:911)
at java.util.ArrayList$Itr.next(ArrayList.java:861)
at org.apache.ibatis.plugin.InterceptorChain.pluginAll(InterceptorChain.java:30)
at org.apache.ibatis.session.Configuration.newResultSetHandler(Configuration.java:676)
at org.apache.ibatis.executor.statement.BaseStatementHandler.<init>(BaseStatementHandler.java:70)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.<init>(PreparedStatementHandler.java:41)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.<init>(RoutingStatementHandler.java:46)
at org.apache.ibatis.session.Configuration.newStatementHandler(Configuration.java:681)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:61)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:89)
... 20 more

@harawata
Copy link
Member

Hello @siyuqxxx ,

This seems to mean that the statement is called before all interceptors are added.
Could you explain how that happens?

@siyuqxxx
Copy link
Author

siyuqxxx commented Jan 25, 2024

During service startup, async query db in @PostConstruct

@harawata
Copy link
Member

Can you provide a demo project with minimum setup?
I would like to see what you are doing and how the issue occurs.
Here are project templates and some examples: https://github.com/harawata/mybatis-issues

@oah1021
Copy link
Contributor

oah1021 commented Jan 26, 2024

I think the query operation should be performed after all the interceptors have been added.

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

No branches or pull requests

3 participants