Skip to content

Commit 8c8106c

Browse files
committed
Taken into account PR review comments
1 parent e62e341 commit 8c8106c

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

org.restlet.java/org.restlet/src/main/java/org/restlet/data/Reference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ public static String decode(String toDecode, CharacterSet characterSet) {
141141
try {
142142
result = (characterSet == null) ? toDecode : java.net.URLDecoder.decode(toDecode, characterSet.getName());
143143
} catch (UnsupportedEncodingException uee) {
144-
Context.getCurrentLogger().log(Level.WARNING,
145-
"Unable to decode the string with the " + characterSet.getName() + " character set.", uee);
144+
Context.getCurrentLogger().log(Level.WARNING, uee,
145+
() -> "Unable to decode the string with the " + characterSet.getName() + " character set.");
146146
}
147147

148148
return result;

org.restlet.java/org.restlet/src/test/java/org/restlet/data/ReferenceTestCase.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected Reference getReference() {
6161
* Test addition methods.
6262
*/
6363
@Test
64-
void testAdditions() throws Exception {
64+
void testAdditions() {
6565
final Reference ref = new Reference("http://restlet.org");
6666
ref.addQueryParameter("abc", "123");
6767
assertEquals("http://restlet.org?abc=123", ref.toString());
@@ -618,7 +618,7 @@ void testTargetRef() {
618618
* Test references that are unequal.
619619
*/
620620
@Test
621-
void testUnEquals() throws Exception {
621+
void testUnEquals() {
622622
final String uri1 = "http://restlet.org/";
623623
final String uri2 = "http://restlet.net/";
624624
final Reference ref1 = new Reference(uri1);
@@ -682,8 +682,9 @@ class TestFailures {
682682
"https://normal.com[user@vulndetector].com/",
683683
"https://normal.com[@]vulndetector.com/"
684684
})
685-
void shouldFailWhenParsingIncorrectHosts(String reference) {
686-
assertThrows(IllegalArgumentException.class, () -> new Reference(reference).getAuthority());
685+
void shouldFailWhenParsingIncorrectHosts(String url) {
686+
final Reference reference = new Reference(url);
687+
assertThrows(IllegalArgumentException.class, reference::getAuthority);
687688
}
688689

689690
@ParameterizedTest
@@ -694,24 +695,27 @@ void shouldFailWhenParsingIncorrectHosts(String reference) {
694695
"https://[ffff::127.0.0.4000]",
695696
"https://[0:0::vulndetector.com]:80",
696697
"https://[2001:db8::vulndetector.com]"})
697-
void shouldFailWhenParsingIncorrectIPv6Hosts(String reference) {
698-
assertThrows(IllegalArgumentException.class, () -> new Reference(reference).getAuthority());
698+
void shouldFailWhenParsingIncorrectIPv6Hosts(String url) {
699+
final Reference reference = new Reference(url);
700+
assertThrows(IllegalArgumentException.class, reference::getAuthority);
699701
}
700702

701703
@ParameterizedTest
702704
@ValueSource(strings = {
703705
"http://localhost:18:19",
704706
"http://localhost:18ab"})
705-
void shouldFailWhenParsingIncorrectPort(String reference) {
706-
assertThrows(IllegalArgumentException.class, () -> new Reference(reference).getAuthority());
707+
void shouldFailWhenParsingIncorrectPort(String url) {
708+
final Reference reference = new Reference(url);
709+
assertThrows(IllegalArgumentException.class, reference::getAuthority);
707710
}
708711

709712
@ParameterizedTest
710713
@ValueSource(strings = {
711714
"https>://vulndetector.com/path",
712715
"https%25://vulndetector.com/path"})
713-
void shouldFailWhenParsingIncorrectScheme(String reference) {
714-
assertThrows(IllegalArgumentException.class, () -> new Reference(reference).getScheme());
716+
void shouldFailWhenParsingIncorrectScheme(String url) {
717+
final Reference reference = new Reference(url);
718+
assertThrows(IllegalArgumentException.class, reference::getScheme);
715719
}
716720
}
717721
}

0 commit comments

Comments
 (0)