From issues-return-34600-apmail-struts-issues-archive=struts.apache.org@struts.apache.org Wed Oct 14 13:26:05 2020 Return-Path: X-Original-To: apmail-struts-issues-archive@locus.apache.org Delivered-To: apmail-struts-issues-archive@locus.apache.org Received: from mailroute1-lw-us.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with ESMTP id EF1461A4F9 for ; Wed, 14 Oct 2020 13:26:04 +0000 (UTC) Received: from mail.apache.org (localhost [127.0.0.1]) by mailroute1-lw-us.apache.org (ASF Mail Server at mailroute1-lw-us.apache.org) with SMTP id 9C3011223F6 for ; Wed, 14 Oct 2020 13:26:04 +0000 (UTC) Received: (qmail 85351 invoked by uid 500); 14 Oct 2020 13:26:03 -0000 Delivered-To: apmail-struts-issues-archive@struts.apache.org Received: (qmail 85278 invoked by uid 500); 14 Oct 2020 13:26:03 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 85173 invoked by uid 99); 14 Oct 2020 13:26:03 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Oct 2020 13:26:03 +0000 Received: from jira2-he-de.apache.org (static.54.33.119.168.clients.your-server.de [168.119.33.54]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id A5FC145C57 for ; Wed, 14 Oct 2020 13:26:01 +0000 (UTC) Received: from jira2-he-de.apache.org (localhost.localdomain [127.0.0.1]) by jira2-he-de.apache.org (ASF Mail Server at jira2-he-de.apache.org) with ESMTP id 6E5BDC8085D for ; Wed, 14 Oct 2020 13:26:00 +0000 (UTC) Date: Wed, 14 Oct 2020 13:26:00 +0000 (UTC) From: "ASF subversion and git services (Jira)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (WW-5088) Empty file upload gives wrong error message MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/WW-5088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17213914#comment-17213914 ] ASF subversion and git services commented on WW-5088: ----------------------------------------------------- Commit 08fb2d71ad4098d841b88b335cff6f0738c0f104 in struts's branch refs/heads/master from Pierre-Yves Soblet [ https://gitbox.apache.org/repos/asf?p=struts.git;h=08fb2d7 ] WW-5088: Add licence to FileUploadTest. > Empty file upload gives wrong error message > ------------------------------------------- > > Key: WW-5088 > URL: https://issues.apache.org/jira/browse/WW-5088 > Project: Struts 2 > Issue Type: Bug > Components: Core Interceptors > Affects Versions: 2.5.22 > Reporter: Greg Huber > Priority: Minor > Fix For: 2.6 > > Time Spent: 1h 50m > Remaining Estimate: 0h > > On an empty file upload the storeLocation is null, so adds a file new StrutsUploadedFile(null) > JakartaMultiPartRequest > {code:java} > List fileList = new ArrayList<>(items.size()); > for (FileItem fileItem : items) { > File storeLocation = ((DiskFileItem) fileItem).getStoreLocation(); > if (fileItem.isInMemory() && storeLocation != null && !storeLocation.exists()) { > try { > storeLocation.createNewFile(); > } catch (IOException e) { > LOG.error("Cannot write uploaded empty file to disk: {}", storeLocation.getAbsolutePath(), e); > } > } > fileList.add(new StrutsUploadedFile(storeLocation)); > } > {code} > The FileUploadInterceptor checks for a null file but not null content from the new StrutsUploadedFile(null). > eg for an empty file main.js > Error message should be: > Error uploading: main.js > but gives: > Error setting expression 'uploadedFiles' with value ['org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@202585bc', ] > Error setting expression 'uploadedFiles' with value ['org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@49553150', ] -- This message was sent by Atlassian Jira (v8.3.4#803005)