diff --git a/hadoop-crypto/src/main/java/com/palantir/hadoop2/cipher/FsCipherOutputStream.java b/hadoop-crypto/src/main/java/com/palantir/hadoop2/cipher/FsCipherOutputStream.java index 9351e35c3..3d903460e 100644 --- a/hadoop-crypto/src/main/java/com/palantir/hadoop2/cipher/FsCipherOutputStream.java +++ b/hadoop-crypto/src/main/java/com/palantir/hadoop2/cipher/FsCipherOutputStream.java @@ -21,6 +21,7 @@ import com.palantir.crypto2.cipher.CipherStreamSupplierImpl; import com.palantir.crypto2.cipher.SeekableCipher; import java.io.FilterOutputStream; +import java.io.IOException; import javax.crypto.Cipher; import org.apache.hadoop.fs.FSDataOutputStream; @@ -39,4 +40,14 @@ public FsCipherOutputStream(FSDataOutputStream delegate, SeekableCipher cipher) super(supplier.getOutputStream(delegate, cipher.initCipher(Cipher.ENCRYPT_MODE))); } + @Override + public void write(byte[] bytes, int off, int len) throws IOException { + out.write(bytes, off, len); + } + + @Override + public void write(byte[] bytes) throws IOException { + out.write(bytes); + } + } diff --git a/hadoop-crypto/src/test/java/com/palantir/hadoop2/cipher/FsCipherOutputStreamTest.java b/hadoop-crypto/src/test/java/com/palantir/hadoop2/cipher/FsCipherOutputStreamTest.java index c0a6b1f10..73ab1e8ba 100644 --- a/hadoop-crypto/src/test/java/com/palantir/hadoop2/cipher/FsCipherOutputStreamTest.java +++ b/hadoop-crypto/src/test/java/com/palantir/hadoop2/cipher/FsCipherOutputStreamTest.java @@ -24,6 +24,7 @@ import com.palantir.crypto2.cipher.CipherStreamSupplier; import com.palantir.crypto2.cipher.SeekableCipher; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; @@ -37,6 +38,8 @@ public final class FsCipherOutputStreamTest { + private static final byte[] bytes = "bytes".getBytes(StandardCharsets.UTF_8); + private FSDataOutputStream os; private Cipher initCipher; private SeekableCipher seekableCipher; @@ -72,4 +75,16 @@ public void testWrite() throws IOException { verify(cos).write(0); } + @Test + public void testWrite_callsWriteWithLength() throws IOException { + scos.write(bytes, 0, bytes.length); + verify(cos).write(bytes, 0, bytes.length); + } + + @Test + public void testWrite_callsBatchWrite() throws IOException { + scos.write(bytes); + verify(cos).write(bytes); + } + }