Skip to content

Commit

Permalink
Merge pull request #414 from TAMULib/august-sprint-334
Browse files Browse the repository at this point in the history
Handle possible null from solrClient.getById
  • Loading branch information
wwelling authored Aug 2, 2024
2 parents 4ca1f6c + 4e5cd7e commit cb7083e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -407,8 +408,8 @@ private Individual getById(String id) {
try {
SolrDocument document = solrClient.getById(collectionName, id);

return Individual.from(document);
} catch (IOException | SolrServerException e) {
return Objects.nonNull(document) ? Individual.from(document) : null;
} catch (IOException | NullPointerException | SolrServerException e) {
throw new SolrRequestException("Failed to get document by id", e);
}
}
Expand Down

0 comments on commit cb7083e

Please sign in to comment.