Skip to content

Commit

Permalink
Fail when there are 2+ Trino announcements
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed May 13, 2024
1 parent 5dcbc62 commit 23882f2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions core/trino-main/src/main/java/io/trino/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import java.util.Optional;
import java.util.Set;

import static com.google.common.collect.MoreCollectors.toOptional;
import static io.airlift.discovery.client.ServiceAnnouncement.ServiceAnnouncementBuilder;
import static io.airlift.discovery.client.ServiceAnnouncement.serviceAnnouncement;
import static io.trino.server.TrinoSystemRequirements.verifyJvmRequirements;
Expand Down Expand Up @@ -268,12 +269,10 @@ private static void updateConnectorIds(Announcer announcer, CatalogManager catal

private static ServiceAnnouncement getTrinoAnnouncement(Set<ServiceAnnouncement> announcements)
{
for (ServiceAnnouncement announcement : announcements) {
if (announcement.getType().equals("trino")) {
return announcement;
}
}
throw new IllegalArgumentException("Trino announcement not found: " + announcements);
return announcements.stream()
.filter(announcement -> announcement.getType().equals("trino"))
.collect(toOptional())
.orElseThrow(() -> new IllegalArgumentException("Trino announcement not found: " + announcements));
}

private static void logLocation(Logger log, String name, Path path)
Expand Down

0 comments on commit 23882f2

Please sign in to comment.