Skip to content

Commit e058ef3

Browse files
authored
Merge pull request #21 from oracle/release_20170810
Releasing version 1.2.13
2 parents 2db1890 + 2d9a4d4 commit e058ef3

File tree

16 files changed

+103
-41
lines changed

16 files changed

+103
-41
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
1313
### Added
1414
- N/A
1515

16+
## 1.2.13 - 2017-08-10
17+
### Fixed
18+
- Duplicable stream support (https://github.com/oracle/bmcs-java-sdk/issues/11)
19+
- Fixed NullPointerException on invalid PEM key file
20+
1621
## 1.2.12 - 2017-07-20
1722
### Fixed
1823
- Reduced overhead in signing and serialization

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ You can find information on any known issues with the SDK [here](https://docs.us
4141

4242
## License
4343

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

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

bmc-audit/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.oracle.bmc.sdk</groupId>
77
<artifactId>oracle-bmc-java-sdk</artifactId>
8-
<version>1.2.12</version>
8+
<version>1.2.13</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

@@ -18,7 +18,7 @@
1818
<dependency>
1919
<groupId>com.oracle.bmc.sdk</groupId>
2020
<artifactId>oracle-bmc-java-sdk-common</artifactId>
21-
<version>1.2.12</version>
21+
<version>1.2.13</version>
2222
</dependency>
2323
</dependencies>
2424

bmc-bom/pom.xml

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.oracle.bmc.sdk</groupId>
99
<artifactId>oracle-bmc-java-sdk</artifactId>
10-
<version>1.2.12</version>
10+
<version>1.2.13</version>
1111
<relativePath>../pom.xml</relativePath>
1212
</parent>
1313

@@ -24,7 +24,7 @@
2424
<dependency>
2525
<groupId>com.oracle.bmc.sdk</groupId>
2626
<artifactId>oracle-bmc-java-sdk-common</artifactId>
27-
<version>1.2.12</version>
27+
<version>1.2.13</version>
2828
<optional>false</optional>
2929
</dependency>
3030

@@ -33,31 +33,31 @@
3333
<dependency>
3434
<groupId>com.oracle.bmc.sdk</groupId>
3535
<artifactId>oracle-bmc-java-sdk-audit</artifactId>
36-
<version>1.2.12</version>
36+
<version>1.2.13</version>
3737
<optional>false</optional>
3838
</dependency>
3939
<dependency>
4040
<groupId>com.oracle.bmc.sdk</groupId>
4141
<artifactId>oracle-bmc-java-sdk-core</artifactId>
42-
<version>1.2.12</version>
42+
<version>1.2.13</version>
4343
<optional>false</optional>
4444
</dependency>
4545
<dependency>
4646
<groupId>com.oracle.bmc.sdk</groupId>
4747
<artifactId>oracle-bmc-java-sdk-identity</artifactId>
48-
<version>1.2.12</version>
48+
<version>1.2.13</version>
4949
<optional>false</optional>
5050
</dependency>
5151
<dependency>
5252
<groupId>com.oracle.bmc.sdk</groupId>
5353
<artifactId>oracle-bmc-java-sdk-loadbalancer</artifactId>
54-
<version>1.2.12</version>
54+
<version>1.2.13</version>
5555
<optional>false</optional>
5656
</dependency>
5757
<dependency>
5858
<groupId>com.oracle.bmc.sdk</groupId>
5959
<artifactId>oracle-bmc-java-sdk-objectstorage</artifactId>
60-
<version>1.2.12</version>
60+
<version>1.2.13</version>
6161
<optional>false</optional>
6262
</dependency>
6363
</dependencies>

bmc-common/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.oracle.bmc.sdk</groupId>
77
<artifactId>oracle-bmc-java-sdk</artifactId>
8-
<version>1.2.12</version>
8+
<version>1.2.13</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

bmc-common/src/main/java/com/oracle/bmc/http/signing/internal/PEMFileRSAPrivateKeySupplier.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ public PEMFileRSAPrivateKeySupplier(
9090
} else if (object instanceof SubjectPublicKeyInfo) {
9191
throw new IllegalArgumentException(
9292
"Public key provided instead of private key");
93+
} else if (object != null) {
94+
throw new IllegalArgumentException(
95+
"Private key must be in PEM format, was: " + object.getClass());
9396
} else {
9497
throw new IllegalArgumentException(
95-
"Private key must be in PEM format: " + object.getClass());
98+
"Private key must be in PEM format");
9699
}
97100

98101
this.key = (RSAPrivateKey) converter.getPrivateKey(keyInfo);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.oracle.bmc.http.signing.internal;
2+
3+
import org.junit.Test;
4+
5+
import java.io.ByteArrayInputStream;
6+
import java.io.InputStream;
7+
import java.io.IOException;
8+
import java.nio.file.Files;
9+
import java.nio.file.Path;
10+
11+
import static org.junit.Assert.fail;
12+
13+
/**
14+
* Tests for {@link PEMFileRSAPrivateKeySupplierTest}.
15+
*/
16+
public class PEMFileRSAPrivateKeySupplierTest {
17+
@Test(expected=IllegalArgumentException.class)
18+
public void ctor_invalidFile() throws IOException {
19+
InputStream notAPem = new ByteArrayInputStream(new byte[0]);
20+
// not a valid key file
21+
new PEMFileRSAPrivateKeySupplier(notAPem, null);
22+
fail("Should have thrown an IllegalArgumentException");
23+
}
24+
}

bmc-core/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.oracle.bmc.sdk</groupId>
77
<artifactId>oracle-bmc-java-sdk</artifactId>
8-
<version>1.2.12</version>
8+
<version>1.2.13</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

@@ -18,7 +18,7 @@
1818
<dependency>
1919
<groupId>com.oracle.bmc.sdk</groupId>
2020
<artifactId>oracle-bmc-java-sdk-common</artifactId>
21-
<version>1.2.12</version>
21+
<version>1.2.13</version>
2222
</dependency>
2323
</dependencies>
2424

bmc-examples/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.oracle.bmc.sdk</groupId>
77
<artifactId>oracle-bmc-java-sdk</artifactId>
8-
<version>1.2.12</version>
8+
<version>1.2.13</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

@@ -19,7 +19,7 @@
1919
<dependency>
2020
<groupId>com.oracle.bmc.sdk</groupId>
2121
<artifactId>oracle-bmc-java-sdk-bom</artifactId>
22-
<version>1.2.12</version>
22+
<version>1.2.13</version>
2323
<type>pom</type>
2424
<scope>import</scope>
2525
</dependency>

bmc-identity/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.oracle.bmc.sdk</groupId>
77
<artifactId>oracle-bmc-java-sdk</artifactId>
8-
<version>1.2.12</version>
8+
<version>1.2.13</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

@@ -18,7 +18,7 @@
1818
<dependency>
1919
<groupId>com.oracle.bmc.sdk</groupId>
2020
<artifactId>oracle-bmc-java-sdk-common</artifactId>
21-
<version>1.2.12</version>
21+
<version>1.2.13</version>
2222
</dependency>
2323
</dependencies>
2424

bmc-loadbalancer/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.oracle.bmc.sdk</groupId>
77
<artifactId>oracle-bmc-java-sdk</artifactId>
8-
<version>1.2.12</version>
8+
<version>1.2.13</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

@@ -18,7 +18,7 @@
1818
<dependency>
1919
<groupId>com.oracle.bmc.sdk</groupId>
2020
<artifactId>oracle-bmc-java-sdk-common</artifactId>
21-
<version>1.2.12</version>
21+
<version>1.2.13</version>
2222
</dependency>
2323
</dependencies>
2424

bmc-objectstorage/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.oracle.bmc.sdk</groupId>
77
<artifactId>oracle-bmc-java-sdk</artifactId>
8-
<version>1.2.12</version>
8+
<version>1.2.13</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

@@ -18,7 +18,7 @@
1818
<dependency>
1919
<groupId>com.oracle.bmc.sdk</groupId>
2020
<artifactId>oracle-bmc-java-sdk-common</artifactId>
21-
<version>1.2.12</version>
21+
<version>1.2.13</version>
2222
</dependency>
2323
</dependencies>
2424

bmc-objectstorage/src/main/java/com/oracle/bmc/objectstorage/transfer/UploadManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private UploadResponse multipartUpload(UploadRequest uploadDetails) {
113113

114114
final ExecutorService executorServiceToUse;
115115
final boolean shutdownExecutor;
116-
if (uploadConfiguration.isAllowParallelUploads() && chunkCreator.enableParallelReads()) {
116+
if (uploadConfiguration.isAllowParallelUploads() && chunkCreator.supportsParallelReads()) {
117117
if (uploadDetails.parallelUploadExecutorService != null) {
118118
executorServiceToUse = uploadDetails.parallelUploadExecutorService;
119119
shutdownExecutor = false;

bmc-objectstorage/src/main/java/com/oracle/bmc/objectstorage/transfer/internal/StreamChunkCreator.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@
33
*/
44
package com.oracle.bmc.objectstorage.transfer.internal;
55

6-
import java.io.IOException;
7-
import java.io.InputStream;
8-
96
import com.oracle.bmc.io.DuplicatableInputStream;
10-
117
import lombok.extern.slf4j.Slf4j;
128

9+
import java.io.IOException;
10+
import java.io.InputStream;
11+
1312
@Slf4j
1413
public class StreamChunkCreator {
1514
private final InputStream source;
1615
private final long chunkLength;
1716
private final long sourceLength;
1817

19-
private boolean canDuplicate = false;
2018
private long startPosition = 0;
2119
private long endPosition = 0;
2220

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

2927
/**
30-
* Attempt to enable parallel reads from the underlying stream. If this returns true,
28+
* Test for whether or not the input stream can be read in parallel. If this returns true,
3129
* then streams returned by {@link #next()} are safe to be read from in parallel. If this
3230
* returns false, then streams returned by {@link #next()} must be read from serially.
3331
*
3432
* @return true if parallel reads could be enabled, false if they could not.
3533
*/
36-
public boolean enableParallelReads() {
37-
if (source instanceof DuplicatableInputStream) {
38-
canDuplicate = true;
39-
}
40-
return canDuplicate;
34+
public boolean supportsParallelReads() {
35+
return isSrcStreamDuplicable();
36+
}
37+
38+
private boolean isSrcStreamDuplicable() {
39+
return source instanceof DuplicatableInputStream;
4140
}
4241

4342
/**
@@ -50,8 +49,8 @@ public boolean hasMore() {
5049

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

7271
SubRangeInputStream rangeInputStream = null;
7372

74-
if (canDuplicate) {
73+
// always use duplicated stream when possible, even if parallel reads not enabled
74+
if (isSrcStreamDuplicable()) {
7575
rangeInputStream =
7676
new DuplicatedSubRangeInputStream(
7777
(DuplicatableInputStream) source, startPosition, endPosition);

bmc-objectstorage/src/test/java/com/oracle/bmc/objectstorage/transfer/internal/StreamChunkCreatorTest.java

+33-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import static org.junit.Assert.*;
77

8+
import java.io.ByteArrayInputStream;
89
import java.io.IOException;
910
import java.io.InputStream;
1011
import java.util.ArrayList;
@@ -55,8 +56,12 @@ public void serialChunks_readInOrder() throws Exception {
5556

5657
@Test
5758
public void serialChunks_readOutOfOrder() throws Exception {
59+
// set up a non-duplicable stream instead
60+
stream = new ByteArrayInputStream(COMPLETE_STRING.getBytes());
61+
5862
StreamChunkCreator creator =
5963
new StreamChunkCreator(stream, COMPLETE_STRING.length(), CHUNK_SIZE);
64+
assertFalse(creator.supportsParallelReads());
6065

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

83+
@Test
84+
public void serialChunks_readOutOfOrder_duplicable() throws Exception {
85+
StreamChunkCreator creator =
86+
new StreamChunkCreator(stream, COMPLETE_STRING.length(), CHUNK_SIZE);
87+
assertTrue(creator.supportsParallelReads());
88+
89+
ArrayList<SubRangeInputStream> chunks = new ArrayList<>();
90+
while (creator.hasMore()) {
91+
SubRangeInputStream chunk = creator.next();
92+
chunks.add(chunk);
93+
}
94+
assertEquals(CHUNKS.length, chunks.size());
95+
96+
StringBuilder sb = new StringBuilder();
97+
StringBuilder sbExpected = new StringBuilder();
98+
for (int i = 0; i < CHUNKS.length; i++) {
99+
String content = toString(chunks.get(RANDOM_ORDER[i]));
100+
sb.append(content);
101+
sbExpected.append(CHUNKS[RANDOM_ORDER[i]]);
102+
}
103+
// when reading chunks out of order of a duplicable stream, the bytes will come back
104+
// in the order the chunks were read
105+
assertEquals(sbExpected.toString(), sb.toString());
106+
}
107+
78108
@Test
79109
public void parallelChunks_readInOrder() throws Exception {
80110
StreamChunkCreator creator =
81111
new StreamChunkCreator(stream, COMPLETE_STRING.length(), CHUNK_SIZE);
82-
assertTrue(creator.enableParallelReads());
112+
assertTrue(creator.supportsParallelReads());
83113

84114
int chunkCount = 0;
85115
while (creator.hasMore()) {
@@ -103,7 +133,7 @@ public void parallelChunks_readInOrder() throws Exception {
103133
public void parallelChunks_readOutOfOrder() throws Exception {
104134
StreamChunkCreator creator =
105135
new StreamChunkCreator(stream, COMPLETE_STRING.length(), CHUNK_SIZE);
106-
assertTrue(creator.enableParallelReads());
136+
assertTrue(creator.supportsParallelReads());
107137

108138
ArrayList<SubRangeInputStream> chunks = new ArrayList<>();
109139
while (creator.hasMore()) {

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.oracle.bmc.sdk</groupId>
66
<artifactId>oracle-bmc-java-sdk</artifactId>
7-
<version>1.2.12</version>
7+
<version>1.2.13</version>
88
<packaging>pom</packaging>
99

1010
<name>Oracle Bare Metal Cloud Services SDK</name>

0 commit comments

Comments
 (0)