Skip to content

Commit

Permalink
Use explicit instead of default encoding.
Browse files Browse the repository at this point in the history
Signed-off-by: Santiago Pericasgeertsen <[email protected]>
  • Loading branch information
spericas committed Oct 23, 2023
1 parent e2d25ef commit bc859cb
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static ProxyProtocolData handleV1Protocol(PushbackInputStream inputStream) throw

// protocol and family
n = readUntil(inputStream, buffer, (byte) ' ', (byte) '\r');
String familyProtocol = new String(buffer, 0, n);
String familyProtocol = new String(buffer, 0, n, StandardCharsets.US_ASCII);
var family = Family.fromString(familyProtocol);
var protocol = Protocol.fromString(familyProtocol);
byte b = readNext(inputStream);
Expand All @@ -124,22 +124,22 @@ static ProxyProtocolData handleV1Protocol(PushbackInputStream inputStream) throw

// source address
n = readUntil(inputStream, buffer, (byte) ' ');
var sourceAddress = new String(buffer, 0, n);
var sourceAddress = new String(buffer, 0, n, StandardCharsets.US_ASCII);
match(inputStream, (byte) ' ');

// destination address
n = readUntil(inputStream, buffer, (byte) ' ');
var destAddress = new String(buffer, 0, n);
var destAddress = new String(buffer, 0, n, StandardCharsets.US_ASCII);
match(inputStream, (byte) ' ');

// source port
n = readUntil(inputStream, buffer, (byte) ' ');
int sourcePort = Integer.parseInt(new String(buffer, 0, n));
int sourcePort = Integer.parseInt(new String(buffer, 0, n, StandardCharsets.US_ASCII));
match(inputStream, (byte) ' ');

// destination port
n = readUntil(inputStream, buffer, (byte) '\r');
int destPort = Integer.parseInt(new String(buffer, 0, n));
int destPort = Integer.parseInt(new String(buffer, 0, n, StandardCharsets.US_ASCII));
match(inputStream, (byte) '\r');
match(inputStream, (byte) '\n');

Expand Down

0 comments on commit bc859cb

Please sign in to comment.