Skip to content
Snippets Groups Projects
Commit e7f9ee82 authored by piotr.kupczyk@id.ethz.ch's avatar piotr.kupczyk@id.ethz.ch
Browse files

SSDM-14065 : UsageReportingTask fails with NPE if samples without space were created

parent a51d529f
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
...@@ -131,7 +131,7 @@ public class UsageGatherer ...@@ -131,7 +131,7 @@ public class UsageGatherer
fetchOptions.withSpace(); fetchOptions.withSpace();
fetchOptions.withRegistrator(); fetchOptions.withRegistrator();
List<Sample> samples = service.searchSamples(sessionToken, searchCriteria, fetchOptions).getObjects(); List<Sample> samples = service.searchSamples(sessionToken, searchCriteria, fetchOptions).getObjects();
Function<Sample, String> spaceExtractor = sample -> sample.getSpace().getCode(); Function<Sample, String> spaceExtractor = sample -> sample.getSpace() != null ? sample.getSpace().getCode() : null;
gatherUsage(usageByUsersAndSpaces, samples, spaceExtractor, UsageInfo::addNewSample); gatherUsage(usageByUsersAndSpaces, samples, spaceExtractor, UsageInfo::addNewSample);
} }
...@@ -155,8 +155,15 @@ public class UsageGatherer ...@@ -155,8 +155,15 @@ public class UsageGatherer
if (experiment != null) if (experiment != null)
{ {
return experiment.getProject().getSpace().getCode(); return experiment.getProject().getSpace().getCode();
} }
return dataSet.getSample().getSpace().getCode();
Sample sample = dataSet.getSample();
if (sample != null)
{
return sample.getSpace() != null ? sample.getSpace().getCode() : null;
}
return null;
} }
}; };
gatherUsage(usageByUsersAndSpaces, dataSets, spaceExtractor, UsageInfo::addNewDataSet); gatherUsage(usageByUsersAndSpaces, dataSets, spaceExtractor, UsageInfo::addNewDataSet);
...@@ -172,7 +179,7 @@ public class UsageGatherer ...@@ -172,7 +179,7 @@ public class UsageGatherer
if (usageBySpaces != null) if (usageBySpaces != null)
{ {
String space = spaceExtractor.apply(entity); String space = spaceExtractor.apply(entity);
if (spacesToBeIgnored.contains(space) == false) if (space != null && spacesToBeIgnored.contains(space) == false)
{ {
UsageInfo usageInfo = usageBySpaces.get(space); UsageInfo usageInfo = usageBySpaces.get(space);
if (usageInfo == null) if (usageInfo == null)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment