From b3335cf6e50adeea3600e165585e146e1524ea3a Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sun, 1 Apr 2018 12:28:28 +0200 Subject: [PATCH] Changes to avoid compile warnings --- .../java/org/apache/archiva/checksum/ChecksummedFileTest.java | 4 ++-- .../archiva/consumers/core/MetadataUpdaterConsumer.java | 4 ---- archiva-modules/archiva-base/archiva-repository-layer/pom.xml | 2 -- .../org/apache/archiva/transaction/AbstractFileEventTest.java | 2 +- .../java/org/apache/archiva/web/docs/RestDocsServlet.java | 2 +- .../apache/archiva/remotedownload/DownloadArtifactsTest.java | 3 ++- .../apache/archiva/remotedownload/DownloadSnapshotTest.java | 3 ++- 7 files changed, 8 insertions(+), 12 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksummedFileTest.java b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksummedFileTest.java index 963cd87bc..727953ec9 100644 --- a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksummedFileTest.java +++ b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksummedFileTest.java @@ -133,7 +133,7 @@ public class ChecksummedFileTest checksummedFile.createChecksum( ChecksumAlgorithm.SHA1 ); Path hashFile = checksummedFile.getChecksumFile( ChecksumAlgorithm.SHA1 ); assertTrue( "ChecksumAlgorithm file should exist.", Files.exists(hashFile) ); - String hashContents = org.apache.commons.io.FileUtils.readFileToString( hashFile.toFile() ); + String hashContents = org.apache.commons.io.FileUtils.readFileToString( hashFile.toFile(), "UTF-8" ); hashContents = StringUtils.trim( hashContents ); assertEquals( "2bb14b388973351b0a4dfe11d171965f59cc61a1 redback-authz-open.jar", hashContents ); } @@ -146,7 +146,7 @@ public class ChecksummedFileTest Path sha1File = jarFile.resolveSibling( jarFile.getFileName()+ ".sha1" ); // A typical scenario seen in the wild. - org.apache.commons.io.FileUtils.writeStringToFile( sha1File.toFile(), "sha1sum: redback-authz-open.jar: No such file or directory" ); + org.apache.commons.io.FileUtils.writeStringToFile( sha1File.toFile(), "sha1sum: redback-authz-open.jar: No such file or directory", "UTF-8" ); ChecksummedFile checksummedFile = new ChecksummedFile( jarFile ); assertFalse( "ChecksummedFile.isValid(SHA1) == false", diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java index 6af89a33a..aef12a553 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java @@ -131,10 +131,6 @@ public class MetadataUpdaterConsumer this.repositoryDir = Paths.get( repository.getRepoRoot( ) ); this.scanStartTimestamp = System.currentTimeMillis( ); } - catch ( RepositoryNotFoundException e ) - { - throw new ConsumerException( e.getMessage( ), e ); - } catch ( RepositoryException e ) { throw new ConsumerException( e.getMessage( ), e ); diff --git a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml index a33ba65be..196ae4534 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml @@ -148,11 +148,9 @@ javax.inject, org.apache.archiva.model*;version=${project.version}, org.apache.archiva.maven2.metadata*;version=${project.version}, - org.apache.archiva.admin.model*;version=${project.version}, org.apache.archiva.common*;version=${project.version}, org.apache.archiva.checksum;version=${project.version}, org.apache.archiva.configuration;version=${project.version}, - org.apache.archiva.metadata*;version=${project.version}, org.apache.archiva.xml;version=${project.version}, org.apache.commons.collections;version="[3.2,4)", org.apache.commons.io;version="[1.4,2)", diff --git a/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/archiva/transaction/AbstractFileEventTest.java b/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/archiva/transaction/AbstractFileEventTest.java index 0905c477c..fd6c45143 100644 --- a/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/archiva/transaction/AbstractFileEventTest.java +++ b/archiva-modules/archiva-base/archiva-transaction/src/test/java/org/apache/archiva/transaction/AbstractFileEventTest.java @@ -89,7 +89,7 @@ public abstract class AbstractFileEventTest protected String readFile( Path file ) throws IOException { - return FileUtils.readFileToString( file.toFile() ); + return FileUtils.readFileToString( file.toFile(), Charset.forName( "UTF-8" ) ); } protected void writeFile( Path file, String content ) diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/docs/RestDocsServlet.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/docs/RestDocsServlet.java index 3e91e48c5..b99be0395 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/docs/RestDocsServlet.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/docs/RestDocsServlet.java @@ -56,7 +56,7 @@ public class RestDocsServlet if ( StringUtils.endsWith( path, ".xsd" ) ) { - StringEscapeUtils.escapeXml( resp.getWriter(), IOUtils.toString( is ) ); + StringEscapeUtils.escapeXml( resp.getWriter(), IOUtils.toString( is, "UTF-8" ) ); //IOUtils.copy( is, resp.getOutputStream() ); return; } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java index f1c79ae8a..db2a713a2 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactsTest.java @@ -44,6 +44,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -182,7 +183,7 @@ public class DownloadArtifactsTest List entries = getZipEntriesNames( zipFile ); ZipEntry zipEntry = zipFile.getEntry( "org/junit/runners/JUnit4.class" ); assertNotNull( "cannot find zipEntry org/junit/runners/JUnit4.class, entries: " + entries + ", content is: " - + FileUtils.readFileToString( file.toFile() ), zipEntry ); + + FileUtils.readFileToString( file.toFile(), Charset.forName( "UTF-8") ), zipEntry ); zipFile.close(); file.toFile().deleteOnExit(); } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadSnapshotTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadSnapshotTest.java index 024e1b855..eeacbf989 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadSnapshotTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadSnapshotTest.java @@ -34,6 +34,7 @@ import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -126,7 +127,7 @@ public class DownloadSnapshotTest List entries = getZipEntriesNames( zipFile ); ZipEntry zipEntry = zipFile.getEntry( "org/apache/archiva/model/ArchivaArtifact.class" ); assertNotNull( "cannot find zipEntry org/apache/archiva/model/ArchivaArtifact.class, entries: " + entries + ", content is: " - + FileUtils.readFileToString( file.toFile() ), zipEntry ); + + FileUtils.readFileToString( file.toFile(), Charset.forName( "UTF-8") ), zipEntry ); zipFile.close(); file.toFile().deleteOnExit(); -- 2.39.5