@@ -30,10 +30,17 @@ public static ProxyHeader parse(byte[] data, int offset, int length) throws Prox
3030 }
3131
3232 public static ProxyHeader parse (byte [] data , int offset , int length , boolean parseTlvs ) throws ProxyProtocolParseException , IllegalArgumentException {
33- if (data == null || offset < 0 || length < 0 ) throw new IllegalArgumentException ("Invalid arguments" );
34- if ((length +offset ) > data .length ) throw new IllegalArgumentException ("Invalid offset/length combination with data length" );
33+ if (data == null || offset < 0 || length < 0 ) {
34+ throw new IllegalArgumentException ("Invalid arguments" );
35+ }
36+
37+ if ((length +offset ) > data .length ) {
38+ throw new IllegalArgumentException ("Invalid offset/length combination with data length" );
39+ }
3540
36- if (PROTOCOL_SIGNATURE_FIXED_LENGTH > length ) throw new ProxyProtocolParseException ("Insufficient data for header" );
41+ if (PROTOCOL_SIGNATURE_FIXED_LENGTH > length ) {
42+ throw new ProxyProtocolParseException ("Insufficient data for header" );
43+ }
3744
3845 for (int i = 0 ; i < PROTOCOL_SIGNATURE .length ; i ++) {
3946 if (data [offset + i ] != PROTOCOL_SIGNATURE [i ]) {
@@ -46,8 +53,12 @@ public static ProxyHeader parse(byte[] data, int offset, int length, boolean par
4653 // Byte 13: version/command
4754 int verCmd = data [pos ++] & 0xFF ;
4855 int version = (verCmd >> 4 ) & 0x0F ;
49- if (version != 2 ) throw new ProxyProtocolParseException ("Invalid version" );
5056 int cmd = verCmd & 0x0F ;
57+
58+ if (version != 2 ) {
59+ throw new ProxyProtocolParseException ("Invalid version" );
60+ }
61+
5162 ProxyHeader .Command command ;
5263 switch (cmd ) {
5364 case 0x00 :
@@ -73,7 +84,9 @@ public static ProxyHeader parse(byte[] data, int offset, int length, boolean par
7384
7485 // Check if we have enough data for the header
7586 int headerLen = PROTOCOL_SIGNATURE_FIXED_LENGTH + variableLength ;
76- if (headerLen > length ) throw new ProxyProtocolParseException ("Insufficient data for header" );
87+ if (headerLen > length ) {
88+ throw new ProxyProtocolParseException ("Insufficient data for header" );
89+ }
7790
7891 AddressPair addresses = null ;
7992 if (af != ProxyHeader .AddressFamily .AF_UNSPEC ) {
0 commit comments