> + @Inject
> + @Named(JoyentConstants.JOYENT_CERT_CLASSPATH)
> + private String certClasspath_;
> +
> +
> + @Inject
> + public JoyentBlobRequestSigner(@org.jclouds.location.Provider
> + Supplier<Credentials> creds) {
> + identity = creds.get().identity;
> + }
> +
> + @Override
> + public HttpRequest filter(HttpRequest request) throws HttpException {
> + LOG.debug("signing request: " + request.getHeaders());
> +
> + if (keyPair_ == null) {
Ok, I think I get now why you use the volatile variable and this synchronized
stuff. Are you trying to minimize the cost of loading the KeyPair and trying to
load it only the first time the filter is invoked? If that is the case, I'd
recommend one of the following two approaches:
* Move the load KeyPair logic to the constructor (you have all you need there).
This way you'll have the KeyPair already loaded and you won't have to deal with
synchronization.
* If you prefer to defer the KeyPair loading until the filter is invoked, you'd
better inject a `Supplier<KeyPair>`, and use it to load the keyPair. You can
configure it in Guice to be synchronized and memoized, so it is thread safe and
it is only loaded once. (See [Guava
Suppliers](http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/Suppliers.html)
utility class. Something like:
`Suppliers.memoize(Suppliers.synchronized(your-supplier-to-load-the-keypair))`.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/188/files#r7140714