parent
519f0cf69e
commit
2f53a32f9d
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 5773
|
||||
title: "Subscriptions with null content caused NullPointerExceptions. This condition is now checked and handled."
|
|
@ -205,6 +205,9 @@ public class SubscriptionWebsocketHandler extends TextWebSocketHandler implement
|
|||
* @return The payload
|
||||
*/
|
||||
private Optional<String> getPayloadByContent(ResourceDeliveryMessage msg) {
|
||||
if (msg.getSubscription().getContent() == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
switch (msg.getSubscription().getContent()) {
|
||||
case IDONLY:
|
||||
return Optional.of(msg.getPayloadId());
|
||||
|
|
|
@ -59,6 +59,36 @@ public class WebsocketWithSubscriptionIdR5Test extends BaseSubscriptionsR5Test {
|
|||
myWebsocketClientExtension.afterEach(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriptionMessagePayloadContentIsNull() {
|
||||
// Given a subscription
|
||||
Subscription subscription = new Subscription();
|
||||
subscription.setStatus(Enumerations.SubscriptionStatusCodes.ACTIVE);
|
||||
subscription.setContent(null);
|
||||
subscription.setTopic("Topic/123");
|
||||
subscription.getChannelType().setCode("websocket");
|
||||
MethodOutcome methodOutcome = myClient.create().resource(subscription).execute();
|
||||
String subscriptionId = methodOutcome.getId().getIdPart();
|
||||
|
||||
// When
|
||||
myWebsocketClientExtension.bind(subscriptionId);
|
||||
|
||||
// And
|
||||
// Trigger resource creation
|
||||
Patient patient = new Patient();
|
||||
patient.setActive(true);
|
||||
myClient.create().resource(patient).execute();
|
||||
|
||||
// Then
|
||||
List<String> messages = myWebsocketClientExtension.getMessages();
|
||||
await().until(() -> !messages.isEmpty());
|
||||
|
||||
// Log it
|
||||
ourLog.info("Messages: {}", messages);
|
||||
|
||||
// Verify a ping message shall be returned
|
||||
Assertions.assertTrue(messages.contains("ping " + subscriptionId));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriptionMessagePayloadContentIsEmpty() {
|
||||
|
|
Loading…
Reference in New Issue