diff --git a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/AbstractSimpleTranslatorResponseKuraKapua.java b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/AbstractSimpleTranslatorResponseKuraKapua.java index 2aff8c1e01e..fee31bf36be 100644 --- a/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/AbstractSimpleTranslatorResponseKuraKapua.java +++ b/translator/kapua/kura/src/main/java/org/eclipse/kapua/translator/kura/kapua/AbstractSimpleTranslatorResponseKuraKapua.java @@ -27,6 +27,7 @@ import org.eclipse.kapua.service.device.management.message.response.KapuaResponsePayload; import org.eclipse.kapua.service.device.management.request.GenericRequestFactory; import org.eclipse.kapua.service.device.management.request.message.response.GenericResponseMessage; +import org.eclipse.kapua.service.device.management.request.message.response.GenericResponsePayload; import org.eclipse.kapua.translator.exception.InvalidChannelException; import org.eclipse.kapua.translator.exception.InvalidPayloadException; import org.eclipse.kapua.translator.exception.TranslatorErrorCodes; @@ -91,7 +92,14 @@ public Class getClassTo() { @Override protected TO_P translatePayload(KuraResponsePayload kuraResponsePayload) throws InvalidPayloadException { try { - TO_P appResponsePayload = payloadClazz.newInstance(); + GenericRequestFactory genericRequestFactory = LOCATOR.getFactory(GenericRequestFactory.class); + + TO_P appResponsePayload; + if (payloadClazz.equals(GenericResponsePayload.class)) { + appResponsePayload = this.payloadClazz.cast(genericRequestFactory.newResponsePayload()); + } else { + appResponsePayload = payloadClazz.newInstance(); + } appResponsePayload.setExceptionMessage(kuraResponsePayload.getExceptionMessage());