Skip to content

Commit 39a63b6

Browse files
committed
[UNDERTOW-2617] remove unecessary exception wrapping in MultiPart
1 parent 47e1b06 commit 39a63b6

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

core/src/main/java/io/undertow/server/handlers/form/MultiPartParserDefinition.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ public FormData parseBlocking() throws IOException {
253253
} else {
254254
throw UndertowMessages.MESSAGES.failedToAllocateResource();
255255
}
256-
} catch (MalformedMessageException e) {
257-
throw new IOException(e);
258256
}
259257
return exchange.getAttachment(FORM_DATA);
260258
}
@@ -323,15 +321,16 @@ public void data(final ByteBuffer buffer) throws IOException {
323321
throw UndertowMessages.MESSAGES.maxFileSizeExceeded(this.maxIndividualFileSize);
324322
}
325323
if (file == null && fileSizeThreshold < this.currentFileSize && (fileName != null || this.currentFileSize > fieldSizeThreshold)) {
326-
try {
327-
createdFiles.add(createFile());
324+
createdFiles.add(createFile());
328325

329-
FileOutputStream fileOutputStream = new FileOutputStream(file.toFile());
326+
FileOutputStream fileOutputStream = new FileOutputStream(file.toFile());
327+
try {
330328
contentBytes.writeTo(fileOutputStream);
331329

332330
fileChannel = fileOutputStream.getChannel();
333-
} catch (IOException e) {
334-
throw new RuntimeException(e);
331+
} catch (IOException ioe) {
332+
fileOutputStream.close();
333+
throw ioe;
335334
}
336335
}
337336

core/src/main/java/io/undertow/util/MultipartParser.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,7 @@ public void handle(final PartHandler handler, final ByteBuffer rawData) throws I
384384
try {
385385
do {
386386
buf.clear();
387-
try {
388-
decoder.decode(rawData, buf);
389-
} catch (IOException e) {
390-
throw new RuntimeException(e);
391-
}
387+
decoder.decode(rawData, buf);
392388
buf.flip();
393389
handler.data(buf);
394390
} while (rawData.hasRemaining());

0 commit comments

Comments
 (0)