File tree 3 files changed +55
-6
lines changed
main/java/com/fasterxml/jackson/dataformat/avro
test/java/com/fasterxml/jackson/dataformat/avro
3 files changed +55
-6
lines changed Original file line number Diff line number Diff line change @@ -167,7 +167,12 @@ public AvroFactory copy()
167
167
public boolean requiresPropertyOrdering () {
168
168
return true ;
169
169
}
170
-
170
+
171
+ @ Override // since 2.10 (should have been earlier)
172
+ public boolean canHandleBinaryNatively () {
173
+ return true ;
174
+ }
175
+
171
176
/*
172
177
/**********************************************************
173
178
/* Serializable overrides
Original file line number Diff line number Diff line change @@ -205,11 +205,6 @@ public int getOutputBuffered() {
205
205
return -1 ;
206
206
}
207
207
208
- @ Override
209
- public boolean canUseSchema (FormatSchema schema ) {
210
- return (schema instanceof AvroSchema );
211
- }
212
-
213
208
@ Override public AvroSchema getSchema () {
214
209
return _rootSchema ;
215
210
}
@@ -224,6 +219,22 @@ public void setSchema(FormatSchema schema)
224
219
setSchema ((AvroSchema ) schema );
225
220
}
226
221
222
+ /*
223
+ /**********************************************************
224
+ /* Public API, capability introspection methods
225
+ /**********************************************************
226
+ */
227
+
228
+ @ Override
229
+ public boolean canUseSchema (FormatSchema schema ) {
230
+ return (schema instanceof AvroSchema );
231
+ }
232
+
233
+ // 10-Sep-2019, Tatu: Should implement wrt [dataformats-binary#179], but...
234
+ // can't. Not yet, will just break things. Wait until 2.11
235
+ // @Override
236
+ // public boolean canWriteBinaryNatively() { return true; }
237
+
227
238
/*
228
239
/**********************************************************
229
240
/* Extended API, configuration
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .dataformat .avro ;
2
+
3
+ import java .util .UUID ;
4
+
5
+ // @since 2.10
6
+ public class UUIDTest extends AvroTestBase
7
+ {
8
+ static class UUIDWrapper {
9
+ public UUID id ;
10
+
11
+ protected UUIDWrapper () { }
12
+ public UUIDWrapper (UUID u ) { id = u ; }
13
+ }
14
+
15
+ private final AvroMapper MAPPER = newMapper ();
16
+
17
+ // 10-Sep-2019, tatu: as per [dataformats-binary#179], should really serialize
18
+ // UUID as binary, but due to various complications can not make it work
19
+ // safely and reliably with 2.10; can only add some foundational support.
20
+ public void testUUIDRoundtrip () throws Exception
21
+ {
22
+ final AvroSchema schema = MAPPER .schemaFor (UUIDWrapper .class );
23
+ //System.err.println("DEBUG: schema -> "+schema.getAvroSchema());
24
+ UUIDWrapper input = new UUIDWrapper (UUID .nameUUIDFromBytes ("BOGUS" .getBytes ("UTF-8" )));
25
+ byte [] avro = MAPPER .writer (schema ).writeValueAsBytes (input );
26
+
27
+ UUIDWrapper output = MAPPER .readerFor (UUIDWrapper .class )
28
+ .with (schema )
29
+ .readValue (avro );
30
+
31
+ assertEquals (input .id , output .id );
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments