Skip to content
This repository was archived by the owner on Nov 24, 2021. It is now read-only.
This repository was archived by the owner on Nov 24, 2021. It is now read-only.

Adding a non-string value to the MDC can cause the app to hang #96

@afoerster

Description

@afoerster

When using the HttpAppender adding a non-string value to the MDC can cause the app to hang.

The error:

Exception in thread "HTTP appender dispatcher" java.lang.RuntimeException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at io.phdata.pulse.log.HttpAppender$Dispatcher.flush(HttpAppender.java:357)
	at io.phdata.pulse.log.HttpAppender$Dispatcher.run(HttpAppender.java:341)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at io.phdata.pulse.log.JsonParser.marshallEventInternal(JsonParser.java:68)
	at io.phdata.pulse.log.JsonParser.marshallArray(JsonParser.java:24)
	at io.phdata.pulse.log.HttpAppender$Dispatcher.flush(HttpAppender.java:355)

The location:

      for (Map.Entry<String, String> entry : props) {
        jg.writeStringField(entry.getKey(), entry.getValue());
      }

I think the easy fix is to just call toString on the entry.getValue(), I don't see any downsides to this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions