title: Netty Encoding decoding error
body: <p>I am coding a simple netty packet service. Currently I got a server and a client with a central protocol module.</p>
  
  <p>My Client log looks like this:</p>
  
  <p>PacketId encoded: 1 
  Writed packet.
  Writing int: 441</p>
  
  <p>My Server log:</p>
  
  <p>PacketId: 8
  protocol is null ? with id: 8
  PacketId: 1
  receiving test with id :0</p>
  
  <p>Encoder:</p>
  
  <pre><code>@Override
      protected void encode( ChannelHandlerContext channelHandlerContext, Packet packet, ByteBuf byteBuf ) {
          final Protocol protocol = Protocol.getProtocol( packet.getClass() );
  
          if ( protocol == null ) {
              throw new IllegalStateException( "The requested packet is not registered!" );
          } else {
              final int packetId = protocol.getId();
  
              if ( packetId &gt; -1 ) {
                  byteBuf.writeInt( packetId );
                  System.out.println( "PacketId encoded: " + packetId );
                  packet.write( byteBuf );
                  System.out.println( "Writed packet." );
              }
          }
      }
  </code></pre>
  
  <p>Decoder:</p>
  
  <pre><code>@Override
      protected void decode( ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List&lt;Object&gt; list ) throws Exception {
          final int packetId = byteBuf.readInt();
          System.out.println( "PacketId: " + packetId );
          final Protocol protocol = Protocol.getProtocol( packetId );
  
          if ( protocol == null ) {
              System.out.println( "protocol is null ? with id: " + packetId );
          } else {
              final Class&lt;? extends Packet&gt; packetClass = Objects.requireNonNull( protocol ).getPacketClass();
  
              if ( packetClass != null ) {
                  Packet packet = packetClass.newInstance();
                  packet.read( byteBuf );
  
                  list.add( packet );
              }
          }
      }
  </code></pre>
  
  <p>Has somebody an idea on how to solve?</p>
  
  <p>Thanks for any contribution!</p>