Avoid exception when getting zero-length xattr on mac#1041
Avoid exception when getting zero-length xattr on mac#1041jrobhoward wants to merge 2 commits intojava-native-access:masterfrom jrobhoward:jhoward/allow_zerolen_xattr_macos
Conversation
|
Thank you - the change looks reasonable. Could you please also add an entry to the For the other methods: I would not use exceptions - it is not exceptional, that a value is not set/set to the empty string. So if a method returns a Memory object and a length of 0 is indicated, I would return null for the Memory object. For a byte[] there is a valid value representing the "empty" byte array. |
|
I added the changelog entry, and updated the Linux XAttrUtil implementation so it returns null instead of throwing exceptions when attempting to create zero-length Memory objects. I did not alter |
|
Merged via: bc22845 Your changes are completely included - I added unittests to verify the behavior and moved the changelog entry to the correct place. I have to apologize, the commit only lists me as author - I did multiple rebases and somewhere along the way, your authorship got lost. I ensured though, that you are listed as author in the |
On MacOS, reading a zero-sized xattr will result in an IllegalArgumentException:
The code change associated with this pull request returns an empty string before attempting to allocate
Memory(0).null) and (an empty xattr, return value="").This only appears to be a problem on MacOS' implementation of
getXAttr(). Linux will return an empty string.getXAttrAsMemory()methods that will produce a similar problem, but I'm not sure what would be the most appropriate: (IllegalArgumentException, IOException, null return value) --so I didn't make any changes.