[
https://issues.apache.org/jira/browse/MSITE-945?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17869204#comment-17869204
]
ASF GitHub Bot commented on MSITE-945:
--------------------------------------
michael-o commented on code in PR #202:
URL: https://github.com/apache/maven-site-plugin/pull/202#discussion_r1694343621
##########
src/test/java/org/apache/maven/plugins/site/deploy/AuthAsyncProxyServlet.java:
##########
@@ -137,4 +142,16 @@ public void service(ServletRequest req, ServletResponse
res) throws ServletExcep
super.service(req, res);
}
+
+ private void writeByteArrayToFile(File targetFile, ServletInputStream
inputStream) throws IOException {
Review Comment:
Why not
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#copy-java.io.InputStream-java.nio.file.Path-java.nio.file.CopyOption...-?
##########
src/test/java/org/apache/maven/plugins/site/deploy/AbstractSiteDeployWebDavTest.java:
##########
@@ -246,4 +248,26 @@ private boolean
assertAtLeastOneRequestContainsHeader(List<HttpRequest> requests
}
return false;
}
+
+ private void cleanDirectory(File dir) throws IOException {
+ Files.list(dir.toPath())
+ .flatMap(p -> {
+ try {
+ return Files.walk(p);
+ } catch (IOException e) {
+ return Stream.empty();
+ }
+ })
+ .sorted(Comparator.reverseOrder())
+ .forEach(p -> {
+ try {
+ Files.delete(p);
+ } catch (IOException e) {
+ }
+ });
+ }
+
+ private String readFileToString(File fileToTest) throws IOException {
+ return
Files.lines(fileToTest.toPath()).collect(Collectors.joining(System.lineSeparator()));
Review Comment:
I think that this would be more efficient:
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#readAllBytes-java.nio.file.Path-
##########
src/test/java/org/apache/maven/plugins/site/deploy/SimpleDavServerHandler.java:
##########
@@ -74,7 +75,7 @@ public void handle(String target, Request r,
HttpServletRequest request, HttpSer
if (request.getMethod().equalsIgnoreCase("PUT")) {
File targetFile = new File(siteTargetPath, targetPath);
- FileUtils.writeByteArrayToFile(targetFile,
IOUtils.toByteArray(request.getInputStream()));
+ writeInputStreamToFile(targetFile,
request.getInputStream());
Review Comment:
Why not use
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#copy-java.io.InputStream-java.nio.file.Path-java.nio.file.CopyOption...-?
> Remove dependency on Commons IO
> -------------------------------
>
> Key: MSITE-945
> URL: https://issues.apache.org/jira/browse/MSITE-945
> Project: Maven Site Plugin
> Issue Type: Dependency upgrade
> Reporter: Elliotte Rusty Harold
> Priority: Major
> Labels: up-for-grabs
>
> All uses look easily replaceable by standard JDK methods these days
--
This message was sent by Atlassian Jira
(v8.20.10#820010)