diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java index 15c845a507..75e2aff439 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java @@ -101,7 +101,7 @@ public class DeadLinksChecker { scannedFiles++; // iterate line-by-line for better reporting the line numbers - final String[] lines = pageContent.split("\r?\n|\n"); + final String[] lines = pageContent.split("\r?\n"); for (int index = 0; index < lines.length; index++) { final String line = lines[index]; final int lineNo = index + 1; @@ -262,16 +262,14 @@ public class DeadLinksChecker { private List listMdFiles(Path pagesDirectory) { - final List mdFiles = new ArrayList<>(); try { - Files.walk(pagesDirectory) + return Files.walk(pagesDirectory) .filter(Files::isRegularFile) .filter(path -> path.toString().endsWith(".md")) - .forEach(mdFiles::add); + .collect(Collectors.toList()); } catch (IOException ex) { throw new RuntimeException("error listing files in " + pagesDirectory, ex); } - return mdFiles; } @@ -300,7 +298,7 @@ public class DeadLinksChecker { private int computeHttpResponse(String url) { try { final HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(url).openConnection(); - httpURLConnection.setRequestMethod("GET"); + httpURLConnection.setRequestMethod("HEAD"); httpURLConnection.setConnectTimeout(5000); httpURLConnection.setReadTimeout(15000); httpURLConnection.connect();