Skip to content

Commit

Permalink
Require Java 11
Browse files Browse the repository at this point in the history
Jetty 11 requires this.  Also address some Modernizer issues.
References #422.
  • Loading branch information
gaul committed Aug 8, 2022
1 parent d375011 commit bbbacaa
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<java.version>11</java.version>
<jclouds.version>2.5.0</jclouds.version>
<slf4j.version>1.7.36</slf4j.version>
<shade.prefix>${project.groupId}.shaded</shade.prefix>
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/gaul/s3proxy/NullBlobStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -119,7 +120,7 @@ public String putBlob(String containerName, Blob blob,
PutOptions options) {
long length;
try (InputStream is = blob.getPayload().openStream()) {
length = ByteStreams.copy(is, ByteStreams.nullOutputStream());
length = is.transferTo(OutputStream.nullOutputStream());
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
Expand Down Expand Up @@ -175,7 +176,7 @@ public MultipartPart uploadMultipartPart(MultipartUpload mpu,
int partNumber, Payload payload) {
long length;
try (InputStream is = payload.openStream()) {
length = ByteStreams.copy(is, ByteStreams.nullOutputStream());
length = is.transferTo(OutputStream.nullOutputStream());
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/gaul/s3proxy/S3ProxyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ public final void doHandle(HttpServletRequest baseRequest,

String[] path = uri.split("/", 3);
for (int i = 0; i < path.length; i++) {
path[i] = URLDecoder.decode(path[i], UTF_8);
path[i] = URLDecoder.decode(path[i], StandardCharsets.UTF_8);
}

Map.Entry<String, BlobStore> provider =
Expand Down Expand Up @@ -1762,7 +1762,7 @@ private void handleGetBlob(HttpServletRequest request,

try (InputStream is = blob.getPayload().openStream();
OutputStream os = response.getOutputStream()) {
ByteStreams.copy(is, os);
is.transferTo(os);
os.flush();
}
}
Expand All @@ -1772,7 +1772,8 @@ private void handleCopyBlob(HttpServletRequest request,
String destContainerName, String destBlobName)
throws IOException, S3Exception {
String copySourceHeader = request.getHeader(AwsHttpHeaders.COPY_SOURCE);
copySourceHeader = URLDecoder.decode(copySourceHeader, UTF_8);
copySourceHeader = URLDecoder.decode(
copySourceHeader, StandardCharsets.UTF_8);
if (copySourceHeader.startsWith("/")) {
// Some clients like boto do not include the leading slash
copySourceHeader = copySourceHeader.substring(1);
Expand Down Expand Up @@ -2520,7 +2521,8 @@ private void handleCopyPart(HttpServletRequest request,
throws IOException, S3Exception {
// TODO: duplicated from handlePutBlob
String copySourceHeader = request.getHeader(AwsHttpHeaders.COPY_SOURCE);
copySourceHeader = URLDecoder.decode(copySourceHeader, UTF_8);
copySourceHeader = URLDecoder.decode(
copySourceHeader, StandardCharsets.UTF_8);
if (copySourceHeader.startsWith("/")) {
// Some clients like boto do not include the leading slash
copySourceHeader = copySourceHeader.substring(1);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/gaul/s3proxy/AwsSdkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.junit.Assume.assumeTrue;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
Expand Down Expand Up @@ -93,7 +94,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.io.ByteSource;
import com.google.common.io.ByteStreams;

import org.assertj.core.api.Fail;

Expand Down Expand Up @@ -653,7 +653,7 @@ public void testOverrideResponseHeader() throws Exception {
S3Object object = client.getObject(getObjectRequest);
try (InputStream is = object.getObjectContent()) {
assertThat(is).isNotNull();
ByteStreams.copy(is, ByteStreams.nullOutputStream());
is.transferTo(OutputStream.nullOutputStream());
}

ObjectMetadata reponseMetadata = object.getObjectMetadata();
Expand Down Expand Up @@ -1446,7 +1446,7 @@ public void testConditionalGet() throws Exception {
.withMatchingETagConstraint(result.getETag()));
try (InputStream is = object.getObjectContent()) {
assertThat(is).isNotNull();
ByteStreams.copy(is, ByteStreams.nullOutputStream());
is.transferTo(OutputStream.nullOutputStream());
}

object = client.getObject(
Expand Down
18 changes: 9 additions & 9 deletions src/test/java/org/gaul/s3proxy/NullBlobStoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Random;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.ByteSource;
import com.google.common.io.ByteStreams;
import com.google.common.net.MediaType;
import com.google.inject.Module;

Expand Down Expand Up @@ -91,10 +91,10 @@ public void testCreateBlobGetBlob() throws Exception {
// content differs, only compare length
try (InputStream actual = blob.getPayload().openStream();
InputStream expected = BYTE_SOURCE.openStream()) {
long actualLength = ByteStreams.copy(actual,
ByteStreams.nullOutputStream());
long expectedLength = ByteStreams.copy(expected,
ByteStreams.nullOutputStream());
long actualLength = actual.transferTo(
OutputStream.nullOutputStream());
long expectedLength = expected.transferTo(
OutputStream.nullOutputStream());
assertThat(actualLength).isEqualTo(expectedLength);
}

Expand Down Expand Up @@ -157,10 +157,10 @@ public void testCreateMultipartBlobGetBlob() throws Exception {
// content differs, only compare length
try (InputStream actual = newBlob.getPayload().openStream();
InputStream expected = byteSource.openStream()) {
long actualLength = ByteStreams.copy(actual,
ByteStreams.nullOutputStream());
long expectedLength = ByteStreams.copy(expected,
ByteStreams.nullOutputStream());
long actualLength = actual.transferTo(
OutputStream.nullOutputStream());
long expectedLength = expected.transferTo(
OutputStream.nullOutputStream());
assertThat(actualLength).isEqualTo(expectedLength);
}

Expand Down

0 comments on commit bbbacaa

Please sign in to comment.