Skip to content

Commit 57407e8

Browse files
committed
Port #392 to 3.1.x
1 parent dc2ad35 commit 57407e8

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project aims to adhere to [Semantic Versioning](http://semver.org/).
44

5+
## [3.1.8] - 2017-01-11
6+
- [Underlying stream is not closed when we throw a `MantaClientEncryptionException`](https://github.com/joyent/java-manta/issues/391)
7+
- [Underlying stream is not closed by `MantaEncryptedObjectInputStream` for range requests with certain ciphers](https://github.com/joyent/java-manta/issues/398)
8+
- [MantaDirectoryListingIterator is not closed in MantaClient#listObjects when directory is empty](https://github.com/joyent/java-manta/issues/400)
9+
510
## [3.1.7] - 2017-11-29
611
### Added
712
- [Recursive directory creation](https://github.com/joyent/java-manta/issues/371)

java-manta-client/src/main/java/com/joyent/manta/http/EncryptionHttpHelper.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@
4848
import org.slf4j.Logger;
4949
import org.slf4j.LoggerFactory;
5050

51-
import javax.crypto.BadPaddingException;
52-
import javax.crypto.Cipher;
53-
import javax.crypto.IllegalBlockSizeException;
54-
import javax.crypto.SecretKey;
5551
import java.io.IOException;
5652
import java.io.UncheckedIOException;
5753
import java.nio.charset.StandardCharsets;
@@ -66,6 +62,10 @@
6662
import java.util.List;
6763
import java.util.Map;
6864
import java.util.function.Supplier;
65+
import javax.crypto.BadPaddingException;
66+
import javax.crypto.Cipher;
67+
import javax.crypto.IllegalBlockSizeException;
68+
import javax.crypto.SecretKey;
6969

7070
/**
7171
* {@link HttpHelper} implementation that transparently handles client-side
@@ -291,9 +291,19 @@ public MantaObjectInputStream httpRequestAsInputStream(final HttpUriRequest requ
291291
+ "client-side encryption is enabled unless the "
292292
+ "permit unencrypted downloads configuration setting "
293293
+ "is enabled";
294-
MantaClientEncryptionException e = new MantaClientEncryptionException(msg);
295-
HttpHelper.annotateContextedException(e, request, response);
296-
throw e;
294+
MantaClientEncryptionException mcee = new MantaClientEncryptionException(msg);
295+
HttpHelper.annotateContextedException(mcee, request, response);
296+
297+
try {
298+
rawStream.close();
299+
} catch (IOException ioe) {
300+
MantaIOException mioe = new MantaIOException(ioe);
301+
HttpHelper.annotateContextedException(mioe, request, response);
302+
LOGGER.warn("Error closing underlying stream", mioe);
303+
}
304+
305+
throw mcee;
306+
297307
}
298308
}
299309

0 commit comments

Comments
 (0)