mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-22 14:09:25 +00:00
Refine Kotlin Serialization codec type checks
ServerSentEvent and String checks, removed from KotlinSerializationSupport in Spring Framework 7.0, are reintroduced by this commit at the right level (KotlinSerializationSupport for ServerSentEvent and KotlinSerializationString(Decoder|Encoder) for String). Closes gh-35885
This commit is contained in:
+1
-1
@@ -102,7 +102,7 @@ public abstract class KotlinSerializationStringDecoder<T extends StringFormat> e
|
||||
|
||||
@Override
|
||||
public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType) {
|
||||
return canSerialize(elementType, mimeType);
|
||||
return canSerialize(elementType, mimeType) && !CharSequence.class.isAssignableFrom(elementType.toClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ public abstract class KotlinSerializationStringEncoder<T extends StringFormat> e
|
||||
|
||||
@Override
|
||||
public boolean canEncode(ResolvableType elementType, @Nullable MimeType mimeType) {
|
||||
return canSerialize(elementType, mimeType);
|
||||
return canSerialize(elementType, mimeType) && !String.class.isAssignableFrom(elementType.toClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ public abstract class KotlinSerializationSupport<T extends SerialFormat> {
|
||||
if (!this.typePredicate.test(type) || ResolvableType.NONE.equals(type)) {
|
||||
return false;
|
||||
}
|
||||
return serializer(type) != null && supports(mimeType);
|
||||
return serializer(type) != null && supports(mimeType) && !ServerSentEvent.class.isAssignableFrom(type.toClass());
|
||||
}
|
||||
|
||||
private boolean supports(@Nullable MimeType mimeType) {
|
||||
|
||||
Reference in New Issue
Block a user