zipkin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [incubator-zipkin] anuraaga commented on a change in pull request #2589: Makes SpanBytesDecoder work on ByteBuffer
Date Tue, 14 May 2019 06:17:49 GMT
anuraaga commented on a change in pull request #2589: Makes SpanBytesDecoder work on ByteBuffer

 File path: zipkin/src/main/java/zipkin2/internal/
 @@ -0,0 +1,379 @@
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package zipkin2.internal;
+import java.nio.ByteBuffer;
+import static zipkin2.internal.HexCodec.HEX_DIGITS;
+import static zipkin2.internal.JsonCodec.UTF_8;
+/** Read operations do bounds checks, as typically more errors occur reading than writing.
+public abstract class ReadBuffer extends InputStream {
+  /** Do not use the buffer passed here after, as it may be manipulated directly. */
+  public static ReadBuffer wrapUnsafe(ByteBuffer buffer) {
+    if (buffer.hasArray()) {
+      int pos = buffer.position();
+      return wrap(buffer.array(), buffer.arrayOffset() + pos);
 Review comment:
   Think we should also look at `remaining()` - it can be efficient to use `slice`, in which
case the buffer doesn't go to the end of the array.

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.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

View raw message