Minor cleanup
This commit is contained in:
@@ -226,8 +226,8 @@ public final class CloudEventMessageUtils {
|
||||
|
||||
// first check the obvious and see if content-type is `cloudevents`
|
||||
if (!attributes.isValidCloudEvent() && headers.containsKey(MessageHeaders.CONTENT_TYPE)) {
|
||||
MimeType contentType = contentTypeResolver.resolve(inputMessage.getHeaders());
|
||||
if (contentType.getType().equals(CloudEventMessageUtils.APPLICATION_CLOUDEVENTS.getType())
|
||||
MimeType contentType = resolveContentType(inputMessage.getHeaders());
|
||||
if (contentType != null && contentType.getType().equals(CloudEventMessageUtils.APPLICATION_CLOUDEVENTS.getType())
|
||||
&& contentType.getSubtype().startsWith(CloudEventMessageUtils.APPLICATION_CLOUDEVENTS.getSubtype())) {
|
||||
|
||||
String dataContentType = StringUtils.hasText(attributes.getDataContentType())
|
||||
@@ -255,6 +255,16 @@ public final class CloudEventMessageUtils {
|
||||
return inputMessage;
|
||||
}
|
||||
|
||||
private static MimeType resolveContentType(MessageHeaders headers) {
|
||||
try {
|
||||
return contentTypeResolver.resolve(headers);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will attempt to determine based on the headers the origin of Message (e.g., HTTP, Kafka etc)
|
||||
* and based on this designate prefix to be used for Cloud Events attributes (i.e., `ce-` or `ce_` etc).
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.lang.reflect.Type;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.lang.reflect.WildcardType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -1073,7 +1072,7 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Object convertMultipleOutputValuesIfNecessary(Object output, String[] contentType) {
|
||||
Collection outputCollection = ObjectUtils.isArray(output) ? Arrays.asList(output) : (Collection) output;
|
||||
Collection outputCollection = ObjectUtils.isArray(output) ? CollectionUtils.arrayToList(output) : (Collection) output;
|
||||
Collection convertedOutputCollection = outputCollection instanceof List ? new ArrayList<>() : new TreeSet<>();
|
||||
Type type = this.isOutputTypeMessage() ? FunctionTypeUtils.getGenericType(this.outputType) : this.outputType;
|
||||
for (Object outToConvert : outputCollection) {
|
||||
|
||||
Reference in New Issue
Block a user