No fielderror for empty files with ActionFileUploadInterceptor

Ute Kaiser <[email protected]> Wed, 1 Oct 2025 16:02:47 +0000
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <trinity-d30aae5a-e9bc-45cf-b21d-bb1450ab5827-1759334567593@trinity-msg-rest-webde-webde-live-6bc9d76d67-bv9mx>
Hi,

I would appreaciate a field error when I try to upload an empty file=2E

I only find a server log warning
WARN  [org=2Eapache=2Estruts2=2Einterceptor=2EActionFileUploadInterceptor]=
 (default task-2) Es konnte kein Dateiname f=C3=BCr uploadDe ermittelt werd=
en=2E =C3=9Cberpr=C3=BCfen Sie ob eine g=C3=BCltige Datei =C3=BCbermittelt =
wurde=2E
(German properties-Key struts=2Emessages=2Einvalid=2Efile=3DCould not find=
 a Filename for {0}=2E Verify that a valid file was submitted=2E)

ActionFileUploadInterceptor=2Eintercept runs into the if, so all nice erro=
rs from acceptFile are not reachable=2E
            if (uploadedFiles =3D=3D null || uploadedFiles=2Elength =3D=3D=
 0) {
                if (LOG=2EisWarnEnabled()) {
                    LOG=2Ewarn(getTextMessage(action, STRUTS_MESSAGES_INVA=
LID_FILE_KEY, new String[]{inputName}));
                }
            } else {
                for (UploadedFile uploadedFile : uploadedFiles) {
                    if (acceptFile(action, uploadedFile, uploadedFile=2Ege=
tOriginalName(), uploadedFile=2EgetContentType(), inputName)) {
                        acceptedFiles=2Eadd(uploadedFile);
                    }
                }
            }

It seems impossible to write a field error on my own=2E
(I have 3 upload options, so I can not raise an error if one of them is nu=
ll=2E)

Best regards
Ute