Fixing dead lock issue in application locking in rest api