title: Very weird Genson's behaviour while reading from socket stream
body: <p>I'm trying to perform communication between server and client using Genson library. I've detected the following problem: trying to send a message to the server my application stalls when genson on the server is trying to read the message. </p>
  
  <p>Meanwhile, if I shutdown the client, the message is perfectly read and processed. I've thought it to be deadlock but not sure.</p>
  
  <p>There is no such a problem with native Java serialization.</p>
  
  <p>Here is my server:
  </p>
  
  <pre class="lang-java prettyprint-override"><code>import com.owlike.genson.Genson;
  
  import java.io.IOException;
  import java.net.ServerSocket;
  import java.net.Socket;
  import java.util.Arrays;
  
  public class Server {
      public static void main(String[] args) throws IOException {
          Genson genson = new Genson();
  
          try (ServerSocket server = new ServerSocket(9991)) {
              try (Socket socket = server.accept()) {
                  int[] loc = genson.deserialize(socket.getInputStream(), int[].class);
                  System.out.println("Server: " + Arrays.toString(loc));
                  genson.serialize(loc, socket.getOutputStream());
              }
          }
      }
  }
  </code></pre>
  
  <p>Here is the client:</p>
  
  <pre class="lang-java prettyprint-override"><code>import com.owlike.genson.Genson;
  
  import java.io.IOException;
  import java.net.Socket;
  import java.util.Arrays;
  
  public class Client {
      public static void main(String[] args) throws IOException {
          Genson genson = new Genson();
  
          try (Socket socket = new Socket("localhost", 9991)) {
              genson.serialize(new int[] {1, 2, 3}, socket.getOutputStream());
              int[] loc = genson.deserialize(socket.getInputStream(), int[].class);
              System.out.println("Client: " + Arrays.toString(loc));
          }
      }
  }
  </code></pre>
  
  <p>I wound highly appreciate any help with this question. Thanks in advance.</p>
  
  <hr>
  
  <p><strong>Edit</strong>: This is really wierd. I've made some additional tests and here is what i get:</p>
  
  <p>Additional class:</p>
  
  <pre class="lang-java prettyprint-override"><code>import com.owlike.genson.annotation.JsonProperty;
  
  import java.io.Serializable;
  
  public class Tester implements Serializable {
      public static final Tester TEST = new Tester(Math.E);
  
      private double val = Math.PI;
  
      public Tester(@JsonProperty("val") double val) {
          this.val = val;
      }
  
      public Tester() {}
  
      public String toString() {
          return "" + val;
      }
  }
  </code></pre>
  
  <p>Having written <code>genson.serialize(Tester.TEST, socket.getOutputStream())</code> in the client request I have the same strange result. But having written <code>genson.serialize(new Tester(Double.NaN), socket.getOutputStream())</code> the result is the expexted one.</p>
  
  <p>Furthermore, if I define the only field in Tester class to be of type <code>int[]</code>, lets say, it only works with values of <code>null</code> or <code>new int[0]</code>.</p>
  
  <p>In addition to that, if I'm trying to serialize and transmit <code>int</code> for integers in range 0..9 I observe the following behaviour: the same strange thing except that when I shutdown the client, server always shows <code>0</code> value.</p>
  
  <p>Besides, for constants like <code>Double.NaN</code>, <code>Double.POSITIVE_INFINITY</code>, <code>Integer.MAX_VALUE</code> and similar there is nothing strange at all (everything works as expected).</p>
  
  <p>For those additional tests <code>Genson</code> class was defined as follows:</p>
  
  <pre class="lang-java prettyprint-override"><code>Genson genson = new GensonBuilder()
          .useMethods(false)
          .setFieldFilter(VisibilityFilter.PRIVATE)
          .create();
  </code></pre>
  
  <p><strong>Note</strong> that there is no such issue when ser/deser to/from a file using streams:</p>
  
  <pre class="lang-java prettyprint-override"><code>import com.owlike.genson.Genson;
  import com.owlike.genson.GensonBuilder;
  import com.owlike.genson.reflect.VisibilityFilter;
  
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  
  public class FileTest {
      private static final String FILENAME = "test.json";
  
      public static void main(String[] args) throws IOException {
          Genson genson = new GensonBuilder()
                  .useMethods(false)
                  .setFieldFilter(VisibilityFilter.PRIVATE)
                  .useIndentation(true)
                  .create();
  
          try (OutputStream stream = new FileOutputStream(FILENAME)) {
              genson.serialize(Tester.TEST, stream);
          }
  
          try (InputStream stream = new FileInputStream(FILENAME)) {
              System.out.println(genson.deserialize(stream, Tester.class));
          }
      }
  }
  </code></pre>