[
https://issues.apache.org/jira/browse/HTTPCLIENT-1429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13812859#comment-13812859
]
Sebastiano Vigna edited comment on HTTPCLIENT-1429 at 11/4/13 2:17 PM:
-----------------------------------------------------------------------
The current toString() code of BasicClientCookie is
{code}
@Override
public String toString() {
final StringBuilder buffer = new StringBuilder();
buffer.append("[version: ");
buffer.append(Integer.toString(this.cookieVersion));
buffer.append("]");
buffer.append("[name: ");
buffer.append(this.name);
buffer.append("]");
buffer.append("[value: ");
buffer.append(this.value);
buffer.append("]");
buffer.append("[domain: ");
buffer.append(this.cookieDomain);
buffer.append("]");
buffer.append("[path: ");
buffer.append(this.cookiePath);
buffer.append("]");
buffer.append("[expiry: ");
buffer.append(this.cookieExpiryDate);
buffer.append("]");
return buffer.toString();
}
{code}
I would just add a call to abbreviate():
{code}
@Override
public String toString() {
final StringBuilder buffer = new StringBuilder();
buffer.append("[version: ");
buffer.append(Integer.toString(this.cookieVersion));
buffer.append("]");
buffer.append("[name: ");
buffer.append(this.name);
buffer.append("]");
buffer.append("[value: ");
buffer.append(org.apache.commons.lang3.StringUtils.abbreviate(this.value, " ...
", 100 ));
buffer.append("]");
buffer.append("[domain: ");
buffer.append(this.cookieDomain);
buffer.append("]");
buffer.append("[path: ");
buffer.append(this.cookiePath);
buffer.append("]");
buffer.append("[expiry: ");
buffer.append(this.cookieExpiryDate);
buffer.append("]");
return buffer.toString();
}
{code}
Depending on your style, 100 (or another reasonable value) might be replaced
with a static final constant, and I don't know whether you are dependent on
lang3 or not, but it's ASF stuff.
was (Author: vigna):
The current toString() code of BasicClientCookie is
{code}
@Override
public String toString() {
final StringBuilder buffer = new StringBuilder();
buffer.append("[version: ");
buffer.append(Integer.toString(this.cookieVersion));
buffer.append("]");
buffer.append("[name: ");
buffer.append(this.name);
buffer.append("]");
buffer.append("[value: ");
buffer.append(this.value);
buffer.append("]");
buffer.append("[domain: ");
buffer.append(this.cookieDomain);
buffer.append("]");
buffer.append("[path: ");
buffer.append(this.cookiePath);
buffer.append("]");
buffer.append("[expiry: ");
buffer.append(this.cookieExpiryDate);
buffer.append("]");
return buffer.toString();
}
{code}
I would just add
{code}
@Override
public String toString() {
final StringBuilder buffer = new StringBuilder();
buffer.append("[version: ");
buffer.append(Integer.toString(this.cookieVersion));
buffer.append("]");
buffer.append("[name: ");
buffer.append(this.name);
buffer.append("]");
buffer.append("[value: ");
buffer.append(org.apache.commons.lang3.StringUtils.abbreviate(this.value, " ...
", 100 ));
buffer.append("]");
buffer.append("[domain: ");
buffer.append(this.cookieDomain);
buffer.append("]");
buffer.append("[path: ");
buffer.append(this.cookiePath);
buffer.append("]");
buffer.append("[expiry: ");
buffer.append(this.cookieExpiryDate);
buffer.append("]");
return buffer.toString();
}
{code}
Depending on your style, 100 (or another reasonable value) might be replaced
with a static final constant, and I don't know whether you are dependent on
lang3 or not, but it's ASF stuff.
> Very large cookies should be logged in a truncated form
> -------------------------------------------------------
>
> Key: HTTPCLIENT-1429
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1429
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 4.3.1
> Reporter: Sebastiano Vigna
> Priority: Minor
> Fix For: 4.3.2
>
>
> Rejected cookies are logged at WARN level. We have met cookies (usually,
> binary encoded state) that are several dozens KB long, and they slow down the
> logging process significantly. It would be nice to have a
> "print/logging-friendly" toString() method that truncates the value after a
> few hundred characters or so.
--
This message was sent by Atlassian JIRA
(v6.1#6144)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]