Skip to content

The way of using ReentrantLock in ProcessQueue and RouteInfoManagerlock.lockInterruptibly() #4112

@dugenkui03

Description

@dugenkui03

What is the purpose of the change

  1. The current approach like below, will swallow the InterruptedException and rise an IllegalMonitorStateException. This problem will affect the ’exception monitor data’ and performance.
            try{
                try{
                    lock.lockInterruptibly();
                    // do something
                }finally {
                    lock.unlock();
                }
            }catch (Exception e){
                // error log
            }

当前使用方式造成的问题是:lock.lockInterruptibly() 抛出异常的话会仍然会调用 finally 中的代码块lock.unlocklock.unlock会抛出异常并被catch` 捕获,由此造成异常监控不准确问题,并对性能有轻微影响。

  1. In ProcessQueue#fillProcessQueueInfo, if an InterruptedException is thrown by #lockInterruptibly, then a RuntimeException IllegalMonitorStateException will be throw from fillProcessQueueInfo because the invoke of #unlock in finally code block.

ProcessQueue#fillProcessQueueInfo中:如果调用#lockInterruptibly 时抛出检查异常InterruptedException、则会导致调用#unlock并由此抛出运行异常IllegalMonitorStateException并在ProcessQueue#fillProcessQueueInfo抛出。

Brief changelog

Details in the pr that refers to this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions