Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DURACLOUD-1292: Updates dependency versions #145

Merged
merged 1 commit into from Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions chunk/src/main/java/org/duracloud/chunk/ChunkableContent.java
Expand Up @@ -168,6 +168,10 @@ private void throwIfChunkNotFullyRead() {
StringBuilder sb = new StringBuilder("Error: ");
sb.append("Previous chunk not fully read: ");
sb.append(currentChunk.getChunkId());
sb.append(" Chunk size: ");
sb.append(currentChunk.getChunkSize());
sb.append(", Bytes read: ");
sb.append(currentChunk.numBytesRead());
log.error(sb.toString());
throw new DuraCloudRuntimeException(sb.toString());
}
Expand Down
Expand Up @@ -25,6 +25,7 @@
import org.duracloud.chunk.stream.ChunkInputStream;
import org.duracloud.chunk.stream.KnownLengthInputStream;
import org.duracloud.common.error.DuraCloudRuntimeException;
import org.duracloud.common.util.IOUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -159,11 +160,7 @@ private AddContentResult writeContent(String spaceId,
contentSize);
result.setState(AddContentResult.State.SUCCESS);
try {
if (contentSize > TWO_GB) {
copyLarge(inputStream, outStream);
} else {
copy(inputStream, outStream);
}
copy(inputStream, outStream);
} catch (Exception e) {
result.setState(AddContentResult.State.ERROR);
}
Expand All @@ -174,20 +171,10 @@ private AddContentResult writeContent(String spaceId,
return result;
}

private void copyLarge(InputStream chunk, OutputStream outStream) {
try {
IOUtils.copyLarge(chunk, outStream);
} catch (IOException e) {
String msg = "Error in copy: " + chunk.toString() + ": ";
log.error(msg, e);
throw new DuraCloudRuntimeException(msg + e.getMessage(), e);
}
}

