mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-03-09 14:33:32 +00:00
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
|
* @return The payload
|
||||||
*/
|
*/
|
||||||
private Optional<String> getPayloadByContent(ResourceDeliveryMessage msg) {
|
private Optional<String> getPayloadByContent(ResourceDeliveryMessage msg) {
|
||||||
|
if (msg.getSubscription().getContent() == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
switch (msg.getSubscription().getContent()) {
|
switch (msg.getSubscription().getContent()) {
|
||||||
case IDONLY:
|
case IDONLY:
|
||||||
return Optional.of(msg.getPayloadId());
|
return Optional.of(msg.getPayloadId());
|
||||||
|
@ -59,6 +59,36 @@ public class WebsocketWithSubscriptionIdR5Test extends BaseSubscriptionsR5Test {
|
|||||||
myWebsocketClientExtension.afterEach(null);
|
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
|
@Test
|
||||||
public void testSubscriptionMessagePayloadContentIsEmpty() {
|
public void testSubscriptionMessagePayloadContentIsEmpty() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user