开发者

Warning "[Parameters] Parameters : Invalid chunk ignored" when posting from a managed bean

I am opening a HttpURLConnection from within a managed bean to post to an external service. When I make the call to HttpUrlConnection.getInputStream() I am getting the following warning:

WARN [Parameters] Parameters : Invalid chunk ignored

Everything processes just fine, but I'd like to keep a bunch of those warnings out of our logs. What is causing this warning and how might I stop it from occurring?

Here is the relevant code:

@ManagedBean
@SessionScoped
public class MyController {

  private void doStuff() {
    ...
    URL url = new URL(externalServiceUrl);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setDoOutput(true);
    conn.setDoInput(true);

    wr = new OutputStreamWriter(conn.getOutputStream());
    wr.write(postData);
    wr.flush();

    InputStream is = conn.getI开发者_开发问答nputStream(); // Warning logged after this line
    ...
  }

}


This warning can occur whenever the query string contains an invalid chunk, such as a request parameter without a name:

name1=value1&=value2&name3=value3

or in your particular case, a & in the beginning (essentially, the first chunk is invalid):

&name1=value1&name2=value2&name3=value3

As per the comments, you seem to be HTTP-connecting to a service which runs on the same container and logs to the same logfile. This warning is actually coming from the service container itself, not from HttpURLConnection.


I removed this warning from my logs by adding:

<category name="org.apache.tomcat.util.http.Parameters">
  <priority value="ERROR"/>

to my jboss-log4j.xml config file. It was set to TRACE level before.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