I have an API.
@GET
@Path("picture")
@Produces("image/jpeg")
Response getPicture(@QueryParam("key") String key);
The corresponding service.
@Override
public Response getPicture(String key) {
try{
byte[] image = service.getPicture(key);
if (image == null) {
}
return Response.ok(new ByteArrayInputStream(image)).build();
} catch (Exception e) {
}
return null;
}
I try to return null and return Response.ok(new ByteArrayInputStream(null)).build(), but I will get an exception.
What does this method return when image is empty?