title: Netty ByteBuf dont get the full message of a large input when decoding
body: <p>There is a legacy application which does json over TCP.</p>
  
  <p>I use a netty server, and I want to convert the json into a Pojo via Gson.</p>
  
  <p>In order to do this, I convert created a Decoder which take as input a ByteBuf and create My Object.</p>
  
  <p>The problem is the Bytebuf has a size of 1024, and the json is much much more bigger than that (>20mo)</p>
  
  <pre><code>@Sharable
  public class RequestDecoder extends MessageToMessageDecoder&lt;ByteBuf&gt; {
  
      @Override
      protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List&lt;Object&gt; out) throws Exception {
          InputStream json = new ByteBufInputStream(msg);
          InputStreamReader inputStreamReader = new InputStreamReader(json, Charsets.UTF_8);
          JsonReader reader;
          reader = new JsonReader(inputStreamReader);
          reader.setLenient(true);
          Request object = new Gson().fromJson(reader, Request.class);
          try {
              reader.close();
          } catch (IOException e) {
              throw new RuntimeException("uncloseable reader", e);
          }
          out.add(object);
      }
  }
  </code></pre>
  
  <p>I always get a :</p>
  
  <pre><code>com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 1020
  </code></pre>
  
  <p>and when I debug I  only get the 1024 first byte in the "ByteBuf msg"</p>
  
  <p>How can I set a ByteBuf capacity to its max capacity? (when debugging I see that ByteBuf is a SimpleLeakAwareByteBuf with a maxCapacity of 2147483647)</p>
  
  <p>How can I get rid of this limitation?</p>