Skip to content

Commit

Permalink
findbugs(server-endpoint): This is a false positive, result can be nu…
Browse files Browse the repository at this point in the history
…ll here. See spotbugs/spotbugs#259
  • Loading branch information
Delawen committed Jul 3, 2020
1 parent ae7f6c6 commit adbad8d
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import static javax.ws.rs.core.HttpHeaders.CONTENT_LENGTH;
import static javax.ws.rs.core.HttpHeaders.CONTENT_TYPE;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand Down Expand Up @@ -72,6 +73,7 @@ public final class ConnectorIconHandler extends BaseHandler {
@ApiResponse(responseCode = "200", description = "Updated Connector icon")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@SuppressFBWarnings
@SuppressWarnings("PMD.CyclomaticComplexity")
public Connector create(MultipartFormDataInput dataInput) {
if (dataInput == null || dataInput.getParts() == null || dataInput.getParts().isEmpty()) {
Expand All @@ -86,6 +88,10 @@ public Connector create(MultipartFormDataInput dataInput) {
InputPart filePart = dataInput.getParts().iterator().next();
try (InputStream result = filePart.getBody(InputStream.class, null)) {

if (result == null) {
throw new IllegalArgumentException("Can't find a valid 'icon' part in the multipart request");
}

try (BufferedInputStream iconStream = new BufferedInputStream(result)) {
MediaType mediaType = filePart.getMediaType();
if (!mediaType.getType().equals("image")) {
Expand Down

0 comments on commit adbad8d

Please sign in to comment.