What's the best way to suppress a runtime console warning in Java?

前端 未结 7 1424
情歌与酒
情歌与酒 2021-02-07 07:15

I am using the getResponseBody() method of the org.apache.commons.httpclient.methods.PostMethod class. However, I am always getting a message written to the console at runtime:

7条回答
  •  长发绾君心
    2021-02-07 07:58

    This issue has already been debated on the ASF JIRA. There are two ways to resolve this:

    • Set a higher value for BUFFER_WARN_TRIGGER_LIMIT. A high enough value is more likely to suppress the warning; however, that defeats the purpose of the warning itself. If you are buffering a lot of data to be eventually parsed in one pass, you are better off reading the data from a stream into an array before working on the array.
    • Set the logging level to a higher value for HttpClient, if you are comfortable with ERROR or FATAL.

提交回复
热议问题