title: Hessian Serialization and Deserialization of java.time.Year
body: <p>While trying to serialize and deserialize object of java.time.Year, it gives serialization error and run into stackOverflow.</p>
  
  <pre><code>java.lang.StackOverflowError
      at com.caucho.hessian.util.IdentityIntMap.get(IdentityIntMap.java:112)
      at com.caucho.hessian.io.Hessian2Output.getRef(Hessian2Output.java:1359)
      at com.caucho.hessian.io.WriteReplaceSerializer.writeObject(WriteReplaceSerializer.java:144)
      at com.caucho.hessian.io.Hessian2Output.writeObject(Hessian2Output.java:465)
      at com.caucho.hessian.io.UnsafeSerializer$ObjectFieldSerializer.serialize(UnsafeSerializer.java:297)
      at com.caucho.hessian.io.UnsafeSerializer.writeInstance(UnsafeSerializer.java:216)
      at com.caucho.hessian.io.UnsafeSerializer.writeObject(UnsafeSerializer.java:170)
  </code></pre>
  
  <p>The sample code to reproduce this error is:</p>
  
  <pre><code>@Test
  public void testHessianSerializeDeserialize() throws IOException {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      Hessian2Output out = new Hessian2Output(bos);
  
      out.startMessage();
      Year y1 = Year.of(2017);
      out.writeObject(y1);
  
      out.completeMessage();
      out.close();
  
      byte[] data = bos.toByteArray();
  
      // Deserialize
      ByteArrayInputStream bin = new ByteArrayInputStream(data);
      Hessian2Input in = new Hessian2Input(bin);
  
      in.startMessage();
      Assert.assertEquals(y1, (Year) in.readObject());
  
      in.completeMessage();
      in.close();
      bin.close();
  }
  </code></pre>