code: @VisibleForTesting
    MesosFileChunkObject parseResponseBody(Response response) throws IOException {
      // not thread-safe, need to make a new one each time;
      CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder()
          .onMalformedInput(CodingErrorAction.REPLACE)
          .replaceWith(REPLACEMENT_CHARACTER);
  
      ByteBuffer responseBuffer = response.getResponseBodyAsByteBuffer();
      Reader sanitizedReader = CharSource.wrap(decoder.decode(responseBuffer)).openStream();
      final MesosFileChunkObject initialChunk = objectMapper.readValue(sanitizedReader, MesosFileChunkObject.class);
  
      // bail early if no replacement characters
      if (!initialChunk.getData().startsWith(REPLACEMENT_CHARACTER) && !initialChunk.getData().endsWith(REPLACEMENT_CHARACTER)) {
        return initialChunk;
      }
  
      final String data = initialChunk.getData();
  
      // if we requested data between two characters, return nothing and advance the offset to the end
      if (data.length() <= 4 && data.replace(REPLACEMENT_CHARACTER, "").length() == 0) {
        return new MesosFileChunkObject("", initialChunk.getOffset() + data.length(), Optional.<Long>absent());
      }
  
      // trim incomplete character at the beginning of the string
      int startIndex = 0;
      if (data.startsWith(TWO_REPLACEMENT_CHARACTERS)) {
        startIndex = 2;
      } else if (data.startsWith(REPLACEMENT_CHARACTER)) {
        startIndex = 1;
      }
  
      // trim incomplete character at the end of the string
      int endIndex = data.length();
      if (data.endsWith(TWO_REPLACEMENT_CHARACTERS)) {
        endIndex -= 2;
      } else if (data.endsWith(REPLACEMENT_CHARACTER)) {
        endIndex -= 1;
      }
  
      return new MesosFileChunkObject(data.substring(startIndex, endIndex), initialChunk.getOffset() + startIndex, Optional.<Long>absent());
    }
docs: This method will first sanitize the input by replacing invalid UTF8 characters with \ufffd (Unicode's "REPLACEMENT CHARACTER")
  before sending it to Jackson for parsing. We then strip the replacement characters characters from the beginning and end of the string
  and increment the offset field by how many characters were stripped from the beginning.