From 2c4e6c166d09c51e3f37a49f453b11b0f5a56465 Mon Sep 17 00:00:00 2001 From: BenWhitehead Date: Wed, 6 Oct 2021 20:55:48 -0400 Subject: [PATCH] test(retry): fix 48 and 114 (#1084) com.google.cloud.storage.Storage.create(com.google.cloud.storage.BlobInfo, java.io.InputStream, com.google.cloud.storage.Storage.BlobWriteOption...) is never safe to retry as it does not wrap the inputstream provided to allow it to be safely read multiple times Fixes #1083 --- .../conformance/retry/RpcMethodMappings.java | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RpcMethodMappings.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RpcMethodMappings.java index 82a5437db..4e443867a 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RpcMethodMappings.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/conformance/retry/RpcMethodMappings.java @@ -1477,19 +1477,18 @@ private static void insert(ArrayList a) { .build()); a.add( RpcMethodMapping.newBuilder(48, objects.insert) - .withApplicable(TestRetryConformance::isPreconditionsProvided) + .withApplicable(not(TestRetryConformance::isPreconditionsProvided)) + .withSetup(defaultSetup.andThen(blobInfoWithGenerationZero)) .withTest( - blobInfoWithGenerationZero.andThen( - (ctx, c) -> - ctx.map( - state -> - state.with( - ctx.getStorage() - .create( - ctx.getState().getBlobInfo(), - new ByteArrayInputStream( - c.getHelloWorldUtf8Bytes()), - BlobWriteOption.generationMatch()))))) + (ctx, c) -> + ctx.map( + state -> + state.with( + ctx.getStorage() + .create( + ctx.getState().getBlobInfo(), + new ByteArrayInputStream(c.getHelloWorldUtf8Bytes()), + BlobWriteOption.generationMatch())))) .build()); a.add( RpcMethodMapping.newBuilder(49, objects.insert) @@ -1717,17 +1716,16 @@ private static void insert(ArrayList a) { a.add( RpcMethodMapping.newBuilder(114, objects.insert) .withApplicable(not(TestRetryConformance::isPreconditionsProvided)) + .withSetup(defaultSetup.andThen(blobInfoWithoutGeneration)) .withTest( - blobInfoWithoutGeneration.andThen( - (ctx, c) -> - ctx.map( - state -> - state.with( - ctx.getStorage() - .create( - ctx.getState().getBlobInfo(), - new ByteArrayInputStream( - c.getHelloWorldUtf8Bytes())))))) + (ctx, c) -> + ctx.map( + state -> + state.with( + ctx.getStorage() + .create( + ctx.getState().getBlobInfo(), + new ByteArrayInputStream(c.getHelloWorldUtf8Bytes()))))) .build()); a.add( RpcMethodMapping.newBuilder(115, objects.insert)