Skip to content

Commit

Permalink
DataObjectInfo should not throw NPE when it is not serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Dec 1, 2023
1 parent ded879b commit 7162006
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ public boolean isAnnotated() {
}

public TypeInfo getJsonType() {
return deserializer != null ? deserializer.getJsonType() : serializer.getJsonType();
if (deserializer != null) {
return deserializer.getJsonType();
} else if (serializer != null) {
return serializer.getJsonType();
} else {
return null;
}
}

public MapperInfo getSerializer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.codegen.doc.Doc;
import io.vertx.codegen.type.*;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.test.codegen.annotations.EmptyAnnotation;
Expand Down Expand Up @@ -951,4 +952,18 @@ private void assertInvalidDataObject(Class<?> dataObjectClass) throws Exception
} catch (GenException ignore) {
}
}

@Test
public void testBuffer() throws Exception {
DataObjectModel model = new GeneratorHelper()
.generateDataObject(BufferHolder.class);
assertNotNull(model);
assertTrue(model.isClass());

PropertyInfo prop = model.getPropertyMap().get("buffer");
assertNotNull(prop);
assertFalse(prop.getType().getDataObject().isDeserializable());
assertFalse(prop.getType().getDataObject().isSerializable());
assertNull(prop.getType().getDataObject().getJsonType());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.vertx.test.codegen.testdataobject;

import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.buffer.Buffer;

@DataObject
public class BufferHolder {

private Buffer buffer;

public Buffer getBuffer() {
return buffer;
}

public void setBuffer(Buffer buffer) {
this.buffer = buffer;
}
}

0 comments on commit 7162006

Please sign in to comment.