Commit Graph

1484 Commits

Author SHA1 Message Date
Andrew Gaul ac22383648 Remove ByteArrayPayload
Callers should use ByteSourcePayload instead.
2014-09-07 07:43:14 -07:00
Andrew Gaul bd5b6853ee Replace uses of ByteArrayPayload
Prefer ByteSourcePayload which offers a superset of its functionality.
Note that ByteArrayPayload implicitly set the contentLength while
users of ByteSourcePayload must do so explicitly.
2014-09-07 07:43:14 -07:00
Andrew Gaul a4bc36dafa Add PayloadEnclosing.setPayload(ByteSource) 2014-09-06 22:27:22 -07:00
Andrew Gaul e1a5c521c5 Improve XML compatibility with trace-level logging
Some providers, notably Azure, include a byte-order mark in their XML
responses.  ParseSax.apply buffers these responses in a String when
users enable trace-level logging to include the response in any thrown
exceptions.  InputSource(InputStream) skips these byte-order marks
while InputSource(Reader) does not, yielding a SAXParseException.
2014-09-05 17:53:50 -07:00
Andrew Gaul 58438d7d1e Address Checkstyle violations 2014-09-04 17:24:27 -07:00
Andrew Gaul 0b89b1fd10 Ensure that Content-MD5 has 128 bits
Update many tests Content-MD5 headers and ETag responses.
2014-09-04 16:57:48 -07:00
Andrew Gaul 8613967820 Remove ByteStreams2.asByteSource
This method is dangerous since all ByteSource should provide a new
InputStream on every call to openStream while the method returns the
same InputStream for non-repeatable Payloads.
2014-09-04 16:55:55 -07:00
Andrew Gaul 34cfdbe266 Enforce Override annotation via Checkstyle
Also remove bogus inheritDoc on base and static methods.
2014-08-31 19:37:50 -07:00
Andrew Gaul 5399cb6877 Avoid unnecessary boxing
Found with FindBugs.
2014-08-30 14:30:47 -07:00
Andrew Gaul 1b824afbfc Remove redundant modifiers from interfaces 2014-08-26 17:34:13 -07:00
Andrew Gaul 74fb8f0183 Add whitespace after semicolons
Also correct some bad line-wrapping.
2014-08-26 11:06:00 -07:00
Andrew Gaul 614f5194ef JCLOUDS-653: Upgrade to Guava 18.0
Release notes:

https://code.google.com/p/guava-libraries/wiki/Release18
2014-08-25 17:47:23 -07:00
Jeremy Daggett e711275fb1 Prefer isEmpty() for collections rather than size() 2014-08-20 11:07:48 -07:00
Jeremy Daggett 744cd5d7eb Prefer Regions to Zones in OpenStack APIs 2014-08-13 09:58:53 -07:00
Andrew Gaul 9009bb5268 JCLOUDS-658: use xattr only on supported systems
Mac OS X HFS+ does not support UserDefinedFileAttributeView:

https://bugs.openjdk.java.net/browse/JDK-8030048
2014-08-12 12:30:06 -07:00
Andrew Gaul f236e046e3 Merge identical tests 2014-08-11 12:45:28 -07:00
Andrew Gaul a10bf3e9c5 Remove Java 6 litter 2014-08-11 12:45:27 -07:00
Andrew Phillips a6412ad66b Addressing Checkstyle violation
Introduced in 7e4cacf
2014-08-09 09:12:43 -04:00
Andrew Gaul 7e4cacf9ea JCLOUDS-264: Allow payloads greater than 2 GB
Enabled by JDK 7.
2014-08-09 00:28:49 -07:00
Andrew Gaul 80a0256cc7 JCLOUDS-622: Remove last vestiges of InputSupplier
Guava 16 deprecated InputSupplier and a future release will remove it.
2014-08-08 15:40:33 -07:00
Andrew Gaul b219208d6c JCLOUDS-653: correct mock expectation 2014-08-08 15:21:58 -07:00
Andrew Gaul 95cfc0d950 JCLOUDS-653: Address Guava 18 deprecations
Mostly renaming Objects.toStringHelper to MoreObjects.toStringHelper.
2014-08-08 11:12:21 -07:00
Andrew Gaul f26431b3e7 JCLOUDS-653: Upgrade to Guava 18.0-rc1
Release notes:

