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.
This commit is contained in:
Andrew Gaul 2013-12-16 20:28:24 -08:00
parent 16ea4fb33f
commit 9d2e4759a3
3 changed files with 11 additions and 5 deletions

View File

@ -44,8 +44,8 @@ public abstract class BaseCipherPayload extends DelegatingPayload {
public abstract Cipher initializeCipher(Key key); public abstract Cipher initializeCipher(Key key);
@Override @Override
public CipherInputStream openStream() { public CipherInputStream openStream() throws IOException {
return new CipherInputStream(super.getInput(), initializeCipher(key)); return new CipherInputStream(super.openStream(), initializeCipher(key));
} }
@Override @Override

View File

@ -22,6 +22,8 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import com.google.common.base.Throwables;
import org.jclouds.io.MutableContentMetadata; import org.jclouds.io.MutableContentMetadata;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
@ -50,7 +52,11 @@ public class DelegatingPayload implements Payload {
*/ */
@Override @Override
public InputStream getInput() { public InputStream getInput() {
return delegate.getInput(); try {
return openStream();
} catch (IOException ioe) {
throw Throwables.propagate(ioe);
}
} }
/** /**

View File

@ -74,8 +74,8 @@ public class MultipartFormTest {
} }
@Override @Override
public InputStream getInput() { public InputStream openStream() throws IOException {
return realPayload.getInput(); return realPayload.openStream();
} }
@Override @Override