[ 
https://issues.apache.org/jira/browse/HTRACE-279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14955821#comment-14955821
 ] 

Colin Patrick McCabe commented on HTRACE-279:
---------------------------------------------

For some reason, the compiler won't accept {{SpanSerializer}} as an instance of 
{{JsonSerializer<Span>}}.

{code}
public static class SpanSerializer extends JsonSerializer<Span> {
...
{code}

{code}
  static {
    // We must explicitly declare that we want to use the SpanSerializer from
    // htrace-core4, or else Jackson sometimes forgets to use it, even though
    // there is a @JsonSerializer annotation on the Span class.  See HTRACE-279.
    OBJECT_MAPPER = new ObjectMapper();
    SimpleModule spanModule = new SimpleModule("SpanModule");
    JsonSerializer<Span> spanSerializer = (JsonSerializer<Span>)new 
Span.SpanSerializer();
    spanModule.addSerializer(Span.class, spanSerializer);
    OBJECT_MAPPER.registerModule(spanModule);
    JSON_WRITER = OBJECT_MAPPER.writer();
  }
{code}

{code}
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) 
on project htrace-htraced: Compilation failure
[ERROR] 
/home/cmccabe/src/htrace2f/htrace-htraced/src/main/java/org/apache/htrace/impl/RestBufferManager.java:[68,64]
 error: inconvertible types
[ERROR] -> [Help 1]
{code}

I'm guessing that this is related to shading.  I suppose in some sense the 
{{JsonSerializer}} is not part of our public API, even though it's a public 
class, since we're shading Jackson.  I'm also guessing that we made a mistake 
in declaring it as {{JsonSerializer<Span>}} rather than {{JsonSerializer<? 
extends Span>}}, although I think this would still not fix the issue.

I guess we just have to use {{Span#toString}} for right now.

> Force HTraced span receiver to use SpanSerializer and add validation to 
> htraced REST ingest path
> ------------------------------------------------------------------------------------------------
>
>                 Key: HTRACE-279
>                 URL: https://issues.apache.org/jira/browse/HTRACE-279
>             Project: HTrace
>          Issue Type: Bug
>    Affects Versions: 4.1
>            Reporter: Colin Patrick McCabe
>            Assignee: Colin Patrick McCabe
>
> Apparently the HTracedReceiver is sometimes not using the JSON SpanSerializer 
> from htrace-core4.  We should force the span receiver to use that serializer. 
>  Also, we should add span ID validation to the htraced daemon.  Currently, a 
> bad span ID can crash the daemon, which is not very robust.  These changes 
> will fix the unit test failure in TestHTracedReceiver.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to