Skip to content

Commit

Permalink
Fixes stackoverflow bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Cole committed Jan 23, 2018
1 parent 2ae9fdb commit a5fafd1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions zipkin2/src/main/java/zipkin2/Span.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public Builder debug(boolean debug) {

/** @see Span#debug */
public Builder debug(@Nullable Boolean debug) {
if (debug != null) return debug(debug);
if (debug != null) return debug((boolean) debug);
flags &= ~FLAG_DEBUG_SET;
return this;
}
Expand All @@ -484,7 +484,7 @@ public Builder shared(boolean shared) {

/** @see Span#shared */
public Builder shared(@Nullable Boolean shared) {
if (shared != null) return shared(shared);
if (shared != null) return shared((boolean) shared);
flags &= ~FLAG_SHARED_SET;
return this;
}
Expand Down
34 changes: 34 additions & 0 deletions zipkin2/src/test/java/zipkin2/SpanTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,40 @@ public class SpanTest {
.isNull();
}

@Test public void canUsePrimitiveOverloads() {
Span primitives = base.toBuilder()
.timestamp(1L)
.duration(1L)
.shared(true)
.debug(true)
.build();

Span objects = base.toBuilder()
.timestamp(Long.valueOf(1L))
.duration(Long.valueOf(1L))
.shared(Boolean.TRUE)
.debug(Boolean.TRUE)
.build();

assertThat(primitives)
.isEqualToComparingFieldByField(objects);
}

@Test public void nullToZeroOrFalse() {
Span nulls = base.toBuilder()
.timestamp(null)
.duration(null)
.build();

Span zeros = base.toBuilder()
.timestamp(0L)
.duration(0L)
.build();

assertThat(nulls)
.isEqualToComparingFieldByField(zeros);
}

@Test public void toString_isJson() {
assertThat(base.toString()).hasToString(
"{\"traceId\":\"0000000000000001\",\"id\":\"0000000000000001\",\"localEndpoint\":{\"serviceName\":\"frontend\",\"ipv4\":\"127.0.0.1\"}}"
Expand Down

1 comment on commit a5fafd1

@codefromthecrypt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @hshopeful for reporting this regression

Please sign in to comment.