Skip to content

Commit 57092d0

Browse files
authored
Updated the error handling in case the error reporter is null (#71)
1 parent 849f1fa commit 57092d0

File tree

1 file changed

+9
-1
lines changed
  • streaming-connect-sink/src/main/java/com/adobe/platform/streaming/sink/impl

1 file changed

+9
-1
lines changed

streaming-connect-sink/src/main/java/com/adobe/platform/streaming/sink/impl/AEPPublisher.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,21 @@ public void publishData(List<Pair<String, SinkRecord>> messages) throws AEPStrea
124124
LOG.error("Failed to publish data to Adobe Experience Platform", jsonException);
125125
if (Objects.nonNull(errorReporter)) {
126126
messages.forEach(message -> errorReporter.report(message.getValue(), jsonException));
127+
} else {
128+
throw new AEPStreamingException("Failed to publish invalid JSON", jsonException);
127129
}
128130
} catch (HttpException httpException) {
129131
LOG.error("Failed to publish data to Adobe Experience Platform", httpException);
132+
133+
final int responseCode = httpException.getResponseCode();
130134
if (Objects.nonNull(errorReporter)) {
131135
messages.forEach(message -> errorReporter.report(message.getValue(), httpException));
136+
} else {
137+
if (HttpUtil.is500(responseCode)) {
138+
throw new AEPStreamingException("Failed to publish", httpException);
139+
}
132140
}
133-
final int responseCode = httpException.getResponseCode();
141+
134142
if (HttpUtil.isUnauthorized(responseCode)) {
135143
throw new AEPStreamingException("Failed to publish", httpException);
136144
}

0 commit comments

Comments
 (0)