Skip to content

Commit

Permalink
resilience: do not return null if tag map is null
Browse files Browse the repository at this point in the history
Motivation:

The expected result of the call to PoolInfoMap.getTags() is an
empty map even for uninitialized pools, not null.  The case
where there is no pool information entry was being handled
correctly, but not the case where the information object
was not yet entirely initialized.   This was causing an NPE
in one of the handler methods.

Modification:

Make the method return empty map in the latter case as well.

Result:

No NPE.
  • Loading branch information
alrossi authored and alrossi committed Mar 28, 2016
1 parent 69cc5b9 commit fdd6c30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -554,7 +554,13 @@ public Map<String, String> getTags(Integer pool) {
if (info == null) {
return ImmutableMap.of();
}
return info.getTags();

Map<String, String> tags = info.getTags();
if (tags == null) {
return ImmutableMap.of();
}

return tags;
}

public Set<Integer> getValidLocations(Collection<Integer> locations,
Expand Down
Expand Up @@ -678,7 +678,7 @@ public void update(String pool, int children) {
* <p>Called by the {@link PnfsOperationMap) when a child operation completes.</p>
*/
public void update(String pool, PnfsId pnfsId) {
LOGGER.trace("Parent {}, child operation for {} has canceled.", pool,
LOGGER.trace("Parent {}, child operation for {} has completed.", pool,
pnfsId);
lock.lock();
try {
Expand Down

0 comments on commit fdd6c30

Please sign in to comment.