wavefrontHQ / wavefront-sdk-java

Wavefront Core Java SDK
Apache License 2.0
6 stars 23 forks source link

potential bug: missing encoding in String.getBytes() call #183

Closed randallt closed 3 years ago

randallt commented 3 years ago

Hi,

While investigating a potential encoding issue (WF Proxy shows a ? and blocks the metric), I found a potential batching bug in the class

com.wavefront.sdk.common.clients.WavefrontClient

in the method

getBatch(...)

The batch size is being calculated, such as

int numBytes = item.getBytes().length;

Since the WFProxy expects encoding in UTF-8, the client should always be using UTF-8, even for these calculations. I admit that the potential for a functional bug is probably low, but I wanted to log this issue anyway.

So the call should be

int numBytes = item.getBytes(StandardCharsets.UTF_8).length;