TextMapFormatter extends AbstractTextFormatter { @Override protected String encodedValue(String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY_STRING; } return value; }  @Override Format<TextMap> getFormatType();  }
@Test public void testEncodedValue() throws Exception { SofaTracerSpanContext spanContext = SofaTracerSpanContext.rootStart(); Map<String, String> baggage = new HashMap<String, String>(); baggage.put("key", "value"); baggage.put("key1", "value1"); baggage.put("key2", "value2"); spanContext.addBizBaggage(baggage); final TextMap carrier = new TextMap() { Map<String, String> carr = new HashMap<String, String>(); @Override public Iterator<Map.Entry<String, String>> iterator() { return carr.entrySet().iterator(); } @Override public void put(String key, String value) { carr.put(key, value); } @Override public String toString() { return "$classname{" + "carr=" + carr + '}'; } }; this.registryExtractorInjector.inject(spanContext, carrier); SofaTracerSpanContext extractContext = this.registryExtractorInjector.extract(carrier); extractContext.equals(spanContext); assertTrue("Extract : " + extractContext, baggage.equals(extractContext.getBizBaggage())); }