Skip to content
Snippets Groups Projects
Commit 4a8337e3 authored by Rustam Lotsmanenko (EPAM)'s avatar Rustam Lotsmanenko (EPAM)
Browse files

temp fix

parent ad71d5f6
No related branches found
No related tags found
1 merge request!432Fix NPE during delivery
Pipeline #214119 failed
......@@ -18,6 +18,7 @@
package org.opengroup.osdu.notification.provider.gcp.config;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
......@@ -50,7 +51,14 @@ public class ExternalSubscriptionsManager {
List<Subscription> cachedInfos = Optional.ofNullable(getExternalSubscriptions(dataPartitionId))
.orElseThrow(() -> new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Server error", "OQM | Subscription info cache was not initialized"))
.getSubscriptions();
return getFilteredSubscription(cachedInfos, dataPartitionId, subscriptionId, serviceTopic);
Subscription subscription = getFilteredSubscription(cachedInfos, dataPartitionId,
subscriptionId, serviceTopic);
if (Objects.nonNull(subscription) && Objects.isNull(subscription.getSecret())) {
return sendGetSubscriptionRequest(dataPartitionId, subscriptionId, serviceTopic, cachedInfos);
}
return subscription;
}
private Subscription getFilteredSubscription(List<Subscription> subscriptions, String dataPartitionId,
......
......@@ -16,6 +16,7 @@
package org.opengroup.osdu.notification.provider.gcp.pubsub;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpStatus;
......@@ -57,6 +58,12 @@ public class OqmNotificationHandler {
}
Subscription subscription = externalSubscriptionsManager.getSubscription(dataPartitionId, subscriptionId, serviceTopic);
if (Objects.isNull(subscription)) {
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR,
"Subscriber config not found.",
String.format("Subscriber with id: %s not found in cache", subscriptionId)
);
}
Secret secret = subscription.getSecret();
SecretAuth secretAuth = authFactory.getSecretAuth(secret.getSecretType());
......
......@@ -17,6 +17,7 @@
package org.opengroup.osdu.notification.provider.gcp.pubsub.receiver;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.opengroup.osdu.core.common.http.HttpResponse;
import org.opengroup.osdu.core.common.model.http.AppException;
......@@ -27,8 +28,6 @@ import org.opengroup.osdu.core.gcp.oqm.model.OqmSubscription;
import org.opengroup.osdu.notification.provider.gcp.pubsub.OqmNotificationHandler;
import org.opengroup.osdu.notification.provider.gcp.thread.ThreadScopeContextHolder;
import java.util.Map;
@Slf4j
public class OqmPublishTopicReceiver implements OqmMessageReceiver {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment