[ https://issues.apache.org/jira/browse/HDFS-9590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15067266#comment-15067266 ]
Xiao Chen commented on HDFS-9590: --------------------------------- Thanks [~liuml07] for the comments. bq. Do you mean {{Storage$StorageDirectory#unlock()}}? There is no Storage#unlock method. Yes, sorry I was unclear. Updated the title. bq. Would you kindly elaborate what kind of "synchronization mechanism" do you expect to add? I don't know all the design assumption here either, but this code itself is to wrap a lock. My concern is that if 2 threads are calling unlock(), and both passed the null check in the beginning, then if 1 proceed to set {{lock = null}}, the other will throw the NPE in the stack trace above. I'm thinking of adding synchronized to the method, or perhaps more sophisticated protection outside. This NPE seems fundamental, so I'm looking around to see what background stories there are... > NPE in Storage#unlock > --------------------- > > Key: HDFS-9590 > URL: https://issues.apache.org/jira/browse/HDFS-9590 > Project: Hadoop HDFS > Issue Type: Bug > Reporter: Xiao Chen > Assignee: Xiao Chen > > The code looks to be possible to have race conditions in multiple-threaded > runs. > {code} > public void unlock() throws IOException { > if (this.lock == null) > return; > this.lock.release(); > lock.channel().close(); > lock = null; > } > {code} > This is called in a handful of places, and I don't see any protection. Shall > we add some synchronization mechanism? Not sure if I missed any design > assumptions here. -- This message was sent by Atlassian JIRA (v6.3.4#6332)