Skip to content

Commit

Permalink
Issue checkstyle#13012: Use toASCIIString for all URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
reftel committed Apr 21, 2023
1 parent fc2bdfe commit 1cb2098
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public static Configuration loadConfiguration(String config,
throws CheckstyleException {
// figure out if this is a File or a URL
final URI uri = CommonUtil.getUriByFilename(config);
final InputSource source = new InputSource(uri.toString());
final InputSource source = new InputSource(uri.toASCIIString());
return loadConfiguration(source, overridePropsResolver,
ignoredModulesOptions, threadModeSettings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private void loadHeaderFile() throws CheckstyleException {
}
catch (final IOException ex) {
throw new CheckstyleException(
"unable to load header file " + headerFile, ex);
"unable to load header file " + headerFile.toASCIIString(), ex);
}
}

Expand Down Expand Up @@ -205,7 +205,7 @@ public Set<String> getExternalResourceLocations() {
result = Collections.emptySet();
}
else {
result = Collections.singleton(headerFile.toString());
result = Collections.singleton(headerFile.toASCIIString());
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ else if (currentImportControl != null) {

@Override
public Set<String> getExternalResourceLocations() {
return Collections.singleton(file.toString());
return Collections.singleton(file.toASCIIString());
}

/**
Expand Down Expand Up @@ -608,7 +608,7 @@ public void setFile(URI uri) {
file = uri;
}
catch (CheckstyleException ex) {
throw new IllegalArgumentException(UNABLE_TO_LOAD + uri, ex);
throw new IllegalArgumentException(UNABLE_TO_LOAD + uri.toASCIIString(), ex);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ private static PkgImportControl load(InputSource source,
return loader.getRoot();
}
catch (ParserConfigurationException | SAXException ex) {
throw new CheckstyleException("unable to parse " + uri
throw new CheckstyleException("unable to parse " + uri.toASCIIString()
+ " - " + ex.getMessage(), ex);
}
catch (IOException ex) {
throw new CheckstyleException("unable to read " + uri, ex);
throw new CheckstyleException("unable to read " + uri.toASCIIString(), ex);
}
}

Expand All @@ -292,10 +292,10 @@ private static PkgImportControl loadUri(URI uri) throws CheckstyleException {
return load(source, uri);
}
catch (MalformedURLException ex) {
throw new CheckstyleException("syntax error in url " + uri, ex);
throw new CheckstyleException("syntax error in url " + uri.toASCIIString(), ex);
}
catch (IOException ex) {
throw new CheckstyleException("unable to find " + uri, ex);
throw new CheckstyleException("unable to find " + uri.toASCIIString(), ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public static FilterSet loadSuppressions(String filename)
throws CheckstyleException {
// figure out if this is a File or a URL
final URI uri = CommonUtil.getUriByFilename(filename);
final InputSource source = new InputSource(uri.toString());
final InputSource source = new InputSource(uri.toASCIIString());
return loadSuppressions(source, filename);
}

Expand Down Expand Up @@ -249,7 +249,7 @@ public static Set<TreeWalkerFilter> loadXpathSuppressions(String filename)
throws CheckstyleException {
// figure out if this is a File or a URL
final URI uri = CommonUtil.getUriByFilename(filename);
final InputSource source = new InputSource(uri.toString());
final InputSource source = new InputSource(uri.toASCIIString());
return loadXpathSuppressions(source, filename);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public void testExternalResource() throws Exception {
.isEqualTo(1);
assertWithMessage("Invalid resource location")
.that(results.iterator().next())
.isEqualTo(uri.toString());
.isEqualTo(uri.toASCIIString());
}

@Test
Expand Down

0 comments on commit 1cb2098

Please sign in to comment.