Fix HawkbitClient multipart support for return void (#2258)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -68,12 +68,11 @@ public class HawkbitClient {
|
|||||||
Objects.requireNonNull(tenant.getPassword(),
|
Objects.requireNonNull(tenant.getPassword(),
|
||||||
"Password is not available!"))
|
"Password is not available!"))
|
||||||
.getBytes(StandardCharsets.ISO_8859_1)))
|
.getBytes(StandardCharsets.ISO_8859_1)))
|
||||||
:
|
: template -> {
|
||||||
template -> {
|
|
||||||
if (ObjectUtils.isEmpty(tenant.getGatewayToken())) {
|
if (ObjectUtils.isEmpty(tenant.getGatewayToken())) {
|
||||||
if (!ObjectUtils.isEmpty(controller.getSecurityToken())) {
|
if (!ObjectUtils.isEmpty(controller.getSecurityToken())) {
|
||||||
template.header(AUTHORIZATION, "TargetToken " + controller.getSecurityToken());
|
template.header(AUTHORIZATION, "TargetToken " + controller.getSecurityToken());
|
||||||
} // else do not sent authentication
|
} // else do not send authentication
|
||||||
} else {
|
} else {
|
||||||
template.header(AUTHORIZATION, "GatewayToken " + tenant.getGatewayToken());
|
template.header(AUTHORIZATION, "GatewayToken " + tenant.getGatewayToken());
|
||||||
}
|
}
|
||||||
@@ -209,12 +208,16 @@ public class HawkbitClient {
|
|||||||
out.write(("--" + boundary + "--\r\n").getBytes(StandardCharsets.UTF_8));
|
out.write(("--" + boundary + "--\r\n").getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
return method.getReturnType() == ResponseEntity.class
|
return method.getReturnType() == ResponseEntity.class
|
||||||
? new ResponseEntity<Object>(
|
? new ResponseEntity<>(
|
||||||
objectMapper.readValue(
|
deserialize(
|
||||||
conn.getInputStream(),
|
conn.getInputStream(),
|
||||||
(Class<?>) ((ParameterizedType) method.getGenericReturnType()).getActualTypeArguments()[0]),
|
(Class<?>) ((ParameterizedType) method.getGenericReturnType()).getActualTypeArguments()[0],
|
||||||
|
objectMapper),
|
||||||
HttpStatusCode.valueOf(conn.getResponseCode()))
|
HttpStatusCode.valueOf(conn.getResponseCode()))
|
||||||
: objectMapper.readValue(conn.getInputStream(), method.getReturnType());
|
: deserialize(conn.getInputStream(), method.getReturnType(), objectMapper);
|
||||||
|
}
|
||||||
|
private Object deserialize(final InputStream is, final Class<?> type, final ObjectMapper objectMapper) throws IOException {
|
||||||
|
return type == void.class || type == Void.class ? null : objectMapper.readValue(is, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeMultipartFile(
|
private void writeMultipartFile(
|
||||||
|
|||||||
Reference in New Issue
Block a user