Use parseInt without substring method

This commit is contained in:
김보배(Bobae Kim)/Platform Engineering팀/11ST
2021-11-12 14:53:27 +09:00
committed by Arjen Poutsma
parent 79d3f5c64c
commit 804b343cab
13 changed files with 24 additions and 24 deletions

View File

@@ -94,7 +94,7 @@ class ReactorServerHttpRequest extends AbstractServerHttpRequest {
if (portIndex != -1) {
try {
return new URI(scheme, null, header.substring(0, portIndex),
Integer.parseInt(header.substring(portIndex + 1)), null, null, null);
Integer.parseInt(header, portIndex + 1, header.length(), 10), null, null, null);
}
catch (NumberFormatException ex) {
throw new URISyntaxException(header, "Unable to parse port", portIndex);

View File

@@ -364,7 +364,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
}
host = value.substring(0, portSeparatorIdx);
try {
port = Integer.parseInt(value.substring(portSeparatorIdx + 1));
port = Integer.parseInt(value, portSeparatorIdx + 1, value.length(), 10);
}
catch (NumberFormatException ex) {
throw new IllegalArgumentException(
@@ -904,7 +904,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
throw new IllegalArgumentException("Invalid IPv4 address: " + rawValue);
}
host(rawValue.substring(0, portSeparatorIdx));
port(Integer.parseInt(rawValue.substring(portSeparatorIdx + 1)));
port(Integer.parseInt(rawValue, portSeparatorIdx + 1, rawValue.length(), 10));
}
else {
host(rawValue);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -174,7 +174,7 @@ public class HtmlCharacterEntityReferencesTests {
private int nextReferredCharacterId() throws IOException {
String reference = nextWordToken();
if (reference != null && reference.startsWith("&#") && reference.endsWith(";")) {
return Integer.parseInt(reference.substring(2, reference.length() - 1));
return Integer.parseInt(reference, 2, reference.length() - 1, 10);
}
return -1;
}

View File

@@ -710,7 +710,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
idx = host.indexOf(':');
}
if (idx != -1) {
return Integer.parseInt(host.substring(idx + 1));
return Integer.parseInt(host, idx + 1, host.length(), 10);
}
}