Hi,

On Wed, Apr 6, 2016 at 8:00 PM, Pavel Rappo <pavel.ra...@oracle.com> wrote:
> Hi,
>
> Could you please review my change for JDK-8153353?
>
> http://cr.openjdk.java.net/~prappo/8153353/webrev.00/
>
> This is an implementation of HPACK (Header Compression for HTTP/2) [1]
> Internal API classes are (package sun.net.httpclient.hpack):
>
>     Encoder, Decoder and DecodingCallback
>
> Example of their usage can be seen in the RFR for HTTP/2 implementation
> published previously today [2, 3].

I would suggest a few of things:

1) Add a test for the decoder where you have the incoming bytes be
passed 1 at the time to the decoder.
Something like:

ByteBuffer data = ByteBuffer.wrap(new byte[]{
                0b00001111, // literal, index=15
                0b00000000,
                0b00001000, // huffman=false, length=8
                0b00000000, // \
                0b00000000, //  but only 3 octets available...
                0b00000000  // /
        });

for (int i = 0; i < data.remaining(); ++i) {
    decoder.decode(ByteBuffer.wrap(new byte[] {data.get(i)}), ...);

2) Verify what happens when a request comes with a huge cookie (where
huge == 8 MiB or so).
Perhaps a BufferOverflowException is thrown, but you want to report
this in a way that the HTTP implementation can return 431.
Same for the response side (and the encoder).

3) Avoid to drop get/set prefixes from JavaBean methods, e.g.

public int size()
public int maxSize()
public int length()
public void maxHeaderTableSize(int size)

etc. The main reason behind this is to make life easier for tools.
For example, it would be trivial to expose compliant JavaBean
properties via JMX; non compliant JavaBean properties like those above
are not recognized by JMX introspection (nor other introspections).

4) Where possible, try to avoid the use of the modulo operator % - it
is known to be really slow.
>From what I saw, you can probably get by using power of twos and bit
shifting and masking.
It does make the code a little more unreadable though. Your call.

Thanks !

-- 
Simone Bordet
http://bordet.blogspot.com
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz

Reply via email to