You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/02/22 15:44:27 UTC

[incubator-skywalking] branch master updated: Fix ArrayIndexOutOfBoundsException (#2284)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new a95e15f  Fix ArrayIndexOutOfBoundsException  (#2284)
a95e15f is described below

commit a95e15fb8dc86e4303e90af27f9df1afad1760e0
Author: 刘正阳 <li...@users.noreply.github.com>
AuthorDate: Fri Feb 22 23:44:22 2019 +0800

    Fix ArrayIndexOutOfBoundsException  (#2284)
    
    * Fix ArrayIndexOutOfBoundsException when intercepting net.spy.memcached.MemcachedClient.getStats()
    
    * revert format
---
 .../apm/plugin/spymemcached/v2/MemcachedMethodInterceptor.java | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/apm-sniffer/apm-sdk-plugin/spymemcached-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spymemcached/v2/MemcachedMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/spymemcached-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spymemcached/v2/MemcachedMethodInterceptor.java
index 94aa8d9..81e9fe1 100644
--- a/apm-sniffer/apm-sdk-plugin/spymemcached-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spymemcached/v2/MemcachedMethodInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spymemcached-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spymemcached/v2/MemcachedMethodInterceptor.java
@@ -41,7 +41,15 @@ public class MemcachedMethodInterceptor implements InstanceMethodsAroundIntercep
         span.setComponent(ComponentsDefine.SPYMEMCACHED);
         Tags.DB_TYPE.set(span, ComponentsDefine.SPYMEMCACHED.getName());
         SpanLayer.asCache(span);
-        Tags.DB_STATEMENT.set(span, method.getName() + " " + allArguments[0]);
+        Tags.DB_STATEMENT.set(span, getStatement(method, allArguments));
+    }
+
+    private String getStatement(Method method, Object[] allArguments) {
+        if (allArguments != null && allArguments.length > 0) {
+            return method.getName() + ' ' + allArguments[0];
+        } else {
+            return method.getName();
+        }
     }
 
     @Override