From 7a6fb572135b951b3f118a98d2529eaaa80a7fb9 Mon Sep 17 00:00:00 2001 From: Shinsuke Sugaya Date: Sun, 15 Mar 2026 17:29:49 +0900 Subject: [PATCH] fix(upload): update commons-fileupload API and add IOException handling Update deprecated setSizeMax/setFileCountMax to setMaxSize/setMaxFileCount and handle IOException from DiskFileItem.getString() after API change. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../sponsor/FessMultipartRequestHandler.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/sponsor/FessMultipartRequestHandler.java b/src/main/java/org/codelibs/fess/mylasta/direction/sponsor/FessMultipartRequestHandler.java index faa50a997d..279acf6172 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/sponsor/FessMultipartRequestHandler.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/sponsor/FessMultipartRequestHandler.java @@ -192,8 +192,8 @@ protected void throwTooLongBoundarySizeException(final String contentType, final protected void setupServletFileUpload(final JakartaServletDiskFileUpload upload, final HttpServletRequest request) { upload.setHeaderCharset(Charset.forName(request.getCharacterEncoding())); - upload.setSizeMax(getSizeMax()); - upload.setFileCountMax(getFileCountMax()); // since commons-fileupload-1.5 + upload.setMaxSize(getSizeMax()); + upload.setMaxFileCount(getFileCountMax()); // since commons-fileupload-1.5 } protected long getSizeMax() { @@ -235,7 +235,11 @@ protected void showFieldLoggingTitle() { protected void showFormFieldParameter(final DiskFileItem item) { if (logger.isDebugEnabled()) { - logger.debug("[param] {}={}", item.getFieldName(), item.getString()); + try { + logger.debug("[param] {}={}", item.getFieldName(), item.getString()); + } catch (final IOException e) { + logger.debug("[param] {}=(failed to read)", item.getFieldName()); + } } } @@ -263,7 +267,11 @@ protected void addTextParameter(final HttpServletRequest request, final DiskFile try { value = item.getString(Charset.forName("ISO-8859-1")); } catch (final java.io.UnsupportedEncodingException uee) { - value = item.getString(); + try { + value = item.getString(); + } catch (final IOException e) { + throw new IllegalStateException("Failed to get string from the item: " + item, e); + } } catch (final IOException e) { throw new IllegalStateException("Failed to get string from the item: " + item, e); }