src/main/java/org/embulk/input/gcs/GcsAuthentication.java in embulk-input-gcs-0.2.8 vs src/main/java/org/embulk/input/gcs/GcsAuthentication.java in embulk-input-gcs-0.3.0
- old
+ new
@@ -9,11 +9,10 @@
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.storage.Storage;
import com.google.api.services.storage.StorageScopes;
-import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import org.embulk.config.ConfigException;
import org.embulk.spi.Exec;
import org.embulk.spi.util.RetryExecutor.RetryGiveupException;
@@ -26,10 +25,11 @@
import java.io.IOException;
import java.io.InterruptedIOException;
import java.security.GeneralSecurityException;
import java.util.Collections;
+import java.util.Optional;
public class GcsAuthentication
{
private final Logger log = Exec.getLogger(GcsAuthentication.class);
private final Optional<String> serviceAccountEmail;
@@ -72,10 +72,10 @@
// @see https://developers.google.com/resources/api-libraries/documentation/storage/v1/java/latest/com/google/api/services/storage/STORAGE_SCOPE.html
// @see https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/java/latest/com/google/api/services/bigquery/BigqueryScopes.html
return new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
- .setServiceAccountId(serviceAccountEmail.orNull())
+ .setServiceAccountId(serviceAccountEmail.orElseGet(null))
.setServiceAccountScopes(
ImmutableList.of(
StorageScopes.DEVSTORAGE_READ_ONLY
)
)