jersey
  1. jersey
  2. JERSEY-2464

Jersey 1.x: HeaderValueException: Unable to parse "Accept-Language" header value es-419

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: 1.18
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:

      tomcat 7, openjdk 7

      Description

      HTTP 400 Bad Request if the client sends Accept-Language: es-419 HTTP header.

      As found in production:

      WARNING: WebApplicationException cause:
      org.glassfish.jersey.message.internal.HeaderValueException: Unable to parse "Accept-Language" header value: "es-419,es;q=0.8,en-US;q=0.6,en;q=0.4"
      	at org.glassfish.jersey.message.internal.InboundMessageContext.exception(InboundMessageContext.java:335)
      	at org.glassfish.jersey.message.internal.InboundMessageContext.getQualifiedAcceptableLanguages(InboundMessageContext.java:492)
      	at org.glassfish.jersey.server.ContainerRequest.getAcceptableLanguages(ContainerRequest.java:563)
      	at org.glassfish.jersey.internal.inject.HttpHeadersInjectee.getAcceptableLanguages(HttpHeadersInjectee.java:103)
      ...
      Caused by: java.text.ParseException: String, es-419, is not a valid language tag
      	at org.glassfish.jersey.message.internal.LanguageTag.parse(LanguageTag.java:122)
      	at org.glassfish.jersey.message.internal.AcceptableLanguageTag.<init>(AcceptableLanguageTag.java:69)
      	at org.glassfish.jersey.message.internal.HttpHeaderReader$8.create(HttpHeaderReader.java:448)
      	at org.glassfish.jersey.message.internal.HttpHeaderReader$8.create(HttpHeaderReader.java:444)
      	at org.glassfish.jersey.message.internal.HttpHeaderReader.readList(HttpHeaderReader.java:506)
      	at org.glassfish.jersey.message.internal.HttpHeaderReader.readList(HttpHeaderReader.java:498)
      	at org.glassfish.jersey.message.internal.HttpHeaderReader.readAcceptableList(HttpHeaderReader.java:466)
      	at org.glassfish.jersey.message.internal.HttpHeaderReader.readAcceptLanguage(HttpHeaderReader.java:453)
      	at org.glassfish.jersey.message.internal.InboundMessageContext.getQualifiedAcceptableLanguages(InboundMessageContext.java:490)
      

      Wikipedia says it's "Spanish appropriate for the Latin America and Caribbean region, using the UN region code."

      JDK7 allows to build a Locale instance for this language tag.

      Possible patch for org.glassfish.jersey.message.internal.LanguageTag.java here.

        Issue Links

          Activity

          Hide
          tingley added a comment -

          Cloned for Jersey 1.x; JERSEY-2124 only fixed the issue in the 2.x codebase. Jersey 1.x is still widely in production, in particular for the Dropwizard REST API framework.

          Show
          tingley added a comment - Cloned for Jersey 1.x; JERSEY-2124 only fixed the issue in the 2.x codebase. Jersey 1.x is still widely in production, in particular for the Dropwizard REST API framework.
          Hide
          Marek Potociar added a comment -

          Jersey 1.x branch is not under active development anymore. Only security issues and issues reported by the customers of commercially supported products that ship with Jersey are fixed on this code base right now.
          Please, move your code to Jersey 2.x and if you still see the issue there, feel free to file a bug against Jersey 2.x.

          Show
          Marek Potociar added a comment - Jersey 1.x branch is not under active development anymore. Only security issues and issues reported by the customers of commercially supported products that ship with Jersey are fixed on this code base right now. Please, move your code to Jersey 2.x and if you still see the issue there, feel free to file a bug against Jersey 2.x.

            People

            • Assignee:
              Michal Gajdos
              Reporter:
              tingley
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 30 minutes
                30m
                Remaining:
                Remaining Estimate - 30 minutes
                30m
                Logged:
                Time Spent - Not Specified
                Not Specified