diff options
author | Bogdan Drutu <bdrutu@google.com> | 2017-09-18 11:33:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-18 11:33:49 -0700 |
commit | 53cb6c8bec4540c66c4cbd22535797a76fef921a (patch) | |
tree | c36ab607d3685d7524e95feba0c046c8a87b7f58 /impl_core/src/main/java/io/opencensus/implcore/trace/propagation/BinaryFormatImpl.java | |
parent | ee94e55010d67c5041aa8e6011a0c1b2d813f8a5 (diff) | |
download | opencensus-java-53cb6c8bec4540c66c4cbd22535797a76fef921a.tar.gz |
Add a new SpanContextParseException and use it in BinaryFormat. (#642)
* Add a new SpanContextParseException and use it in BinaryFormat
* Fix review comments.
Diffstat (limited to 'impl_core/src/main/java/io/opencensus/implcore/trace/propagation/BinaryFormatImpl.java')
-rw-r--r-- | impl_core/src/main/java/io/opencensus/implcore/trace/propagation/BinaryFormatImpl.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/impl_core/src/main/java/io/opencensus/implcore/trace/propagation/BinaryFormatImpl.java b/impl_core/src/main/java/io/opencensus/implcore/trace/propagation/BinaryFormatImpl.java index c388ae94..6075c80b 100644 --- a/impl_core/src/main/java/io/opencensus/implcore/trace/propagation/BinaryFormatImpl.java +++ b/impl_core/src/main/java/io/opencensus/implcore/trace/propagation/BinaryFormatImpl.java @@ -23,7 +23,7 @@ import io.opencensus.trace.SpanId; import io.opencensus.trace.TraceId; import io.opencensus.trace.TraceOptions; import io.opencensus.trace.propagation.BinaryFormat; -import java.text.ParseException; +import io.opencensus.trace.propagation.SpanContextParseException; /** * Implementation of the {@link BinaryFormat}. @@ -77,7 +77,7 @@ public final class BinaryFormatImpl extends BinaryFormat { 4 * ID_SIZE + TraceId.SIZE + SpanId.SIZE + TraceOptions.SIZE; @Override - public byte[] toBinaryValue(SpanContext spanContext) { + public byte[] toByteArray(SpanContext spanContext) { checkNotNull(spanContext, "spanContext"); byte[] bytes = new byte[FORMAT_LENGTH]; bytes[VERSION_ID_OFFSET] = VERSION_ID; @@ -91,10 +91,10 @@ public final class BinaryFormatImpl extends BinaryFormat { } @Override - public SpanContext fromBinaryValue(byte[] bytes) throws ParseException { + public SpanContext fromByteArray(byte[] bytes) throws SpanContextParseException { checkNotNull(bytes, "bytes"); if (bytes.length == 0 || bytes[0] != VERSION_ID) { - throw new ParseException("Unsupported version.", 0); + throw new SpanContextParseException("Unsupported version."); } TraceId traceId = TraceId.INVALID; SpanId spanId = SpanId.INVALID; @@ -114,7 +114,7 @@ public final class BinaryFormatImpl extends BinaryFormat { } return SpanContext.create(traceId, spanId, traceOptions); } catch (IndexOutOfBoundsException e) { - throw new ParseException("Invalid input: " + e.toString(), pos); + throw new SpanContextParseException("Invalid input.", e); } } } |