https://bz.apache.org/bugzilla/show_bug.cgi?id=62768

            Bug ID: 62768
           Summary: OPCPackage#close() method is incorrectly synchronized
           Product: POI
           Version: 4.0.0-FINAL
          Hardware: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: OPC
          Assignee: dev@poi.apache.org
          Reporter: b...@mail.ru
  Target Milestone: ---

Created attachment 36168
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36168&action=edit
multi-thread runner

There is a code in OPCPackage#close() method, which creates and uses a lock:

ReentrantReadWriteLock l = new ReentrantReadWriteLock();
                try {
                        l.writeLock().lock();
...
} finally {
  l.writeLock().unlock();
}

However, it is completely useless since the *new* lock object is always created
for any method execution, thus voiding this lock.

Suggested change - either move l to a class field and initialize it in
constructor, or simply use synchronized section as read/write lock is not
really needed here.

I attached the sample which runs close() method from multiple thread - as you
can see, they are not synchronized with each other.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to