Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-323

Undocumented UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.2.2
    • Fix Version/s: 4.3
    • Component/s: HttpCore
    • Environment:
      Ubuntu Linux 12.10,
      Sun Java 1.7.0
      Linux kernel 3.5.0-19-generic i686

      Description

      I have an wrong instance of HttpEntity, with illegal field "charset" (Content-Type: text/html; charset=cp-1251) in Content-Type header, and if ContentType.getOrDefault(entity) called with that entity - method throwing an uncaught exception:

      java.nio.charset.UnsupportedCharsetException: cp-1251
      at java.nio.charset.Charset.forName(Charset.java:543)
      at org.apache.http.entity.ContentType.create(ContentType.java:180)
      at org.apache.http.entity.ContentType.create(ContentType.java:190)
      at org.apache.http.entity.ContentType.get(ContentType.java:233)
      at org.apache.http.entity.ContentType.getOrDefault(ContentType.java:249)
      at org.apache.http.util.EntityUtils.toString(EntityUtils.java:212)
      at org.apache.http.util.EntityUtils.toString(EntityUtils.java:264)
      at com.rinamika.riwl.crawler.impl.LoaderImpl.processPage(LoaderImpl.java:131)
      ...

      I suppose that it's not right behavior because method getOrDefault must be return a defaul value if something happened.

      Sorry for my English.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              popsul Viktor
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: