refactor: 각 어댑터터별 리펙토링 진행
This commit is contained in:
@@ -4,5 +4,7 @@ dependencies {
|
||||
api project(':messaging:messaging-core-api')
|
||||
api project(':messaging:messaging-schema-api')
|
||||
|
||||
implementation 'com.google.protobuf:protobuf-java:4.29.3'
|
||||
// api: ProtobufMessageContract is a public record over com.google.protobuf.Message and
|
||||
// Parser, and registering a contract is the first thing a consumer of this codec does.
|
||||
api 'com.google.protobuf:protobuf-java:4.29.3'
|
||||
}
|
||||
|
||||
+14
@@ -15,6 +15,7 @@ import com.google.protobuf.Parser;
|
||||
import dev.caskeleton.messaging.api.ContentType;
|
||||
import dev.caskeleton.messaging.api.MessageType;
|
||||
import dev.caskeleton.messaging.api.SchemaVersion;
|
||||
import dev.caskeleton.messaging.api.error.MessageSerializationException;
|
||||
import dev.caskeleton.messaging.api.error.MessageTooLargeException;
|
||||
import dev.caskeleton.messaging.api.error.MessageValidationException;
|
||||
import dev.caskeleton.messaging.api.error.MessagingConfigurationException;
|
||||
@@ -231,6 +232,19 @@ class ProtobufCompatibilityTest {
|
||||
assertThat(codec.encode(ORDER_CREATED, V1, v1Message()).bytes()).hasSize(exact);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aLengthPrefixNoPayloadOfThisSizeCouldHonourIsADecodeFailure() {
|
||||
ProtobufMessageCodec codec = codec(V1_DESCRIPTOR);
|
||||
// Tag 1, wire type 2 (length-delimited), then a varint claiming four hundred million bytes
|
||||
// follow. The whole message is six bytes, so it passes the size limit; what must not happen is
|
||||
// the parser reserving the claimed length before discovering there is nothing behind it.
|
||||
byte[] hostile = {0x0A, (byte) 0x80, (byte) 0x88, (byte) 0xDE, (byte) 0xBE, 0x01};
|
||||
|
||||
assertThatThrownBy(() -> codec.decode(ORDER_CREATED, V1, hostile, DynamicMessage.class))
|
||||
.isInstanceOf(MessageSerializationException.class)
|
||||
.hasMessageContaining("protobuf");
|
||||
}
|
||||
|
||||
@Test
|
||||
void theEncodedMessageCarriesItsSchemaReference() {
|
||||
EncodedMessage encoded = codec(V1_DESCRIPTOR, V2).encode(ORDER_CREATED, V2, v1Message());
|
||||
|
||||
Reference in New Issue
Block a user