Source:
private String startResumableUpload() throws IOException { InsertObjectSpec.Builder insertObjectSpecBuilder = InsertObjectSpec.newBuilder() .setResource( Object.newBuilder() .setBucket(resourceId.getBucketName()) .setName(resourceId.getObjectName()) .setContentType(createOptions.getContentType()) .putAllMetadata(encodeMetadata(createOptions.getMetadata())) .build()); if (writeConditions.hasContentGenerationMatch()) { insertObjectSpecBuilder.setIfGenerationMatch( Int64Value.newBuilder().setValue(writeConditions.getContentGenerationMatch())); } if (writeConditions.hasMetaGenerationMatch()) { insertObjectSpecBuilder.setIfMetagenerationMatch( Int64Value.newBuilder().setValue(writeConditions.getMetaGenerationMatch())); } if (requesterPaysProject != null) { insertObjectSpecBuilder.setUserProject(requesterPaysProject); } StartResumableWriteRequest request = StartResumableWriteRequest.newBuilder() .setInsertObjectSpec(insertObjectSpecBuilder) .build(); SimpleResponseObserver<StartResumableWriteResponse> responseObserver = new SimpleResponseObserver<>(); Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder() .retryIfExceptionOfType(IOException.class) .retryIfRuntimeException() .withWaitStrategy(WaitStrategies.exponentialWait(2, 20_000, MILLISECONDS)) .withStopStrategy(StopStrategies.stopAfterAttempt(UPLOAD_RETRIES)) .build(); try { retryer.call( () -> { stub.withDeadlineAfter(START_RESUMABLE_WRITE_TIMEOUT.toMillis(), MILLISECONDS) .startResumableWrite(request, responseObserver); try { responseObserver.done.await(); if (responseObserver.hasError()) { throw new IOException(responseObserver.getError()); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } return null; }); } catch (Exception e) { throw new IOException( String.format("Failed to start resumable upload for '%s'", getResourceString()), e); } return responseObserver.getResponse().getUploadId(); }

Target:
private String startResumableUpload() throws IOException { InsertObjectSpec.Builder insertObjectSpecBuilder = InsertObjectSpec.newBuilder() .setResource( Object.newBuilder() .setBucket(resourceId.getBucketName()) .setName(resourceId.getObjectName()) .setContentType(createOptions.getContentType()) .putAllMetadata(encodeMetadata(createOptions.getMetadata())) .build()); if (writeConditions.hasContentGenerationMatch()) { insertObjectSpecBuilder.setIfGenerationMatch( Int64Value.newBuilder().setValue(writeConditions.getContentGenerationMatch())); } if (writeConditions.hasMetaGenerationMatch()) { insertObjectSpecBuilder.setIfMetagenerationMatch( Int64Value.newBuilder().setValue(writeConditions.getMetaGenerationMatch())); } if (requesterPaysProject != null) { insertObjectSpecBuilder.setUserProject(requesterPaysProject); } StartResumableWriteRequest request = StartResumableWriteRequest.newBuilder() .setInsertObjectSpec(insertObjectSpecBuilder) .build(); SimpleResponseObserver<StartResumableWriteResponse> responseObserver = new SimpleResponseObserver<>(); Retryer retryer = getRetryer(); try { retryer.call( () -> { stub.withDeadlineAfter(START_RESUMABLE_WRITE_TIMEOUT.toMillis(), MILLISECONDS) .startResumableWrite(request, responseObserver); responseObserver.done.await(); if (responseObserver.hasError()) { throw new IOException(responseObserver.getError()); } return null; }); } catch (Exception e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } throw new IOException( String.format("Failed to start resumable upload for '%s'", getResourceString()), e); } return responseObserver.getResponse().getUploadId(); }