Skip to content

Commit 1d1e239

Browse files
committed
Update the javadoc for the CompositeCodec class.
Change the `ClassUtils.findClosestMatch` `failOnTie` to true. In the past when finding the appropriate delegate(codec) for a object and their were multiple delegates available the first one was returned. The problem is it could return a different delegate on each launch of the `findDelegate`. Now with `failOnTie` set to true a `IllegalStateException` is returned.
1 parent 5aeee02 commit 1d1e239

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spring-integration-core/src/main/java/org/springframework/integration/codec/CompositeCodec.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
import org.springframework.util.Assert;
2828

2929
/**
30-
* A Codec that can delegate to one out of many Codecs, each mapped to a class.
30+
* An implementation of {@link Codec} that combines multiple codecs into a single codec,
31+
* delegating encoding and decoding operations to the appropriate type-specific codec.
32+
* This implementation associates object types with their appropriate codecs while providing a fallback default codec
33+
* for unregistered types.
3134
* @author David Turanski
3235
* @author Glenn Renfro
3336
* @since 4.2
@@ -79,7 +82,7 @@ public <T> T decode(byte[] bytes, Class<T> type) throws IOException {
7982
}
8083

8184
private Codec findDelegate(Class<?> type) {
82-
Class<?> clazz = ClassUtils.findClosestMatch(type, this.delegates.keySet(), false);
85+
Class<?> clazz = ClassUtils.findClosestMatch(type, this.delegates.keySet(), true);
8386
return clazz == null ? this.defaultCodec : this.delegates.getOrDefault(clazz, this.defaultCodec);
8487
}
8588

0 commit comments

Comments
 (0)