Juan Hernandez has uploaded a new change for review. Change subject: restapi: Don't use inner classes in LinkBuilder ......................................................................
restapi: Don't use inner classes in LinkBuilder We use anonymous classes in a rather unusual way in the LinkBuilder. We do the follwing: whatever.setBody(new Body(){{setType(type);}}); Instead of this: Body body = new Body(); body.setType(type); whatever.setBody(body); The former is probably nicer syntax, but it has the side effect of introducing a synthetic field in the anonymous subclass of Body that the compiler generates automatically. This synthetic field is a reference to the outer LinkHelper class. When Jackson tries to convert this object to JSON it finds the synthetic field, and tries to serialize it as well. This fails because the LinkHelper class doesn't have a suitable constructor. The net effect is an error when the server tries to return an error message to the user. The solution is to avoid completely the anonymous classes, and thus the synthetic fields. Change-Id: I10e0ecb68b3e0d412de486c3a38dbefa3c4dd9d2 Bug-Url: https://bugzilla.redhat.com/1093755 Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com> --- M backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/rsdl/RsdlBuilder.java 1 file changed, 8 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/27380/1 diff --git a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/rsdl/RsdlBuilder.java b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/rsdl/RsdlBuilder.java index 3afaaef..ba987a0 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/rsdl/RsdlBuilder.java +++ b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/rsdl/RsdlBuilder.java @@ -199,16 +199,17 @@ return this; } public LinkBuilder requestParameter(final String requestParameter) { - link.setRequest(new Request()); - link.getRequest().setBody(new org.ovirt.engine.api.model.Body() { - { - setType(requestParameter); - } - }); + org.ovirt.engine.api.model.Body body = new org.ovirt.engine.api.model.Body(); + body.setType(requestParameter); + Request request = new Request(); + request.setBody(body); + link.setRequest(request); return this; } public LinkBuilder responseType(final String responseType) { - link.setResponse(new Response(){{setType(responseType);}}); + Response response = new Response(); + response.setType(responseType); + link.setResponse(response); return this; } public LinkBuilder httpMethod(HttpMethod httpMethod) { -- To view, visit http://gerrit.ovirt.org/27380 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I10e0ecb68b3e0d412de486c3a38dbefa3c4dd9d2 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches