Skip to content

Commit

Permalink
Fixing the NullPointerException in RoutingDataSourceHealthContributor
Browse files Browse the repository at this point in the history
The RoutingDataSourceHealthContributor constructor throws a NullPointerException (NPE) if the provided map has a null key. With this commit the NPE issue has been fixed by filtering the entries that are not-null. 

This closes spring-projects#27694
  • Loading branch information
safeeransari-gc committed Aug 16, 2021
1 parent b65cc4d commit 8d241d8
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ static class RoutingDataSourceHealthContributor implements CompositeHealthContri
RoutingDataSourceHealthContributor(AbstractRoutingDataSource routingDataSource,
Function<DataSource, HealthContributor> contributorFunction) {
Map<String, DataSource> routedDataSources = routingDataSource.getResolvedDataSources().entrySet().stream()
.filter((e) -> e.getKey() != null)
.collect(Collectors.toMap((e) -> e.getKey().toString(), Map.Entry::getValue));
this.delegate = CompositeHealthContributor.fromMap(routedDataSources, contributorFunction);
}
Expand Down

0 comments on commit 8d241d8

Please sign in to comment.