mirror of https://github.com/apache/jclouds.git
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:
parent
16ea4fb33f
commit
9d2e4759a3
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue