<commit_before>package com.continuuity.common.discovery;

import com.google.gson.Gson;
import com.netflix.curator.x.discovery.ServiceInstance;
import com.netflix.curator.x.discovery.details.InstanceSerializer;

/**
 * ServicePayload serializer.
 */
public class ServicePayloadSerializer implements
  InstanceSerializer<ServicePayload> {
  /**
   * Instance of gson that is used to serialize the {@link ServicePayload}
   */
  private final Gson gson;
  {
    gson = new Gson();
  }

  /**
   * Serialize an instance into bytes
   *
   * @param instance the instance
   * @return byte array representing the instance
   * @throws Exception any errors
   */
  @Override
  public byte[] serialize(ServiceInstance<ServicePayload> instance) throws Exception {
    return gson.toJson(instance).getBytes();
  }

  /**
   * Deserialize a byte array into an instance
   *
   * @param bytes the bytes
   * @return service instance
   * @throws Exception any errors
   */
  @Override
  @SuppressWarnings("unchecked")
  public ServiceInstance<ServicePayload> deserialize(byte[] bytes) throws Exception {
    return gson.fromJson(new String(bytes), ServiceInstance.class);
  }
}
<commit_msg>Charset should be provided to String encode/decode of byte[]<commit_after>package com.continuuity.common.discovery;

import com.google.gson.Gson;
import com.netflix.curator.x.discovery.ServiceInstance;
import com.netflix.curator.x.discovery.details.InstanceSerializer;

import java.nio.charset.Charset;

/**
 * ServicePayload serializer.
 */
public class ServicePayloadSerializer implements
  InstanceSerializer<ServicePayload> {

  /**
   * Charset used for json encode/decode.
   */
  private static final Charset UTF8 = Charset.forName("UTF-8");

  /**
   * Instance of gson that is used to serialize the {@link ServicePayload}
   */
  private final Gson gson = new Gson();

  /**
   * Serialize an instance into bytes
   *
   * @param instance the instance
   * @return byte array representing the instance
   * @throws Exception any errors
   */
  @Override
  public byte[] serialize(ServiceInstance<ServicePayload> instance) throws Exception {
    return gson.toJson(instance).getBytes(UTF8);
  }

  /**
   * Deserialize a byte array into an instance
   *
   * @param bytes the bytes
   * @return service instance
   * @throws Exception any errors
   */
  @Override
  @SuppressWarnings("unchecked")
  public ServiceInstance<ServicePayload> deserialize(byte[] bytes) throws Exception {
    return gson.fromJson(new String(bytes, UTF8), ServiceInstance.class);
  }
}

{'fraction_non_alphanumeric': 0.09846998823067869, 'fraction_numerical': 0.001569242840329541, 'mean_word_length': 3.9514563106796117, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4558013', 'n_tokens_mistral': 731, 'n_tokens_neox': 724, 'n_words': 203}