@Test public void contextsHaveIndependentValue() {

  TraceContext decorated = propagationFactory.decorate(context);
  BasicMapExtra extra1 = decorated.findExtra(BasicMapExtra.class);
  extra1.put("1", "two");
  // we have the same span ID, so we should couple our extra state
  assertThat(propagationFactory.decorate(decorated.toBuilder().build()).extra())
      .isEqualTo(decorated.extra());
  // we no longer have the same span ID, so we should decouple our extra state
  context2 = propagationFactory.decorate(context2.toBuilder().addExtra(extra1).build());
  BasicMapExtra extra2 = context2.findExtra(BasicMapExtra.class);
  // we have different instances of extra
  assertThat(extra1).isNotSameAs(extra2);
  // however, the values inside are the same until a write occurs
  assertThat(extra1).isEqualTo(extra2);
  // check that the change is present, but the other contexts are the same
  String beforeUpdate = extra1.get("1");
  extra1.put("1", "2");
  assertThat(extra1.get("1")).isNotEqualTo(beforeUpdate); // copy-on-write
  assertThat(extra2.get("1")).isEqualTo(beforeUpdate);
}