Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4636

File upload error message always in default language

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.28
    • Fix Version/s: 2.5.8
    • Component/s: None
    • Labels:
      None

      Description

      Struts 2 allows to redefine error messages when an upload fails (as documented in https://cwiki.apache.org/confluence/display/WW/File+Upload).

      For instance, if I upload a file with a size greater than allowed by the configuration using fileUpload interceptor and commons-fileupload dependency, the following key of my resource bundle is used :

      struts.messages.upload.error.SizeLimitExceededException=File size exceeded (in i18n.properties).
      

      However, when the current language is not the default one, the translated key (in i18n_fr.properties for instance) is not taken into account (the default language is used instead).

      The issue seems similar to WW-3177 (that was fixed in 2.3.7).

      1. Struts2i18nTest.zip
        6 kB
        Pierre-Yves Soblet

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user victorsosa closed the pull request at:

          https://github.com/apache/struts/pull/97

          Show
          githubbot ASF GitHub Bot added a comment - Github user victorsosa closed the pull request at: https://github.com/apache/struts/pull/97
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user victorsosa commented on the issue:

          https://github.com/apache/struts/pull/97

          done

          Show
          githubbot ASF GitHub Bot added a comment - Github user victorsosa commented on the issue: https://github.com/apache/struts/pull/97 done
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user aleksandr-m commented on the issue:

          https://github.com/apache/struts/pull/97

          @victorsosa, @lukaszlenart Please close this one. WW-4636 is fixed in https://github.com/apache/struts/pull/113.

          Show
          githubbot ASF GitHub Bot added a comment - Github user aleksandr-m commented on the issue: https://github.com/apache/struts/pull/97 @victorsosa, @lukaszlenart Please close this one. WW-4636 is fixed in https://github.com/apache/struts/pull/113 .
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Struts-JDK7-master #546 (See https://builds.apache.org/job/Struts-JDK7-master/546/)
          WW-4636 - File upload error message always in default language (amashchenko: rev 835cc7cd096ba274ffd71e54115dbefc63cadffd)

          • (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
          • (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java
          • (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
          • (edit) plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
          • (edit) core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java
          • (edit) core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
          • (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
          • (add) core/src/main/java/org/apache/struts2/dispatcher/LocalizedMessage.java
            WW-4636 - File upload error message always in default language (lukaszlenart: rev 33ac7ac49aabfcf792d38fa44d271a93433ffe56)
          • (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
          • (edit) plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
          • (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java
          • (edit) core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
          • (add) core/src/main/java/org/apache/struts2/dispatcher/LocalizedMessage.java
          • (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
          • (edit) core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java
          • (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Struts-JDK7-master #546 (See https://builds.apache.org/job/Struts-JDK7-master/546/ ) WW-4636 - File upload error message always in default language (amashchenko: rev 835cc7cd096ba274ffd71e54115dbefc63cadffd) (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java (edit) plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java (edit) core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java (edit) core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java (add) core/src/main/java/org/apache/struts2/dispatcher/LocalizedMessage.java WW-4636 - File upload error message always in default language (lukaszlenart: rev 33ac7ac49aabfcf792d38fa44d271a93433ffe56) (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java (edit) plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java (edit) core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java (add) core/src/main/java/org/apache/struts2/dispatcher/LocalizedMessage.java (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java (edit) core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java (edit) core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          PR merged, thanks!

          Show
          lukaszlenart Lukasz Lenart added a comment - PR merged, thanks!
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/struts/pull/113

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/struts/pull/113
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 70400f4a037784719d4b7da341df7efb6353dcf2 in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=70400f4 ]

          WW-4636 Fixes problem with File upload error message are always in default language

          Show
          jira-bot ASF subversion and git services added a comment - Commit 70400f4a037784719d4b7da341df7efb6353dcf2 in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=70400f4 ] WW-4636 Fixes problem with File upload error message are always in default language
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 835cc7cd096ba274ffd71e54115dbefc63cadffd in struts's branch refs/heads/master from Aleksandr Mashchenko
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=835cc7c ]

          WW-4636 - File upload error message always in default language

          Show
          jira-bot ASF subversion and git services added a comment - Commit 835cc7cd096ba274ffd71e54115dbefc63cadffd in struts's branch refs/heads/master from Aleksandr Mashchenko [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=835cc7c ] WW-4636 - File upload error message always in default language
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 33ac7ac49aabfcf792d38fa44d271a93433ffe56 in struts's branch refs/heads/master from Aleksandr Mashchenko
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=33ac7ac ]

          WW-4636 - File upload error message always in default language

          Show
          jira-bot ASF subversion and git services added a comment - Commit 33ac7ac49aabfcf792d38fa44d271a93433ffe56 in struts's branch refs/heads/master from Aleksandr Mashchenko [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=33ac7ac ] WW-4636 - File upload error message always in default language
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user aleksandr-m commented on the issue:

          https://github.com/apache/struts/pull/113

          Yep, we can close #97.

          Show
          githubbot ASF GitHub Bot added a comment - Github user aleksandr-m commented on the issue: https://github.com/apache/struts/pull/113 Yep, we can close #97.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user cnenning commented on the issue:

          https://github.com/apache/struts/pull/113

          :+1:

          That means #97 can be closed?

          Show
          githubbot ASF GitHub Bot added a comment - Github user cnenning commented on the issue: https://github.com/apache/struts/pull/113 :+1: That means #97 can be closed?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user lukaszlenart commented on the issue:

          https://github.com/apache/struts/pull/113

          Looks good to me, if no objections I'm going to merge it. Thanks, great work!

          Show
          githubbot ASF GitHub Bot added a comment - Github user lukaszlenart commented on the issue: https://github.com/apache/struts/pull/113 Looks good to me, if no objections I'm going to merge it. Thanks, great work!
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user aleksandr-m opened a pull request:

          https://github.com/apache/struts/pull/113

          WW-4636 - File upload error message always in default language

          Please review.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/aleksandr-m/struts feature/WW-4636

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/struts/pull/113.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #113


          commit 835cc7cd096ba274ffd71e54115dbefc63cadffd
          Author: Aleksandr Mashchenko <amashchenko@apache.org>
          Date: 2016-10-15T12:25:14Z

          WW-4636 - File upload error message always in default language


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user aleksandr-m opened a pull request: https://github.com/apache/struts/pull/113 WW-4636 - File upload error message always in default language Please review. You can merge this pull request into a Git repository by running: $ git pull https://github.com/aleksandr-m/struts feature/ WW-4636 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/struts/pull/113.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #113 commit 835cc7cd096ba274ffd71e54115dbefc63cadffd Author: Aleksandr Mashchenko <amashchenko@apache.org> Date: 2016-10-15T12:25:14Z WW-4636 - File upload error message always in default language
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user victorsosa commented on the pull request:

          https://github.com/apache/struts/pull/97#issuecomment-221640016

          @aleksandr-m It is set to English in here: https://github.com/apache/struts/blob/master/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java#L62

          get locale from the action context instead of request?... I will check that

          Show
          githubbot ASF GitHub Bot added a comment - Github user victorsosa commented on the pull request: https://github.com/apache/struts/pull/97#issuecomment-221640016 @aleksandr-m It is set to English in here: https://github.com/apache/struts/blob/master/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java#L62 get locale from the action context instead of request?... I will check that
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user aleksandr-m commented on the pull request:

          https://github.com/apache/struts/pull/97#issuecomment-221628543

          First of all, there is [some chance](https://github.com/apache/struts/blob/master/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java#L71) that `defaultLocale` isn't set to English.

          Can we get locale from the action context instead of request?

          Show
          githubbot ASF GitHub Bot added a comment - Github user aleksandr-m commented on the pull request: https://github.com/apache/struts/pull/97#issuecomment-221628543 First of all, there is [some chance] ( https://github.com/apache/struts/blob/master/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java#L71 ) that `defaultLocale` isn't set to English. Can we get locale from the action context instead of request?
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user victorsosa opened a pull request:

          https://github.com/apache/struts/pull/97

          WW-4636 File upload error message always in default language

          File upload error message always in default English language.

          Content negotiation is a mechanism defined in the HTTP specification is
          used in the code; now using the 'Accept-Language: us' in the request the language is choose.

          The bug was that it was always using the English language for the
          message.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/victorsosa/struts WW-4636

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/struts/pull/97.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #97


          commit da8b13a87ef0d6af54a8cabbc62d54fbca67f683
          Author: victor sosa <victorsosa@users.noreply.github.com>
          Date: 2016-03-03T18:16:11Z

          Merge pull request #8 from apache/master

          update pull

          commit a5d716393999110b3701563479a96e83136a8b97
          Author: victor sosa <victorsosa@users.noreply.github.com>
          Date: 2016-03-03T18:41:11Z

          Merge pull request #9 from victorsosa/easymock_update

          Easymock update

          commit 6bb1ec67ad539d4bf6850f8314ef521e06b8295e
          Author: victor sosa <victorsosa@users.noreply.github.com>
          Date: 2016-03-04T22:07:16Z

          Merge pull request #10 from apache/master

          pull update

          commit 379b75292e6d084dc881e71f0a826c45934d9df8
          Author: victor sosa <victorsosa@users.noreply.github.com>
          Date: 2016-03-27T18:43:40Z

          Merge pull request #11 from apache/master

          update pull

          commit 47cf4ff84b07523cca2e1c5571742368c5cb5556
          Author: victor sosa <victorsosa@users.noreply.github.com>
          Date: 2016-04-20T18:58:32Z

          Merge pull request #13 from apache/master

          update pull

          commit ca74ac36fc7eb60e41eeaa8a539771169f900dd6
          Author: victor sosa <victorsosa@users.noreply.github.com>
          Date: 2016-05-04T14:47:57Z

          Merge pull request #14 from apache/master

          update pull

          commit 6b360108e57b8986c6409b26cba9b3cd4f16a603
          Author: victorsosa <victor.sosa@peopleware.do>
          Date: 2016-05-17T12:37:13Z

          WW-4634

          commit b4facc8e0674851be581dc74cc262f275734a180
          Author: victor sosa <victorsosa@users.noreply.github.com>
          Date: 2016-05-17T12:39:51Z

          Merge pull request #15 from apache/master

          update pull

          commit f9e4a5e676c2fde1603aa0809cb44c71d2e7a122
          Author: victorsosa <victor.sosa@peopleware.do>
          Date: 2016-05-17T12:50:50Z

          Merge branch 'master' of github.com:victorsosa/struts

          commit ffdacf1b60b8bf1df54af004a5fd84752eb522b4
          Author: victorsosa <victor.sosa@peopleware.do>
          Date: 2016-05-17T13:00:33Z

          WW-4634

          commit b3507834016946a5d2206ac2c51d865199918a68
          Author: victorsosa <victor.sosa@peopleware.do>
          Date: 2016-05-25T12:02:05Z

          WW-4636

          File upload error message always in default language

          Content negotiation is a mechanism defined in the HTTP specification is
          used; now using the 'Accept-Language: us' in the request the language
          choose.

          The bug was that it was always using the English language for the
          message.

          commit 81ff4ae6cdd03f77439ddd9be35f4fe6130aa0e4
          Author: Victor Sosa <victor.sosa@peopleware.do>
          Date: 2016-05-25T12:23:18Z

          rollback

          commit 2272623fd82fe61c4c662c5f81af45ff2e1c882f
          Author: victorsosa <victor.sosa@peopleware.do>
          Date: 2016-05-25T12:27:18Z

          Merge branch 'WW-4636' of github.com:victorsosa/struts into WW-4636

          commit dcb8ac72e4491e878efecad662b3430e42446c80
          Author: victor sosa <victorsosa@users.noreply.github.com>
          Date: 2016-05-25T12:30:33Z

          Update styles.css


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user victorsosa opened a pull request: https://github.com/apache/struts/pull/97 WW-4636 File upload error message always in default language File upload error message always in default English language. Content negotiation is a mechanism defined in the HTTP specification is used in the code; now using the 'Accept-Language: us' in the request the language is choose. The bug was that it was always using the English language for the message. You can merge this pull request into a Git repository by running: $ git pull https://github.com/victorsosa/struts WW-4636 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/struts/pull/97.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #97 commit da8b13a87ef0d6af54a8cabbc62d54fbca67f683 Author: victor sosa <victorsosa@users.noreply.github.com> Date: 2016-03-03T18:16:11Z Merge pull request #8 from apache/master update pull commit a5d716393999110b3701563479a96e83136a8b97 Author: victor sosa <victorsosa@users.noreply.github.com> Date: 2016-03-03T18:41:11Z Merge pull request #9 from victorsosa/easymock_update Easymock update commit 6bb1ec67ad539d4bf6850f8314ef521e06b8295e Author: victor sosa <victorsosa@users.noreply.github.com> Date: 2016-03-04T22:07:16Z Merge pull request #10 from apache/master pull update commit 379b75292e6d084dc881e71f0a826c45934d9df8 Author: victor sosa <victorsosa@users.noreply.github.com> Date: 2016-03-27T18:43:40Z Merge pull request #11 from apache/master update pull commit 47cf4ff84b07523cca2e1c5571742368c5cb5556 Author: victor sosa <victorsosa@users.noreply.github.com> Date: 2016-04-20T18:58:32Z Merge pull request #13 from apache/master update pull commit ca74ac36fc7eb60e41eeaa8a539771169f900dd6 Author: victor sosa <victorsosa@users.noreply.github.com> Date: 2016-05-04T14:47:57Z Merge pull request #14 from apache/master update pull commit 6b360108e57b8986c6409b26cba9b3cd4f16a603 Author: victorsosa <victor.sosa@peopleware.do> Date: 2016-05-17T12:37:13Z WW-4634 commit b4facc8e0674851be581dc74cc262f275734a180 Author: victor sosa <victorsosa@users.noreply.github.com> Date: 2016-05-17T12:39:51Z Merge pull request #15 from apache/master update pull commit f9e4a5e676c2fde1603aa0809cb44c71d2e7a122 Author: victorsosa <victor.sosa@peopleware.do> Date: 2016-05-17T12:50:50Z Merge branch 'master' of github.com:victorsosa/struts commit ffdacf1b60b8bf1df54af004a5fd84752eb522b4 Author: victorsosa <victor.sosa@peopleware.do> Date: 2016-05-17T13:00:33Z WW-4634 commit b3507834016946a5d2206ac2c51d865199918a68 Author: victorsosa <victor.sosa@peopleware.do> Date: 2016-05-25T12:02:05Z WW-4636 File upload error message always in default language Content negotiation is a mechanism defined in the HTTP specification is used; now using the 'Accept-Language: us' in the request the language choose. The bug was that it was always using the English language for the message. commit 81ff4ae6cdd03f77439ddd9be35f4fe6130aa0e4 Author: Victor Sosa <victor.sosa@peopleware.do> Date: 2016-05-25T12:23:18Z rollback commit 2272623fd82fe61c4c662c5f81af45ff2e1c882f Author: victorsosa <victor.sosa@peopleware.do> Date: 2016-05-25T12:27:18Z Merge branch ' WW-4636 ' of github.com:victorsosa/struts into WW-4636 commit dcb8ac72e4491e878efecad662b3430e42446c80 Author: victor sosa <victorsosa@users.noreply.github.com> Date: 2016-05-25T12:30:33Z Update styles.css
          Hide
          victorsosa victorsosa added a comment -

          the bug right now, it is always using the English language. Inserting the Accept-Language: en-US in the request.

          Now it will use the Content negotiation to determine which language to use, as it suppose to.

          Base on: https://en.wikipedia.org/wiki/Content_negotiation

          Show
          victorsosa victorsosa added a comment - the bug right now, it is always using the English language. Inserting the Accept-Language: en-US in the request. Now it will use the Content negotiation to determine which language to use, as it suppose to. Base on: https://en.wikipedia.org/wiki/Content_negotiation
          Hide
          pys Pierre-Yves Soblet added a comment -

          I attach a sample application with a single page on which you can switch between languages and upload oversized files.
          You can see that when the page is displayed in French, the "my.message" label is translated while the "struts.messages.upload.error.SizeLimitExceededException" error message is not.

          Show
          pys Pierre-Yves Soblet added a comment - I attach a sample application with a single page on which you can switch between languages and upload oversized files. You can see that when the page is displayed in French, the "my.message" label is translated while the "struts.messages.upload.error.SizeLimitExceededException" error message is not.

            People

            • Assignee:
              aleksandr-m Aleksandr Mashchenko
              Reporter:
              pys Pierre-Yves Soblet
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development