https://code.google.com/p/guava-libraries/wiki/Release18
2014-08-08 11:08:09 -07:00
Andrew Gaul 59462747e7 Reset StringBuilder instead of creating new ones
This avoids unneeded garbage, especially during XML parsing.  Replaced
with:

find -name \*.java | xargs sed -i 's/^\( *[^ ]*\) = new StringBuilder();$/\1.setLength(0);/'
2014-08-06 11:22:49 -07:00
Andrew Gaul 9e9acf1f3e Address Checkstyle violations 2014-08-05 17:13:29 -07:00
Andrew Phillips e3d9851216 Up to 2.0.0-SNAPSHOT after the 1.8.0 release 2014-08-05 09:10:24 +02:00
Zack Shoylev 231a60675e Adds support for ImmutableMap in jclouds gson 2014-07-29 12:36:53 -05:00
Andrew Phillips eba727fef7 'iso8601DateParseWithOptionalTZ' -> 'iso8601DateOrSecondsDateParse' in DateService
Follow-up to d57bbebe
2014-07-28 12:20:49 -04:00
Shri Javadekar d57bbebe7e Try iso8601SecondsDateParse if iso8601DateParse fails.
S3 compatible blobStores sometimes return date in the format:
"2014-07-23T20:53:17+0000" instead of the more common
"2014-07-23T18:09:39.944Z". This caused jclouds to barf with an
IllegalArgumentException.

This commit tries to parse both the formats for S3. The exception
is thrown if both fail.

Added unit tests for the same.
2014-07-26 22:19:54 -07:00
Andrew Gaul 5c8bdcdfbb Remove ByteSources.asByteSource
This method breaks the contract of ByteSource which specifies that
openStream can produce multiple independent streams.
2014-07-24 13:02:13 -07:00
Andrew Gaul f17c876d8d Replace const.txt file input with synthetic inputs
This commit replaces file resource-based test inputs with in-memory
equivalents.  This is more consistent and efficient than the previous
approach.  Also resized some test inputs to be partSize + 1 instead of
2 * partSize.  Tested against aws-s3, blobstore, core, cloudfiles-us,
and filesystem.
2014-07-19 18:35:25 -07:00
Andrew Gaul 0df905a870 JCLOUDS-622: add Strings2.toString(InputSupplier)
We did not deprecate this in 1.7.x as previously thought.
2014-07-18 21:48:08 -07:00
Aled Sage 1fb286809e JCLOUDS-549: Fix NPE in LoginCredentials.toString
- also deprecates LoginCredentails.get(Password|PrivateKey)
- use getOptionalPassword and getOptionalPrivateKey instead
2014-07-18 14:09:18 +01:00
Andrew Gaul fb60d76704 JCLOUDS-622: Remove most vestiges of InputSupplier
Guava 16 deprecated InputSupplier and a future release will remove it.
2014-07-16 16:07:59 -07:00
Andrew Gaul a8b106c2bb JCLOUDS-622: remove calls to InputSupplier methods
Guava 16 deprecated these methods and Guava 18 will remove them.
2014-07-15 03:09:58 -07:00
Andrew Gaul bdb5cbcbe7 Improve use of ByteSource with test resources
This commit ensures proper resource cleanup, simplifies
initialization, and paves the way for purely synthetic inputs in a
subsequent commit.
2014-07-11 09:10:51 -07:00
Andrew Gaul de68449cde JCLOUDS-622: Deprecate Strings2.toString
Guava 16 deprecated InputSupplier.
2014-07-10 23:32:41 -07:00
Andrew Gaul 1d218b1705 JCLOUDS-417: Test closing a stream w/o reading it 2014-07-10 20:59:10 -07:00
Tom Manville afc0ca557d JCLOUDS-417: Remove ConsumeOnCloseInputStream
ConsumeOnCloseInputStream can potentially perform a copy in finalize()
if the stream was not closed properly.
2014-07-10 20:59:09 -07:00
Andrew Gaul 66dab8d96e JCLOUDS-410: Remove InputStreamSupplierPayload
ByteSourcePayload replaces this.  jclouds 1.7 deprecated
InputStreamSupplierPayload and Guava 16 deprecated InputSupplier
itself.
2014-07-10 20:43:08 -07:00
Andrew Gaul 66307d9816 Use consistent stage for the two-stage injection 2014-07-07 23:36:53 -07:00
Andrew Gaul 3fdb6d2e91 Avoid extra copy with Splitter result 2014-07-07 23:36:22 -07:00
Christopher Dancy 3659a5f583 JCLOUDS-607: ComputeService.createNodesInGroup throws NPE on FloatingIPApi.create() 2014-07-07 19:46:54 -04:00
Andrew Gaul f5244884a5 Avoid impossible UnsupportedEncodingException 2014-07-02 17:30:09 -07:00
Andrew Gaul d43c3ea3e0 Handle short reads in BasePayloadSlicer
InputStream.read(byte[]) can return fewer bytes than requested.
Specifically ByteSource.concat(ByteSource...).openStream() will only
return as many bytes as the current ByteSource contains.  Thus
ByteSources.repeatingArrayByteSource(byte[]).openStream() will return
short reads despite the byte[] input from its single logical
InputStream.
2014-07-02 15:13:20 -07:00
Ignasi Barrera b9029ea7a6 JCLOUDS-617: Use the configured JCE provider in the Cipher payloads 2014-07-02 00:27:08 +02:00
Andrew Gaul 77eff6fffb Close InputStream after use
Found with Kohsuke's file-leak-detector.
2014-06-30 18:26:55 -07:00
Andrew Gaul 8fa209b15e Use more specific testng asserts where possible
These asserts yield more informative error messages.  Found with:

