youjie23 commented on PR #774:
URL: https://github.com/apache/skywalking-java/pull/774#issuecomment-3263879418

   > This was discussed back to the plugin was being added/reviewed. I am not 
sure there is a proper way to deal with byte array, unless this is an internal 
usage.
   
   Thank you for the review.
   Yes, you are rigorous. Redis will directly store the passed byte[] 
regardless of its content encoding and type. It is imprudent to directly assume 
that it can be converted into a string using UTF-8 (this is only for our 
internal usage scenario).
   Should we close this PR directly? Or should we attempt a conversion, like 
the code below?
   ```
   private Optional<String> getKey(Object[] allArguments) {
            //code
           if (argument instanceof String) {
               return Optional.of(StringUtil.cut((String) argument, 
JedisPluginConfig.Plugin.Jedis.REDIS_PARAMETER_MAX_LENGTH));
           }
           if (argument instanceof byte[]) {
              try {
                    String key = new String((byte[]) argument, 
StandardCharsets.UTF_8);
                    return Optional.of(StringUtil.cut(key, 
JedisPluginConfig.Plugin.Jedis.REDIS_PARAMETER_MAX_LENGTH));
              } 
             catch{
             }
           }
           return Optional.empty();
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to