From 2acdbdc6b3e53970efe6104bf116aee5b1399ba6 Mon Sep 17 00:00:00 2001 From: Woonduk Kang Date: Wed, 16 Oct 2013 01:44:08 +0000 Subject: [PATCH] =?UTF-8?q?[=EA=B0=95=EC=9A=B4=EB=8D=95]=20[LUCYSUS-1744]?= =?UTF-8?q?=20httpclient4=20interceptor=EC=97=90=EC=84=9C=20cookie?= =?UTF-8?q?=EB=A0=88=EC=BD=94=EB=94=A9=EC=8B=9C=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=82=AC=EC=9D=B4=EC=A6=88=EB=A5=BC=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=ED=95=98=EA=B3=A0=20=EB=A0=88=EC=BD=94=EB=94=A9?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=ED=95=A8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@2527 84d0f5b1-2673-498c-a247-62c4ff18d310 --- .../interceptor/HttpRequestExecuteInterceptor.java | 8 ++++++-- .../interceptor/HttpUriRequestExecuteInterceptor.java | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/HttpRequestExecuteInterceptor.java b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/HttpRequestExecuteInterceptor.java index acdff5ba6..213374efd 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/HttpRequestExecuteInterceptor.java +++ b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/HttpRequestExecuteInterceptor.java @@ -182,7 +182,10 @@ public class HttpRequestExecuteInterceptor implements SimpleAroundInterceptor, B private void dumpCookie(HttpRequest request, Trace trace) { org.apache.http.Header[] cookies = request.getHeaders("Cookie"); for (org.apache.http.Header header: cookies) { - trace.recordAttribute(AnnotationKey.HTTP_COOKIE, header.getValue()); + final String value = header.getValue(); + if (value != null && !value.isEmpty()) { + trace.recordAttribute(AnnotationKey.HTTP_COOKIE, StringUtils.drop(value, 1024)); + } break; } } @@ -190,8 +193,9 @@ public class HttpRequestExecuteInterceptor implements SimpleAroundInterceptor, B if (request instanceof HttpEntityEnclosingRequestBase) { HttpEntityEnclosingRequestBase entityRequest = (HttpEntityEnclosingRequestBase) request; try { - HttpEntity entity = entityRequest.getEntity(); + final HttpEntity entity = entityRequest.getEntity(); if (entity != null && entity.isRepeatable()) { + // entity utils의 toString시 일정 length까지만 데이터를 읽도록하는 기능이 필요함. String entityString = EntityUtils.toString(entityRequest.getEntity(), "UTF8"); trace.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, StringUtils.drop(entityString, 1024)); } diff --git a/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/HttpUriRequestExecuteInterceptor.java b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/HttpUriRequestExecuteInterceptor.java index f12fbc50a..ef966bca4 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/HttpUriRequestExecuteInterceptor.java +++ b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/HttpUriRequestExecuteInterceptor.java @@ -230,7 +230,10 @@ public class HttpUriRequestExecuteInterceptor implements SimpleAroundInterceptor private void dumpCookie(HttpUriRequest request, Trace trace) { org.apache.http.Header[] cookies = request.getHeaders("Cookie"); for (org.apache.http.Header header: cookies) { - trace.recordAttribute(AnnotationKey.HTTP_COOKIE, StringUtils.drop(header.getValue(), 1024)); + final String value = header.getValue(); + if (value != null && !value.isEmpty()) { + trace.recordAttribute(AnnotationKey.HTTP_COOKIE, StringUtils.drop(value, 1024)); + } // Cookie값이 2개 이상일수가 있나? break; } @@ -240,8 +243,9 @@ public class HttpUriRequestExecuteInterceptor implements SimpleAroundInterceptor if (request instanceof HttpEntityEnclosingRequestBase) { HttpEntityEnclosingRequestBase entityRequest = (HttpEntityEnclosingRequestBase) request; try { - HttpEntity entity = entityRequest.getEntity(); + final HttpEntity entity = entityRequest.getEntity(); if (entity != null && entity.isRepeatable() && entity.getContentLength() > 0) { + // entity utils의 toString시 일정 length까지만 데이터를 읽도록하는 기능이 필요함. String entityString = EntityUtils.toString(entityRequest.getEntity(), "UTF8"); trace.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, StringUtils.drop(entityString, 1024)); }