Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
### Added
- N/A

## 1.3.3 - 2018-12-13
### Added
- Support for Data Guard for VM shapes in the Database service
- Support for sparse disk groups for Exadata shapes in the Database service
- Support for a new field, isLatestForMajorVersion, when listing DB versions in the Database service
- Support for in-transit encryption for paravirtualized boot volume and data volume attachments in the Block Storage service
- Support for tagging DNS Zones in the DNS service
- Support for resetting credentials for SCIM clients associated with an Identity provider and updating user capabilities in the Identity service

### Fixed
- If the response body is an InputStream and the Content-Length header is available, the OCI Java SDK now throws an IOException if the data provided by the InputStream has a different size

## 1.3.2 - 2018-11-29
### Added
- Support for getting bucket statistics in the Object Storage service
Expand Down
4 changes: 2 additions & 2 deletions bmc-addons/bmc-apache-connector-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-addons</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -37,7 +37,7 @@
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-common</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion bmc-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions bmc-audit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -19,7 +19,7 @@
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-common</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
</dependency>
</dependencies>

Expand Down
30 changes: 15 additions & 15 deletions bmc-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>oci-java-sdk-bom</artifactId>
Expand All @@ -19,86 +19,86 @@
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-common</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
<!-- Service modules, alpha sorted -->
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-audit</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-containerengine</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-core</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-database</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-dns</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-email</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-filestorage</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-identity</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-loadbalancer</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-objectstorage</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-resourcesearch</artifactId>
<optional>false</optional>
<version>1.3.2</version>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<optional>false</optional>
<artifactId>oci-java-sdk-addons-apache</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-keymanagement</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<optional>false</optional>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion bmc-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
package com.oracle.bmc.http.internal;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
Expand All @@ -18,6 +17,8 @@

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.google.common.base.Optional;
import com.oracle.bmc.io.internal.ContentLengthVerifyingInputStream;
import com.oracle.bmc.model.BmcException;

import lombok.Builder;
Expand Down Expand Up @@ -188,7 +189,25 @@ public static <T> T readEntity(@NonNull final Response response, Class<T> entity
contentType);
try {
// NOTE: do not buffer InputStreams (namely object storage) as those might be very large
return response.readEntity(entityType);
final InputStream rawInputStream = response.readEntity(InputStream.class);
InputStream inputStream = rawInputStream;

Optional<List<String>> contentLengthHeader =
HeaderUtils.get(
response.getStringHeaders(), HttpHeaders.CONTENT_LENGTH);
// If the Content-Length header is present, verify that the length of the input stream matches it
if (contentLengthHeader.isPresent()) {
long contentLength =
HeaderUtils.toValue(
HttpHeaders.CONTENT_LENGTH,
contentLengthHeader.get().get(0),
Long.class);

inputStream =
new ContentLengthVerifyingInputStream(
rawInputStream, contentLength);
}
return (T) inputStream;
} finally {
response.getHeaders().addAll(HttpHeaders.CONTENT_TYPE, contentType);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/**
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
*/
package com.oracle.bmc.io.internal;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.io.InputStream;

/**
* A wrapper over an {@link java.io.InputStream} whose length is known, which verifies that
* the length of the wrapped stream matches its known length.
*
* NOTE: This implementation of content length verification does not support {@link InputStream#reset()}
* and the verification is disabled upon invocation of {@link InputStream#reset()}.
*/
@Slf4j
@RequiredArgsConstructor
public class ContentLengthVerifyingInputStream extends InputStream {
private final InputStream delegate;
private final long contentLength;

private long totalBytesProcessed = 0L;
private boolean isVerificationEnabled = true;

@Override
public int read() throws IOException {
final int byteRead = delegate.read();
// Either one byte read or eof
final int bytesRead = byteRead != -1 ? 1 : -1;
processBytesRead(bytesRead);
return byteRead;
}

@Override
public int read(byte b[]) throws IOException {
final int bytesRead = delegate.read(b);
processBytesRead(bytesRead);
return bytesRead;
}

@Override
public int read(byte b[], int off, int len) throws IOException {
final int bytesRead = delegate.read(b, off, len);
processBytesRead(bytesRead);
return bytesRead;
}

@Override
public long skip(long n) throws IOException {
final long bytesSkipped = delegate.skip(n);
totalBytesProcessed += bytesSkipped;
return bytesSkipped;
}

@Override
public synchronized void mark(int readlimit) {
delegate.mark(readlimit);
}

@Override
public synchronized void reset() throws IOException {
isVerificationEnabled = false;
LOG.info("Content length verification disabled");
delegate.reset();
}

@Override
public int available() throws IOException {
return delegate.available();
}

@Override
public void close() throws IOException {
delegate.close();
}

@Override
public boolean markSupported() {
return delegate.markSupported();
}

private void processBytesRead(final int bytesRead) throws IOException {
if (!isVerificationEnabled) {
return;
}

if (bytesRead == -1) {
if (totalBytesProcessed != contentLength) {
throw new IOException(
String.format(
"Total bytes processed (%d) does not match content-length (%d)",
totalBytesProcessed,
contentLength));
}
} else {
totalBytesProcessed += bytesRead;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void testReadEntity_streamWithConentType() {
verify(response).readEntity(entityType);
verify(headers).addAll(HttpHeaders.CONTENT_TYPE, contentType);
verify(response, never()).bufferEntity();
verify(response).getStringHeaders();
verifyNoMoreInteractions(response, statusInfo, headers, mockStream);
}

Expand Down
Loading