Skip to content

Commit

Permalink
Dev UI - Reactive Messaging - fix NPE when a channel is not configured
Browse files Browse the repository at this point in the history
- resolves quarkusio#15293
  • Loading branch information
mkouba committed Feb 24, 2021
1 parent a9b7a96 commit eea49d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{#if it}
{#when it.type}
{#case PUBLISHER}
<i class="fas fa-sign-out-alt"></i> Publisher:
Expand All @@ -12,4 +13,5 @@
{#case CHANNEL}
<i class="fas fa-syringe"></i> Channel:
{/when}
{it.description.raw}
{it.description.raw}
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static class DevChannelInfo implements Comparable<DevChannelInfo> {
public DevChannelInfo(String name, Component publisher, List<Component> consumers) {
this.name = name;
this.publisher = publisher;
this.consumers = consumers;
this.consumers = consumers != null ? consumers : Collections.emptyList();
}

public String getName() {
Expand All @@ -138,18 +138,26 @@ public List<Component> getConsumers() {

@Override
public int compareTo(DevChannelInfo other) {
// publisher connectors first
if (publisher.type != other.publisher.type) {
return publisher.type == ComponentType.CONNECTOR ? -1 : 1;
if (publisher != other.publisher) {
if (other.publisher == null) {
return -1;
}
if (publisher == null) {
return 1;
}
// publisher connectors first
if (publisher.type != other.publisher.type) {
return publisher.type == ComponentType.CONNECTOR ? -1 : 1;
}
}
// consumer connectors last
long consumerConnetors = consumers.stream().filter(Component::isConnector).count();
long otherConsumersConnectors = other.consumers.stream().filter(Component::isConnector).count();
if (consumerConnetors != otherConsumersConnectors) {
return Long.compare(otherConsumersConnectors, consumerConnetors);
}

if (publisher.type == ComponentType.CONNECTOR && other.publisher.type != ComponentType.CONNECTOR) {
if (publisher != other.publisher && publisher.type == ComponentType.CONNECTOR
&& other.publisher.type != ComponentType.CONNECTOR) {
return 1;
}
// alphabetically
Expand Down

0 comments on commit eea49d4

Please sign in to comment.