Skip to content

Commit

Permalink
Merge branch '2.17' into 2.18
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jul 25, 2024
2 parents be59471 + 47cdf69 commit a4f7c54
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fasterxml.jackson.dataformat.protobuf.schemagen;

import java.nio.ByteBuffer;
import java.util.UUID;

import com.fasterxml.jackson.databind.*;

Expand Down Expand Up @@ -55,6 +56,8 @@ public static boolean hasIndex(BeanProperty writer) {

public static boolean isBinaryType(JavaType type) {
return type.hasRawClass(byte[].class)
// 24-Jul-2024, tatu: [dataformats-binary#506] UUID as Binary
|| type.hasRawClass(UUID.class)
|| type.isTypeOrSubTypeOf(ByteBuffer.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.fasterxml.jackson.dataformat.protobuf.schema;

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.UUID;

import org.junit.Assert;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper;
import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase;
Expand Down Expand Up @@ -43,6 +46,17 @@ public void testWithUUID() throws Exception
{
ProtobufSchema schema = MAPPER.generateSchemaFor(UUIDBean.class);
assertNotNull(schema);

UUIDBean input = new UUIDBean();
input.messageId = UUID.nameUUIDFromBytes("abc".getBytes(StandardCharsets.UTF_8));

byte[] proto = MAPPER.writer().with(schema)
.writeValueAsBytes(input);
UUIDBean result = MAPPER.readerFor(UUIDBean.class)
.with(schema)
.readValue(proto);
assertNotNull(result.messageId);
assertEquals(input.messageId, result.messageId);
}

// [dataformats-binary#68]
Expand All @@ -56,5 +70,17 @@ public void testWithBinary() throws Exception
{
ProtobufSchema schema = MAPPER.generateSchemaFor(BinaryBean.class);
assertNotNull(schema);

// But let's try round-tripping too
BinaryBean input = new BinaryBean();
input.data = new byte[] { 1, 2, -1 };

byte[] proto = MAPPER.writer().with(schema)
.writeValueAsBytes(input);
BinaryBean result = MAPPER.readerFor(BinaryBean.class)
.with(schema)
.readValue(proto);
assertNotNull(result.data);
Assert.assertArrayEquals(input.data, result.data);
}
}
5 changes: 5 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Active maintainers:
(requested by Joachim L)
(contributed by Michal F)

2.17.3 (not yet released)

#506: Cannot deserialize `UUID` values
(reported by @uniquonil)

2.17.2 (05-Jul-2024)

#497: (ion) Failed copy(): `IonValueMapper` does not override copy()
Expand Down

0 comments on commit a4f7c54

Please sign in to comment.