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

请不要吞没和忽略 java.lang.InterruptedException #785

Closed
chaosky opened this issue Jan 29, 2015 · 4 comments
Closed

请不要吞没和忽略 java.lang.InterruptedException #785

chaosky opened this issue Jan 29, 2015 · 4 comments

Comments

@chaosky
Copy link

chaosky commented Jan 29, 2015

你好:

DruidDataSource.java 的 1281 的 lock.lockInterruptibly() 行会产生 InterruptedException, 请不要在 catch (Throwable e) 里面忽略异常, 这样上层无法收到中断. 可以重新抛出异常或者重新设置中断状态. 抛出异常对客户来说比较有好, 可以和jdk库抛出的中断统一处理. 也请检查其他你们库中的其他地方是否忽略了中断. 谢谢.

关联代码为:

            final long lastActiveTimeMillis = System.currentTimeMillis();
            lock.lockInterruptibly();  // 这里产生的中断异常请重新抛出
            try {
                activeCount--;
                closeCount++;

                putLast(holder, lastActiveTimeMillis);
                recycleCount++;
            } finally {
                lock.unlock();
            }
        } catch (Throwable e) {
            holder.clearStatementCache();

            if (!holder.isDiscard()) {
                this.discardConnection(physicalConnection);
                holder.setDiscard(true);
            }

            LOG.error("recyle error", e);
            recycleErrorCount.incrementAndGet();
        }
@wenshao
Copy link
Member

wenshao commented Jun 7, 2015

不吃掉也抛不出来啊

@wenshao wenshao closed this as completed Jun 7, 2015
@chaosky
Copy link
Author

chaosky commented Jun 8, 2015

那就请重新设置中断状态(也可以异步抛出的). 直接忽略的话上层通过中断来通知业务停止处理时, 如果调用了druid的相关方法会导致业务层收不到中断通知.

@xiaxianggo
Copy link

一般在什么情况下这边会产生 InterruptedException,其他数据库没怎么遇到 最近用odbc连接azure,这边频繁中断

@darren-fu
Copy link

对待issues的态度是真差

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

4 participants