You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Viktor (JIRA)" <ji...@apache.org> on 2012/11/24 15:02:58 UTC

[jira] [Created] (HTTPCORE-323) Uncaught UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault

Viktor created HTTPCORE-323:
-------------------------------

             Summary: Uncaught UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault
                 Key: HTTPCORE-323
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-323
             Project: HttpComponents HttpCore
          Issue Type: Bug
          Components: HttpCore
    Affects Versions: 4.2.2
         Environment: Ubuntu Linux 12.10,
Sun Java 1.7.0
Linux kernel 3.5.0-19-generic i686
            Reporter: Viktor


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) callied 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 happend.

Sorry for my English.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Commented] (HTTPCORE-323) Undocumented UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13504113#comment-13504113 ] 

Gary Gregory commented on HTTPCORE-323:
---------------------------------------

Hello Viktor:

The Javadoc states:

    /**
     * Extracts <code>Content-Type</code> value from {@link HttpEntity} or returns default value
     * if not explicitly specified.
     *
     * @param entity HTTP entity
     * @return content type
     * @throws ParseException if the given text does not represent a valid
     * <code>Content-Type</code> value.
     */

So to me, the behavior you see is poorly documented:

     * Extracts <code>Content-Type</code> value from {@link HttpEntity} or returns default value
     * if not explicitly specified.

- You pass in a content type, so you 'specify' one which is why the default is not returned. That's part is fine.

     * @throws ParseException if the given text does not represent a valid
     * <code>Content-Type</code> value.

You pass in an invalid content type, but the method does not throw a ParseException.

BUT the throws declaration does specify UnsupportedCharsetException, it is not in the Javadoc though.

All of this tells me that we need better Javadocs.

See:

commit -m "Add missing Javadoc related to [HTTPCORE-323]: Undocumented UnsupportedCharsetException org.apache.http.entity.ContentType.getOrDefault." C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/entity/StringEntity.java C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/entity/ContentType.java C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
    Sending        C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/entity/ContentType.java
    Sending        C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
    Sending        C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
    Sending        C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
    Transmitting file data ...
    Committed revision 1413870.

Gary


                
> Undocumented UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault
> -------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-323
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-323
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore
>    Affects Versions: 4.2.2
>         Environment: Ubuntu Linux 12.10,
> Sun Java 1.7.0
> Linux kernel 3.5.0-19-generic i686
>            Reporter: Viktor
>              Labels: bug,, charset,, httpcore,, nio,
>
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Updated] (HTTPCORE-323) Uncaught UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault

Posted by "Viktor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-323?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Viktor updated HTTPCORE-323:
----------------------------

    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.

  was:
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) callied 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 happend.

Sorry for my English.

    
> Uncaught UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault
> ---------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-323
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-323
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore
>    Affects Versions: 4.2.2
>         Environment: Ubuntu Linux 12.10,
> Sun Java 1.7.0
> Linux kernel 3.5.0-19-generic i686
>            Reporter: Viktor
>              Labels: bug,, charset,, httpcore,, nio,
>
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Updated] (HTTPCORE-323) Undocumented UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-323?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory updated HTTPCORE-323:
----------------------------------

    Summary: Undocumented UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault  (was: Uncaught UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault)
    
> Undocumented UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault
> -------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-323
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-323
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore
>    Affects Versions: 4.2.2
>         Environment: Ubuntu Linux 12.10,
> Sun Java 1.7.0
> Linux kernel 3.5.0-19-generic i686
>            Reporter: Viktor
>              Labels: bug,, charset,, httpcore,, nio,
>
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Closed] (HTTPCORE-323) Undocumented UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-323?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory closed HTTPCORE-323.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 4.3

commit -m "Add missing Javadoc related to [HTTPCORE-323]: Undocumented UnsupportedCharsetException org.apache.http.entity.ContentType.getOrDefault." C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/entity/StringEntity.java C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/entity/ContentType.java C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
    Sending        C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/entity/ContentType.java
    Sending        C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
    Sending        C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore/src/main/java/org/apache/http/util/EntityUtils.java
    Sending        C:/svn/org/apache/httpcomponents/trunk/httpcore/httpcore-nio/src/main/java/org/apache/http/nio/entity/NStringEntity.java
    Transmitting file data ...
    Committed revision 1413870.
commit -m "[HTTPCORE-323] Undocumented UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault" C:/svn/org/apache/httpcomponents/trunk/httpcore/RELEASE_NOTES.txt
    Sending        C:/svn/org/apache/httpcomponents/trunk/httpcore/RELEASE_NOTES.txt
    Transmitting file data ...
    Committed revision 1413874.
                
> Undocumented UnsupportedCharsetException in org.apache.http.entity.ContentType.getOrDefault
> -------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-323
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-323
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore
>    Affects Versions: 4.2.2
>         Environment: Ubuntu Linux 12.10,
> Sun Java 1.7.0
> Linux kernel 3.5.0-19-generic i686
>            Reporter: Viktor
>              Labels: bug,, charset,, httpcore,, nio,
>             Fix For: 4.3
>
>
> 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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org