Skip to content

Commit

Permalink
dcache-xroot: check that descriptor is not null before calling close
Browse files Browse the repository at this point in the history
Motivation:

```
05 Dec 2023 16:29:55 (dcache-cms199-01) [] An exception java.lang.NullPointerException
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.dcache.xrootd.pool.XrootdPoolRequestHandler.removeAllDescriptorsAtomically(XrootdPoolRequestHandler.java:948)
at org.dcache.xrootd.pool.XrootdPoolRequestHandler.exceptionCaught(XrootdPoolRequestHandler.java:277)
```

as reported on Slack channel.

Modification:

Should check for `null` before closing descriptor.

Result:

The NPE does not swallow the actual exception from `exceptionCaught`.

Target: master
Request: 9.2
Request: 9.1
Request: 9.0
Patch: https://rb.dcache.org/r/14180/
Requires-notes: yes
Acked-by: Lea
  • Loading branch information
alrossi authored and lemora committed Dec 8, 2023
1 parent 711b4a3 commit 84e5af5
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -18,6 +18,7 @@
package org.dcache.xrootd.pool;

import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.util.function.Predicate.not;
import static org.dcache.xrootd.protocol.XrootdProtocol.UUID_PREFIX;
import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_ArgInvalid;
import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_ArgMissing;
Expand Down Expand Up @@ -945,7 +946,7 @@ private FileDescriptor getDescriptorAtomically(int fd) throws XrootdException {

@GuardedBy("writeLock")
private void removeAllDescriptorsAtomically() {
_descriptors.forEach(FileDescriptor::close);
_descriptors.stream().filter(not(null)).forEach(FileDescriptor::close);
_descriptors.clear();
}

Expand Down

0 comments on commit 84e5af5

Please sign in to comment.