[ 
https://issues.apache.org/jira/browse/HDFS-5195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13766833#comment-13766833
 ] 

Colin Patrick McCabe commented on HDFS-5195:
--------------------------------------------

mlock and munlock are able to handle {{NULL}} pointers on their own, without 
any assistance from us.  They will simply fail with {{ENOMEM}}.  

I do agree that it's helpful to print out a special error message in this case 
to let the user know that JNI access to direct buffers is not available.  
However, I would rather not put the check in like you have it here, since it's 
an extra "if" statement we have to execute all the time, even though 99.9999% 
of the time it does nothing.  Let's add the check after mlock or munlock fails.
                
> Prevent passing null pointer to mlock and munlock.
> --------------------------------------------------
>
>                 Key: HDFS-5195
>                 URL: https://issues.apache.org/jira/browse/HDFS-5195
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: datanode
>    Affects Versions: HDFS-4949
>            Reporter: Chris Nauroth
>            Assignee: Chris Nauroth
>         Attachments: HDFS-5195.1.patch
>
>
> According to JNI documentation, it is optional for the JVM to support the 
> {{GetDirectBufferAddress}} function.  If unsupported, then the function will 
> return null.  This is probably a very rare thing, but let's be defensive by 
> checking the return value for null and throwing an exception instead of 
> passing null down to {{mlock}} and {{munlock}}.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to