Skip to content

Commit

Permalink
Parser class renamed.
Browse files Browse the repository at this point in the history
Signed-off-by: Santiago Pericasgeertsen <[email protected]>
  • Loading branch information
spericas committed Jan 10, 2024
1 parent 7a89f84 commit 2be644b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import java.util.function.Supplier;

/**
* Utility class to properly report integer parsing errors.
* Utility class for parsing.
*/
public class IntegerParser {
public class ParserHelper {

private IntegerParser() {
private ParserHelper() {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

class IntegerParserTest {
class ParserHelperTest {

@Test
void testNormalParse() {
int v = IntegerParser.parseNonNegative(
int v = ParserHelper.parseNonNegative(
"7FFFFFFF",
16,
() -> new RuntimeException("Oops"));
Expand All @@ -35,7 +35,7 @@ void testNormalParse() {
@Test
void testNegativeParse() {
assertThrows(RuntimeException.class, () ->
IntegerParser.parseNonNegative("FFFFFFFF",
ParserHelper.parseNonNegative("FFFFFFFF",
16,
() -> new RuntimeException("Value is invalid")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

import io.helidon.common.IntegerParser;
import io.helidon.common.ParserHelper;
import io.helidon.common.buffers.BufferData;
import io.helidon.common.buffers.Bytes;
import io.helidon.common.buffers.DataReader;
Expand Down Expand Up @@ -57,7 +57,7 @@

abstract class Http1CallChainBase implements WebClientService.Chain {
private static final System.Logger LOGGER = System.getLogger(Http1CallChainBase.class.getName());
private static final Supplier<IllegalArgumentException> INVALID_SIZE_SUPPLIER =
private static final Supplier<IllegalArgumentException> INVALID_SIZE_EXCEPTION_SUPPLIER =
() -> new IllegalArgumentException("Chunk size is invalid");

private final BufferData writeBuffer = BufferData.growing(128);
Expand Down Expand Up @@ -511,7 +511,7 @@ private void ensureBuffer() {
reader.skip(2); // CRLF
int length;
try {
length = IntegerParser.parseNonNegative(hex, 16, INVALID_SIZE_SUPPLIER);
length = ParserHelper.parseNonNegative(hex, 16, INVALID_SIZE_EXCEPTION_SUPPLIER);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Chunk size is not a number:\n"
+ BufferData.create(hex.getBytes(US_ASCII)).debugDataHex());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.concurrent.Semaphore;
import java.util.function.Supplier;

import io.helidon.common.IntegerParser;
import io.helidon.common.ParserHelper;
import io.helidon.common.buffers.BufferData;
import io.helidon.common.buffers.DataReader;
import io.helidon.common.buffers.DataWriter;
Expand Down Expand Up @@ -66,7 +66,7 @@
*/
public class Http1Connection implements ServerConnection, InterruptableTask<Void> {
private static final System.Logger LOGGER = System.getLogger(Http1Connection.class.getName());
private static final Supplier<RequestException> INVALID_SIZE_SUPPLIER =
private static final Supplier<RequestException> INVALID_SIZE_EXCEPTION_SUPPLIER =
() -> RequestException.builder()
.type(EventType.BAD_REQUEST)
.message("Chunk size is invalid")
Expand Down Expand Up @@ -271,7 +271,7 @@ private BufferData readEntityFromPipeline(HttpPrologue prologue, WritableHeaders
private BufferData readNextChunk(HttpPrologue prologue, WritableHeaders<?> headers) {
// chunk length processing
String hex = reader.readLine();
int chunkLength = IntegerParser.parseNonNegative(hex, 16, INVALID_SIZE_SUPPLIER);
int chunkLength = ParserHelper.parseNonNegative(hex, 16, INVALID_SIZE_EXCEPTION_SUPPLIER);

currentEntitySizeRead += chunkLength;
if (maxPayloadSize != -1 && currentEntitySizeRead > maxPayloadSize) {
Expand Down

0 comments on commit 2be644b

Please sign in to comment.