private void copy(InputStream chunk, OutputStream outStream) {
try {
IOUtils.copy(chunk, outStream);
} catch (IOException e) {
IOUtil.copy(chunk, outStream);
} catch (DuraCloudRuntimeException e) {
String msg = "Error in copy: " + chunk.toString() + ": ";
log.error(msg, e);
throw new DuraCloudRuntimeException(msg + e.getMessage(), e);
Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.duracloud.chunk.stream.KnownLengthInputStream;
import org.duracloud.common.error.DuraCloudRuntimeException;
import org.duracloud.common.util.ChecksumUtil;
import org.duracloud.common.util.IOUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
Expand Down Expand Up @@ -90,7 +91,7 @@ private void doChunking() throws IOException {
chunkFiles.add(f);

out = new FileOutputStream(f);
IOUtils.copy(chunk, out);
IOUtil.copy(chunk, out);

IOUtils.closeQuietly(chunk);
IOUtils.closeQuietly(out);
Expand Down
7 changes: 5 additions & 2 deletions common/src/main/java/org/duracloud/common/util/IOUtil.java
Expand Up @@ -31,6 +31,9 @@
*/
public class IOUtil {

// Maintain default buffer size from commons-io prior to v2.7 (where it changed to 8192)
private static final int COPY_BUFFER_SIZE = 4096;

private IOUtil() {
// Ensures no instances are made of this class, as there are only static members.
}
Expand Down Expand Up @@ -60,7 +63,7 @@ public static OutputStream getOutputStream(File file) {

public static void copy(InputStream input, OutputStream output) {
try {
IOUtils.copy(input, output);
IOUtils.copy(input, output, COPY_BUFFER_SIZE);
} catch (IOException e) {
throw new DuraCloudRuntimeException(e);
}
Expand Down Expand Up @@ -95,7 +98,7 @@ public static File writeStreamToFile(InputStream inStream, boolean gzip) {
if (gzip) {
outStream = new GZIPOutputStream(outStream);
}
IOUtils.copy(inStream, outStream);
IOUtils.copy(inStream, outStream, COPY_BUFFER_SIZE);
} catch (IOException e) {
String err = "Error writing stream to file: " + e.getMessage();

Expand Down
Expand Up @@ -14,11 +14,11 @@
import java.util.Date;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.IOUtils;
import org.apache.http.HttpStatus;
import org.duracloud.client.ContentStore;
import org.duracloud.client.ContentStoreManager;
import org.duracloud.common.util.DateUtil.DateFormat;
import org.duracloud.common.util.IOUtil;
import org.duracloud.error.ContentStoreException;
import org.duracloud.error.NotFoundException;
import org.slf4j.Logger;
Expand Down Expand Up @@ -66,7 +66,7 @@ public String get(@PathVariable("storeId") String storeId,
+ ".tsv");
contentDisposition.append("\"");
response.setHeader("Content-Disposition", contentDisposition.toString());
IOUtils.copy(is, response.getOutputStream());
IOUtil.copy(is, response.getOutputStream());
} catch (NotFoundException ex) {
response.setStatus(HttpStatus.SC_NOT_FOUND);

Expand Down
Expand Up @@ -14,12 +14,12 @@
import java.util.Date;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.IOUtils;
import org.apache.http.HttpStatus;
import org.duracloud.client.ContentStore;
import org.duracloud.client.ContentStoreManager;
import org.duracloud.common.constant.ManifestFormat;
import org.duracloud.common.util.DateUtil.DateFormat;
import org.duracloud.common.util.IOUtil;
import org.duracloud.error.ContentStoreException;
import org.duracloud.error.NotFoundException;
import org.slf4j.Logger;
Expand Down Expand Up @@ -76,7 +76,7 @@ public String get(@PathVariable("storeId") String storeId,
+ extension);
contentDisposition.append("\"");
response.setHeader("Content-Disposition", contentDisposition.toString());
IOUtils.copy(is, response.getOutputStream());
IOUtil.copy(is, response.getOutputStream());
} catch (NotFoundException ex) {
response.setStatus(HttpStatus.SC_NOT_FOUND);

Expand Down
Expand Up @@ -283,7 +283,7 @@ public void testSetSpaceACLs() throws Exception {
@Test
public void testClearCache() throws InterruptedException {
String spaceId = "ACLStorageProvider-cache";
createMockStorageProvider(3);
createMockStorageProvider(2);

expect(mockProvider.getSpaceACLs(spaceId))
.andReturn(new HashMap<String, AclType>());
Expand Down
48 changes: 33 additions & 15 deletions pom.xml
Expand Up @@ -238,11 +238,11 @@
<org.springframework.security.version>4.0.4.RELEASE</org.springframework.security.version>
<org.springframework.webflow.version>2.4.2.RELEASE</org.springframework.webflow.version>
<hibernate.version>5.1.0.Final</hibernate.version>
<aws.sdk.version>1.11.155</aws.sdk.version>
<aws.sdk.version>1.12.24</aws.sdk.version>
<jersey.version>2.5.1</jersey.version>
<jackson.version>2.7.4</jackson.version>
<jackson.version>2.12.3</jackson.version>
<tiles.version>2.2.2</tiles.version>
<selenium.version>2.19.0</selenium.version>
<selenium.version>2.53.1</selenium.version>
<slf4j.version>1.7.6</slf4j.version>
<jetty.version>9.4.31.v20200723</jetty.version>
<jaxb.api.version>2.3.1</jaxb.api.version>
Expand Down Expand Up @@ -634,7 +634,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<version>4.13.2</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
Expand All @@ -658,7 +658,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
<version>1.2.0</version>
</dependency>

<dependency>
Expand All @@ -676,7 +676,7 @@
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.7</version>
<version>1.4.17</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -731,7 +731,7 @@
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
<version>2.12.1</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -773,13 +773,13 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>2.7</version>
</dependency>

<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.2</version>
<version>1.9.4</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
Expand All @@ -795,25 +795,29 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
<version>4.5.13</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.2</version>
<version>4.5.13</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.4</version>
<version>4.4.13</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -943,7 +947,7 @@
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.3.0</version>
<version>3.0.2</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -1041,6 +1045,14 @@
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down Expand Up @@ -1297,7 +1309,7 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
<version>1.15</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -1382,6 +1394,12 @@
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>${jackson.version}</version>
<exclusions>
<exclusion>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -1464,7 +1482,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>17.0</version>
<version>30.1.1-jre</version>
</dependency>

<dependency>
Expand Down
Expand Up @@ -21,13 +21,13 @@
import java.util.Map;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.duracloud.chunk.util.ChunkUtil;
import org.duracloud.client.ContentStore;
import org.duracloud.common.model.ContentItem;
import org.duracloud.common.retry.Retrier;
import org.duracloud.common.util.ChecksumUtil;
import org.duracloud.common.util.DateUtil;
import org.duracloud.common.util.IOUtil;
import org.duracloud.retrieval.source.ContentStream;
import org.duracloud.retrieval.source.RetrievalSource;
import org.duracloud.stitch.error.MissingContentException;
Expand Down Expand Up @@ -249,7 +249,7 @@ protected Map<String, String> retrieveToFile(File localFile, RetrievalListener l
InputStream inStream = contentStream.getStream();
OutputStream outStream = new FileOutputStream(localFile);
) {
IOUtils.copyLarge(inStream, outStream);
IOUtil.copy(inStream, outStream);
} catch (IOException e) {
try {
deleteFile(localFile);
Expand Down
Expand Up @@ -20,9 +20,9 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.apache.commons.io.IOUtils;
import org.duracloud.client.ContentStore;
import org.duracloud.common.model.ContentItem;
import org.duracloud.common.util.IOUtil;
import org.duracloud.domain.Content;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
Expand Down Expand Up @@ -127,7 +127,7 @@ public void testGetSourceContent() throws Exception {
assertEquals(checksum, contentStream.getChecksum());

ByteArrayOutputStream outStream = new ByteArrayOutputStream();
IOUtils.copy(contentStream.getStream(), outStream);
IOUtil.copy(contentStream.getStream(), outStream);
assertEquals(value, outStream.toString("UTF-8"));
}

Expand Down
Expand Up @@ -103,13 +103,23 @@ private static AmazonS3 newS3Client(String accessKey,
} else {
awsRegion = System.getProperty(OPTS.AWS_REGION.name());
}
// Construct a normal client that connects to AWS.
log.debug("Creating AWS S3 Client.");
s3Client = AmazonS3ClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
.withRegion(awsRegion)
.build();

if (null == awsRegion) {
// Construct an AWS client with no region set (the provider chain will be consulted)
log.debug("Creating AWS S3 Client with no explicit region.");
s3Client = AmazonS3ClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
.build();
} else {
// Construct an AWS client with a specified region
log.debug("Creating AWS S3 Client with region: " + awsRegion);
s3Client = AmazonS3ClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
.withRegion(awsRegion)
.build();
}
} else {
// Construct a client that will work with S3+Swift
log.debug("Creating Swift S3 client.");
Expand Down