Skip to content

Commit

Permalink
Merge pull request #21 from oracle/release_20170810
Browse files Browse the repository at this point in the history
Releasing version 1.2.13
  • Loading branch information
mricken authored Aug 10, 2017
2 parents 2db1890 + 2d9a4d4 commit e058ef3
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 41 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
### Added
- N/A

## 1.2.13 - 2017-08-10
### Fixed
- Duplicable stream support (https://github.com/oracle/bmcs-java-sdk/issues/11)
- Fixed NullPointerException on invalid PEM key file

## 1.2.12 - 2017-07-20
### Fixed
- Reduced overhead in signing and serialization
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can find information on any known issues with the SDK [here](https://docs.us

## License

Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.

This SDK and sample is dual licensed under the Universal Permissive License 1.0 and the Apache License 2.0.

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.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -18,7 +18,7 @@
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-common</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
</dependency>
</dependencies>

Expand Down
14 changes: 7 additions & 7 deletions bmc-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -24,7 +24,7 @@
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-common</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<optional>false</optional>
</dependency>

Expand All @@ -33,31 +33,31 @@
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-audit</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-core</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-identity</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-loadbalancer</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-objectstorage</artifactId>
<version>1.2.12</version>
<version>1.2.13</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.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ public PEMFileRSAPrivateKeySupplier(
} else if (object instanceof SubjectPublicKeyInfo) {
throw new IllegalArgumentException(
"Public key provided instead of private key");
} else if (object != null) {
throw new IllegalArgumentException(
"Private key must be in PEM format, was: " + object.getClass());
} else {
throw new IllegalArgumentException(
"Private key must be in PEM format: " + object.getClass());
"Private key must be in PEM format");
}

this.key = (RSAPrivateKey) converter.getPrivateKey(keyInfo);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.oracle.bmc.http.signing.internal;

import org.junit.Test;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

import static org.junit.Assert.fail;

/**
* Tests for {@link PEMFileRSAPrivateKeySupplierTest}.
*/
public class PEMFileRSAPrivateKeySupplierTest {
@Test(expected=IllegalArgumentException.class)
public void ctor_invalidFile() throws IOException {
InputStream notAPem = new ByteArrayInputStream(new byte[0]);
// not a valid key file
new PEMFileRSAPrivateKeySupplier(notAPem, null);
fail("Should have thrown an IllegalArgumentException");
}
}
4 changes: 2 additions & 2 deletions bmc-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -18,7 +18,7 @@
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-common</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
</dependency>
</dependencies>

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

Expand All @@ -19,7 +19,7 @@
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-bom</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions bmc-identity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -18,7 +18,7 @@
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-common</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
</dependency>
</dependencies>

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

Expand All @@ -18,7 +18,7 @@
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-common</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
</dependency>
</dependencies>

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

Expand All @@ -18,7 +18,7 @@
<dependency>
<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk-common</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private UploadResponse multipartUpload(UploadRequest uploadDetails) {

final ExecutorService executorServiceToUse;
final boolean shutdownExecutor;
if (uploadConfiguration.isAllowParallelUploads() && chunkCreator.enableParallelReads()) {
if (uploadConfiguration.isAllowParallelUploads() && chunkCreator.supportsParallelReads()) {
if (uploadDetails.parallelUploadExecutorService != null) {
executorServiceToUse = uploadDetails.parallelUploadExecutorService;
shutdownExecutor = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
*/
package com.oracle.bmc.objectstorage.transfer.internal;

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

import com.oracle.bmc.io.DuplicatableInputStream;

import lombok.extern.slf4j.Slf4j;

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

@Slf4j
public class StreamChunkCreator {
private final InputStream source;
private final long chunkLength;
private final long sourceLength;

private boolean canDuplicate = false;
private long startPosition = 0;
private long endPosition = 0;

Expand All @@ -27,17 +25,18 @@ public StreamChunkCreator(InputStream stream, long contentLength, long chunkLeng
}

/**
* Attempt to enable parallel reads from the underlying stream. If this returns true,
* Test for whether or not the input stream can be read in parallel. If this returns true,
* then streams returned by {@link #next()} are safe to be read from in parallel. If this
* returns false, then streams returned by {@link #next()} must be read from serially.
*
* @return true if parallel reads could be enabled, false if they could not.
*/
public boolean enableParallelReads() {
if (source instanceof DuplicatableInputStream) {
canDuplicate = true;
}
return canDuplicate;
public boolean supportsParallelReads() {
return isSrcStreamDuplicable();
}

private boolean isSrcStreamDuplicable() {
return source instanceof DuplicatableInputStream;
}

/**
Expand All @@ -50,8 +49,8 @@ public boolean hasMore() {

/**
* Returns the next chunk as a new stream. Returned streams must be
* consumed in order unless {@link #enableParallelReads()} was called and
* returned true, in which case the returned streams can be read out of order.
* consumed in order unless {@link #supportsParallelReads()} returned true,
* in which case the returned streams can be read out of order.
* <p>
* Users should call {@link #hasMore()} before calling this.
*
Expand All @@ -71,7 +70,8 @@ public SubRangeInputStream next() {

SubRangeInputStream rangeInputStream = null;

if (canDuplicate) {
// always use duplicated stream when possible, even if parallel reads not enabled
if (isSrcStreamDuplicable()) {
rangeInputStream =
new DuplicatedSubRangeInputStream(
(DuplicatableInputStream) source, startPosition, endPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import static org.junit.Assert.*;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
Expand Down Expand Up @@ -55,8 +56,12 @@ public void serialChunks_readInOrder() throws Exception {

@Test
public void serialChunks_readOutOfOrder() throws Exception {
// set up a non-duplicable stream instead
stream = new ByteArrayInputStream(COMPLETE_STRING.getBytes());

StreamChunkCreator creator =
new StreamChunkCreator(stream, COMPLETE_STRING.length(), CHUNK_SIZE);
assertFalse(creator.supportsParallelReads());

ArrayList<SubRangeInputStream> chunks = new ArrayList<>();
while (creator.hasMore()) {
Expand All @@ -71,15 +76,40 @@ public void serialChunks_readOutOfOrder() throws Exception {
sb.append(content);
}
// even reading all chunks out of order will end up reading the
// underlying bytes in order
// underlying bytes in order, provided the stream is non-duplicable
assertEquals(COMPLETE_STRING, sb.toString());
}

@Test
public void serialChunks_readOutOfOrder_duplicable() throws Exception {
StreamChunkCreator creator =
new StreamChunkCreator(stream, COMPLETE_STRING.length(), CHUNK_SIZE);
assertTrue(creator.supportsParallelReads());

ArrayList<SubRangeInputStream> chunks = new ArrayList<>();
while (creator.hasMore()) {
SubRangeInputStream chunk = creator.next();
chunks.add(chunk);
}
assertEquals(CHUNKS.length, chunks.size());

StringBuilder sb = new StringBuilder();
StringBuilder sbExpected = new StringBuilder();
for (int i = 0; i < CHUNKS.length; i++) {
String content = toString(chunks.get(RANDOM_ORDER[i]));
sb.append(content);
sbExpected.append(CHUNKS[RANDOM_ORDER[i]]);
}
// when reading chunks out of order of a duplicable stream, the bytes will come back
// in the order the chunks were read
assertEquals(sbExpected.toString(), sb.toString());
}

@Test
public void parallelChunks_readInOrder() throws Exception {
StreamChunkCreator creator =
new StreamChunkCreator(stream, COMPLETE_STRING.length(), CHUNK_SIZE);
assertTrue(creator.enableParallelReads());
assertTrue(creator.supportsParallelReads());

int chunkCount = 0;
while (creator.hasMore()) {
Expand All @@ -103,7 +133,7 @@ public void parallelChunks_readInOrder() throws Exception {
public void parallelChunks_readOutOfOrder() throws Exception {
StreamChunkCreator creator =
new StreamChunkCreator(stream, COMPLETE_STRING.length(), CHUNK_SIZE);
assertTrue(creator.enableParallelReads());
assertTrue(creator.supportsParallelReads());

ArrayList<SubRangeInputStream> chunks = new ArrayList<>();
while (creator.hasMore()) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.oracle.bmc.sdk</groupId>
<artifactId>oracle-bmc-java-sdk</artifactId>
<version>1.2.12</version>
<version>1.2.13</version>
<packaging>pom</packaging>

<name>Oracle Bare Metal Cloud Services SDK</name>
Expand Down

0 comments on commit e058ef3

Please sign in to comment.