grep -rI 'assertTrue(.* =='
grep -rI 'assertTrue(.* !='
grep -rI 'assertTrue(.*\.equals('
2014-06-24 13:54:01 -07:00
Andrew Gaul 5b5e713cba Avoid unnecessary object creation
Prefer StringBuffer.append(string, index1, index2) over
StringBuffer.append(String.substring(index1, index2).
2014-06-24 13:15:18 -07:00
Andrew Gaul e799a7409c JCLOUDS-597: HashCode methods for Content-MD5
This works more naturally with Guava Hashing methods and immutability
provides better safety guarantees.  Also deprecate existing byte[]
methods.
2014-06-12 15:29:17 -07:00
Jeremy Daggett 446671a2a7 Improve readability of expect test output 2014-06-11 15:35:45 -05:00
Andrew Gaul 9cdd53b0b7 JCLOUDS-546: Remove Javadoc @author annotations
Annotations removed with:

find -name \*.java | xargs sed -i /@author/d

Empty Javadoc removed with multiple iterations of:

find -name \*.java | xargs sed -i -z 's/ \*\n \*\// \*\//'
find -name \*.java | xargs sed -i -z 's/ \* \n \*\// \*\//'
find -name \*.java | xargs sed -i -z 's/\/\*\*\n \*\/\n//'
2014-06-07 21:44:54 -07:00
Andrew Gaul 2342abd3c5 Address Checkstyle violations 2014-05-30 11:10:14 -07:00
Andrew Gaul 186f052022 Remove BlobBuilder and Payloads.calculateMD5
Callers should instead explicitly set contentMD5, usually with the
results from Guava Hashing.md5(). This narrows the API and removes a
strange IOException from callers.  Further it removes a dangerous
rebuffering of arbitrarily-large non-repeatable Payloads.
2014-05-28 12:54:18 -07:00
Andrew Gaul bae4377dca Prefer File.delete over File.deleteOnExit
The former has deterministic behavior and avoids resource leaks.
2014-05-23 16:17:10 -07:00
Andrew Gaul 26b53e52b7 Use ByteSource methods to create test input
Also avoids excessive system calls due to unbuffered writes.  Finally
migrate repeatingArrayByteSource to ByteSources.
2014-05-22 10:43:57 -07:00
Andrew Gaul 4c265d3168 Prefer Guava Hashing over MessageDigest 2014-05-22 09:40:06 -07:00
Andrew Gaul 644fbf2052 Prefer ByteStreams over ByteArrayOutputStream 2014-05-22 00:40:21 -07:00
Andrew Gaul 11b778bbb9 Add missing @Override annotations 2014-05-20 21:23:30 -07:00
Andrew Gaul 1f1f4f0a49 Override hashCode when equals overridden
Java 8 added a warning for this:

https://bugs.openjdk.java.net/browse/JDK-6563143
2014-05-20 21:22:43 -07:00
Andrew Gaul 62a6842748 Address CheckStyle violations 2014-05-17 00:49:40 -07:00
Andrew Gaul baddf8fe80 Replace InputSupplierMap with Map<K, ByteSource>
A future version of Guava will remove InputSupplier.
2014-05-16 18:10:52 -07:00
Andrew Gaul d9d8d421cb Migrate InputSupplier callers to ByteSource
A future version of Guava will remove InputSupplier.
2014-05-16 18:08:19 -07:00
Andrew Gaul 70cf3e1f7c Make constants final classes instead of interfaces
This commit prohibits implementation of the empty interface and
instantiation of the class.  Refer to _Effective Java_ item 19 for
more background.
2014-05-16 09:45:52 -07:00
Andrew Gaul 8d51ad6f87 Prefer Guava HttpHeaders over JAX-RS
jclouds code contains more instances of the former and Guava has
additional constants like CONTENT_MD5.
2014-05-15 01:55:51 -07:00
Andrew Gaul 67c2b5f6b9 Enable whitespace around Checkstyle rule 2014-05-08 18:31:47 -07:00
Andrew Gaul 2d88f5164e Enforce that all commas have trailing whitespace 2014-05-08 18:28:08 -07:00
Andrew Gaul 3f22f6738d JCLOUDS-534: Upgrade to Guava 17.0
Release notes:

https://code.google.com/p/guava-libraries/wiki/Release17
2014-05-06 17:23:37 -07:00
Andrew Gaul 82e9e9e42f JCLOUDS-534: Upgrade to Guava 17.0-rc2
This commit accommodates changes to Predicates.and.toString and
PublicSuffixPatterns.EXACT.  Release notes:

https://code.google.com/p/guava-libraries/wiki/Release17
2014-04-14 18:38:15 -07:00
Andrew Gaul d0bd30cc15 Address several Guava InputSupplier deprecations
Many remain due to Payload implementing InputSupplier<InputStream>.  Guava 18
will remove InputSupplier.
2014-04-12 12:02:26 -07:00
Andrew Gaul 7af18d4843 JCLOUDS-534: Address Guava 17 compatibility issues
Corrected with:

find -name \*.java | xargs sed -i 's/new Stopwatch();/Stopwatch.createUnstarted();/'
find -name \*.java | xargs sed -i 's/new Stopwatch().start();/Stopwatch.createStarted();/'
2014-04-11 14:24:12 -07:00
Pasi Niemi 85a1a8c1dd JCLOUDS-516: Add ssh agent support via sch agentproxy 2014-03-27 09:04:34 +01:00
Shri Javadekar 655aa444d7 JCLOUDS-510 Delete objects in a container efficiently.
The existing approach for deleting objects in a container suffers
from a head-of-line blocking problem. This commit implements a better
scheme which does not have that problem. This scheme uses a counting
semaphore for making sure that a certain number of futures are
issued in parallel. As each of these futures is completed, one
permit of the semaphore is released.

Added unit tests for testing this new scheme.
2014-03-26 13:48:28 -07:00
Andrew Gaul 00847f9ffc JCLOUDS-460: Add jitter to avoid thundering herd
When issuing many simultaneous requests to Synaptic Atmos I observed:

HTTP/1.1 failed with code 500, error: AtmosError
[code=1040, message=The server is busy. Please try again.]

Previously all clients slept for fixed intervals and thus retried
around the same time.  This commit adds a random delay which should
better distribute load on the provider.
2014-03-03 22:30:22 -08:00
Andrew Gaul d7e0b3b10c Remove WriteTo
Guava helpers capture this functionality in a more idiomatic way.
2014-02-21 17:13:31 -08:00
Andrew Gaul 9a1aae8cfc JCLOUDS-410: Remove StreamingPayload
Only two tests use this class.  Callers should use ByteSourcePayload
or InputStreamPayload instead.
2014-02-19 21:27:31 -08:00
Andrew Gaul c035bcd6b2 JCLOUDS-459: Limit maximum user threads
Previously jclouds could use an unlimited number of threads on its
user ExecutorService.  While this ExecutorService will go away when we
complete deasyncafication, we should prevent jclouds from misbehaving
until that time.
2014-02-19 10:04:50 -08:00
Andrew Gaul 266d7f847b Prefer ByteSource over deprecated InputSupplier 2014-02-18 22:35:10 -08:00
Andrew Gaul 1f08b692cd JCLOUDS-473: Close FileInputStream in Wire.copy
FileBackedOutputStream.asByteSource.getInput returns a FileInputStream
which we do not close.  We later call FileBackedOutputStream.reset
which removes the underlying File.  This fails on Windows which does
not support deleting an open file and leaks resources on other
platforms.  Eagerly close to address this issue.
2014-02-18 16:42:40 -08:00
Andrew Phillips 4c07702d29 JCLOUDS-432: Revert "JCLOUDS-427: Avoiding Guava reflection code broken in Java 7u51"
This reverts commit 8ff60020f8.
2014-02-10 10:01:02 -05:00
Andrew Phillips 02615adc4f JCLOUDS-427: Upgrading Guava 16.0 -> 16.0.1
Fixes Guava issue 1635.
2014-02-10 10:01:01 -05:00
Zack Shoylev 30a29cc73e Adds a top-level zone filter. New live tests iterate over all available zones to ensure jclouds is fully compatible. Sometimes we want to filter to specific zones on demand. 2014-02-07 10:37:49 -06:00
Andrew Gaul 241abea734 Store propagatable exceptions in a static field
Also include ResourceAlreadyExistsException.  References JCLOUDS-438.
2014-01-29 10:30:18 -08:00
Andrew Gaul 0098751f42 JCLOUDS-438: Map S3 code BucketAlreadyExists
Mapping to ResourceAlreadyExistsException allows external callers to
handle this situation specifically.
2014-01-28 21:21:46 -08:00
Andrew Phillips ea5128209a JCLOUDS-415: Upgrading Guava 15.0 -> 16.0 2014-01-28 07:57:35 -05:00
Andrew Phillips d77f96bed7 JCLOUDS-415: Preparing for Guava 16.0
Invokable.equals has changed from 15 to 16 so we need to implement the check differently ourselves.
2014-01-28 07:57:34 -05:00
Andrew Phillips 8ff60020f8 JCLOUDS-427: Avoiding Guava reflection code broken in Java 7u51
- Adding a version of TypeToken.where that replaces two parameters in one go
- Avoiding TypeToken type parameter replacement with wildcard bounds

Works around https://code.google.com/p/guava-libraries/issues/detail?id=1635
2014-01-23 23:28:00 -05:00
Andrew Phillips b59457a405 Fixing an error message about an unassignable backend 2014-01-23 09:09:47 -05:00
Andrew Gaul 9416416ff4 Address Checkstyle violations 2014-01-19 20:51:51 -08:00
Andrew Gaul d5fd82500c JCLOUDS-428: Address Java 8 compatibility nits
Tested with JDK 1.6.0_45, 1.7.0_45, and 1.8.0-ea-b123.
2014-01-19 20:37:45 -08:00
Ignasi Barrera 09a430744a Added OkHttp driver to support modern HTTP verbs 2014-01-13 10:47:39 +01:00
Andrew Gaul 3143e43a27 Remove erroneous deprecation of ByteSource method 2013-12-26 08:24:04 -08:00
Andrew Gaul c7b0f66544 Replace calls to Closeables.closeQuietly
Guava 16 removes this API.  Replace with Closeables2.closeQuietly.
References JCLOUDS-413 and JCLOUDS-415.
2013-12-21 12:30:59 -08:00
Andrew Gaul f9e98681b6 Address miscellaneous Guava deprecations
References JCLOUDS-415.
2013-12-20 14:05:44 -08:00
Andrew Bayer c1ee11d9bd Updating to 1.8.0-SNAPSHOT 2013-12-17 11:31:56 -08:00
Andrew Gaul 9d2e4759a3 JCLOUDS-410. Correctly override getInput
Payload.getInput must always call openStream to handle overridden
methods correctly.  Previously this caused errors in jclouds-chef in
BaseCipherPayload.
2013-12-17 08:02:03 -08:00
Andrew Gaul e48d4985ea JCLOUDS-410. Add support for ByteSource Payloads
Also deprecate byte[], File, InputSupplier<InputStream>, and String
Payloads.  Callers should instead provide a ByteSource via
ByteSource.wrap(byte[]) and Files.asByteSource(File)
2013-12-16 13:06:30 -08:00
Andrew Gaul f3dcd3fe86 JCLOUDS-410. Deprecate Payload.getInput
We plan to transition Payload to ByteSource in the next major release.
Unfortunately Payload.getInput masks its checked exception and
ByteSource.getInput is final so we cannot continue to mask the
exceptions.  Deprecation of getInput and addition openStream allows us
to transition callers from the former to the latter.
2013-12-16 13:02:37 -08:00
Andrew Gaul ac1f05ffac Remove unneeded calls to ByteSources.asByteSource 2013-12-15 22:57:32 -08:00
Andrew Gaul 8bf23069d9 Prefer Math.max over Ints.max to avoid varargs 2013-12-12 17:53:34 -08:00