|
1 | 1 | /*
|
2 |
| - * Copyright 2017-2023 the original author or authors. |
| 2 | + * Copyright 2017-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
34 | 34 | import org.springframework.messaging.MessageHeaders;
|
35 | 35 | import org.springframework.util.Assert;
|
36 | 36 | import org.springframework.util.ClassUtils;
|
37 |
| -import org.springframework.util.MimeType; |
38 | 37 |
|
39 | 38 | import com.fasterxml.jackson.core.JsonProcessingException;
|
40 | 39 | import com.fasterxml.jackson.core.type.TypeReference;
|
41 |
| -import com.fasterxml.jackson.databind.DeserializationContext; |
42 |
| -import com.fasterxml.jackson.databind.JsonNode; |
43 | 40 | import com.fasterxml.jackson.databind.ObjectMapper;
|
44 |
| -import com.fasterxml.jackson.databind.deser.std.StdNodeBasedDeserializer; |
45 |
| -import com.fasterxml.jackson.databind.module.SimpleModule; |
46 |
| -import com.fasterxml.jackson.databind.node.TextNode; |
47 |
| -import com.fasterxml.jackson.databind.type.TypeFactory; |
48 | 41 |
|
49 | 42 | /**
|
50 | 43 | * Default header mapper for Apache Kafka.
|
@@ -163,8 +156,6 @@ private DefaultKafkaHeaderMapper(boolean outbound, ObjectMapper objectMapper, St
|
163 | 156 | Assert.notNull(objectMapper, "'objectMapper' must not be null");
|
164 | 157 | Assert.noNullElements(patterns, "'patterns' must not have null elements");
|
165 | 158 | this.objectMapper = objectMapper;
|
166 |
| - this.objectMapper |
167 |
| - .registerModule(new SimpleModule().addDeserializer(MimeType.class, new MimeTypeJsonDeserializer())); |
168 | 159 | }
|
169 | 160 |
|
170 | 161 | /**
|
@@ -426,39 +417,6 @@ protected boolean trusted(String requestedType) {
|
426 | 417 | return true;
|
427 | 418 | }
|
428 | 419 |
|
429 |
| - |
430 |
| - /** |
431 |
| - * The {@link StdNodeBasedDeserializer} extension for {@link MimeType} deserialization. |
432 |
| - * It is presented here for backward compatibility when older producers send {@link MimeType} |
433 |
| - * headers as serialization version. |
434 |
| - */ |
435 |
| - private class MimeTypeJsonDeserializer extends StdNodeBasedDeserializer<MimeType> { |
436 |
| - |
437 |
| - private static final long serialVersionUID = 1L; |
438 |
| - |
439 |
| - MimeTypeJsonDeserializer() { |
440 |
| - super(MimeType.class); |
441 |
| - } |
442 |
| - |
443 |
| - @Override |
444 |
| - public MimeType convert(JsonNode root, DeserializationContext ctxt) throws IOException { |
445 |
| - if (root instanceof TextNode) { |
446 |
| - return MimeType.valueOf(root.asText()); |
447 |
| - } |
448 |
| - else { |
449 |
| - JsonNode type = root.get("type"); |
450 |
| - JsonNode subType = root.get("subtype"); |
451 |
| - JsonNode parameters = root.get("parameters"); |
452 |
| - Map<String, String> params = |
453 |
| - DefaultKafkaHeaderMapper.this.objectMapper.readValue(parameters.traverse(), |
454 |
| - TypeFactory.defaultInstance() |
455 |
| - .constructMapType(HashMap.class, String.class, String.class)); |
456 |
| - return new MimeType(type.asText(), subType.asText(), params); |
457 |
| - } |
458 |
| - } |
459 |
| - |
460 |
| - } |
461 |
| - |
462 | 420 | /**
|
463 | 421 | * Represents a header that could not be decoded due to an untrusted type.
|
464 | 422 | */
|
|
0 commit comments