Skip to content

Commit 643a056

Browse files
committed
* Remove generic arg from the ContentTypeDelegatingDataMarshaller
1 parent e79579a commit 643a056

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

spring-integration-core/src/main/java/org/springframework/integration/support/cloudevents/ContentTypeDelegatingDataMarshaller.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,34 @@
4444
*
4545
* @since 5.3
4646
*/
47-
public class ContentTypeDelegatingDataMarshaller<T> implements DataMarshaller<byte[], T, String> {
47+
public class ContentTypeDelegatingDataMarshaller implements DataMarshaller<byte[], Object, String> {
4848

4949
private final DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory();
5050

5151
private final List<Encoder<?>> encoders = new ArrayList<>();
5252

53-
@SafeVarargs
54-
public ContentTypeDelegatingDataMarshaller(Encoder<T>... encoders) {
53+
public ContentTypeDelegatingDataMarshaller(Encoder<?>... encoders) {
5554
this.encoders.add(CharSequenceEncoder.allMimeTypes());
5655
setEncoders(encoders);
5756
}
5857

59-
@SafeVarargs
60-
public final void setEncoders(Encoder<T>... encoders) {
58+
public final void setEncoders(Encoder<?>... encoders) {
6159
Assert.notNull(encoders, "'encoders' must not be null");
6260
Assert.noNullElements(encoders, "'encoders' must not contain null elements");
6361
this.encoders.addAll(Arrays.asList(encoders));
6462
}
6563

6664
@Override
6765
@SuppressWarnings({ "unchecked", "rawtypes" })
68-
public byte[] marshal(T data, Map<String, String> headers) throws RuntimeException {
66+
public byte[] marshal(Object data, Map<String, String> headers) throws RuntimeException {
6967
String contentType = headers.get(MessageHeaders.CONTENT_TYPE);
7068
if (contentType == null) { // Assume JSON by default
7169
return Json.binaryMarshal(data, headers);
7270
}
7371
else {
7472
ResolvableType elementType = ResolvableType.forClass(data.getClass());
7573
MimeType mimeType = MimeType.valueOf(contentType);
76-
Encoder<T> encoder = encoder(elementType, mimeType);
74+
Encoder<Object> encoder = encoder(elementType, mimeType);
7775
DataBuffer dataBuffer =
7876
encoder.encodeValue(data, this.dataBufferFactory, elementType,
7977
mimeType, (Map<String, Object>) (Map) headers);
@@ -86,10 +84,10 @@ public byte[] marshal(T data, Map<String, String> headers) throws RuntimeExcepti
8684
}
8785

8886
@SuppressWarnings("unchecked")
89-
private Encoder<T> encoder(ResolvableType elementType, MimeType mimeType) {
87+
private Encoder<Object> encoder(ResolvableType elementType, MimeType mimeType) {
9088
for (Encoder<?> encoder : this.encoders) {
9189
if (encoder.canEncode(elementType, mimeType)) {
92-
return (Encoder<T>) encoder;
90+
return (Encoder<Object>) encoder;
9391
}
9492
}
9593
throw new IllegalArgumentException("No encoder for " + elementType);

spring-integration-core/src/main/java/org/springframework/integration/transformer/ToCloudEventTransformer.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ public enum Result {
7272

7373
private final URI source;
7474

75-
private final ContentTypeDelegatingDataMarshaller<Object> dataMarshaller =
76-
new ContentTypeDelegatingDataMarshaller<>();
75+
private final ContentTypeDelegatingDataMarshaller dataMarshaller = new ContentTypeDelegatingDataMarshaller();
7776

7877
@Nullable
7978
private final EventStep<AttributesImpl, Object, byte[], String> wireBuilder;
@@ -136,8 +135,7 @@ public void setExtensionExpression(@Nullable Expression extensionExpression) {
136135
* Plus {@link MessageHeaders#CONTENT_TYPE} must be present in the request message.
137136
* @param encoders the {@link Encoder}s to use.
138137
*/
139-
@SafeVarargs
140-
public final void setEncoders(Encoder<Object>... encoders) {
138+
public final void setEncoders(Encoder<?>... encoders) {
141139
this.dataMarshaller.setEncoders(encoders);
142140
}
143141

0 commit comments

Comments
 (0)