8000 Storage - SocketException Socket closed (gcloud java 0.28) · Issue #1227 · googleapis/google-cloud-java · GitHub
[go: up one dir, main page]

Skip to content

Storage - SocketException Socket closed (gcloud java 0.28) #1227

@fondberg

Description

@fondberg

We still see StorageException caused by SocketExceptions even if they should have been retried.

java.net.SocketException: Socket is closed
    at sun.security.ssl.SSLSocketImpl.getInputStream
    at sun.net.www.http.HttpClient.parseHTTP
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream
    at java.net.HttpURLConnection.getResponseCode
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode
    at com.google.api.client.http.javanet.NetHttpResponse.<init>
    at com.google.api.client.http.javanet.NetHttpRequest.execute
    at com.google.api.client.http.HttpRequest.execute
    at com.google.cloud.storage.spi.DefaultStorageRpc.open
    at com.google.cloud.storage.BlobWriteChannel.<init>
    at com.google.cloud.storage.StorageImpl.writer
    at com.google.cloud.storage.StorageImpl.writer
    at com.google.cloud.storage.StorageImpl.writer
    at com.spotify.buildartifactarchiver.storage.GcsUploaderClient.storeInputStream
    at com.spotify.buildartifactarchiver.storage.ArtifactUploader.uploadZipArchive
    at com.spotify.buildartifactarchiver.storage.ArtifactUploader.upload
    at com.spotify.buildartifactarchiver.ArtifactArchiver.archiveArtifactsForBuild
    at com.spotify.buildartifactarchiver.ArtifactArchiver.archiveBuild
    at com.spotify.buildartifactarchiver.web.ArtifactArchiverPubSubResource.messageHandler
    at com.spotify.google.cloud.pubsub.client.Puller.lambda$pullBatch$11
    at java.util.concurrent.CompletableFuture.uniWhenComplete
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire
    at java.util.concurrent.CompletableFuture.postComplete
    at java.util.concurrent.CompletableFuture.complete
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.succeed
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.lambda$wrap$9
    at java.util.concurrent.CompletableFuture.uniWhenComplete
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire
    at java.util.concurrent.CompletableFuture.postComplete
    at java.util.concurrent.CompletableFuture.complete
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.succeed
    at com.spotify.google.cloud.pubsub.client.Pubsub.lambda$requestJavaNet$8
    at java.util.concurrent.ThreadPoolExecutor.runWorker
    at java.util.concurrent.ThreadPoolExecutor$Worker.run
    at java.lang.Thread.run
com.google.cloud.storage.StorageException: Socket is closed
    at com.google.cloud.storage.spi.DefaultStorageRpc.translate
    at com.google.cloud.storage.spi.DefaultStorageRpc.open
    at com.google.cloud.storage.BlobWriteChannel.<init>
    at com.google.cloud.storage.StorageImpl.writer
    at com.google.cloud.storage.StorageImpl.writer
    at com.google.cloud.storage.StorageImpl.writer
    at com.spotify.buildartifactarchiver.storage.GcsUploaderClient.storeInputStream
    at com.spotify.buildartifactarchiver.storage.ArtifactUploader.uploadZipArchive
    at com.spotify.buildartifactarchiver.storage.ArtifactUploader.upload
    at com.spotify.buildartifactarchiver.ArtifactArchiver.archiveArtifactsForBuild
    at com.spotify.buildartifactarchiver.ArtifactArchiver.archiveBuild
    at com.spotify.buildartifactarchiver.web.ArtifactArchiverPubSubResource.messageHandler
    at com.spotify.google.cloud.pubsub.client.Puller.lambda$pullBatch$11
    at java.util.concurrent.CompletableFuture.uniWhenComplete
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire
    at java.util.concurrent.CompletableFuture.postComplete
    at java.util.concurrent.CompletableFuture.complete
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.succeed
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.lambda$wrap$9
    at java.util.concurrent.CompletableFuture.uniWhenComplete
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire
    at java.util.concurrent.CompletableFuture.postComplete
    at java.util.concurrent.CompletableFuture.complete
    at com.spotify.google.cloud.pubsub.client.PubsubFuture.succeed
    at com.spotify.google.cloud.pubsub.client.Pubsub.lambda$requestJavaNet$8
    at java.util.concurrent.ThreadPoolExecutor.runWorker
    at java.util.concurrent.ThreadPoolExecutor$Worker.run
    at java.lang.Thread.run

We are uploading files using the following code if there is something that we might be doing wrong...

  public void storeInputStream(InputStream input, String fileName, String contentType)
      throws IOException {

    Storage storage = getStorage();

    BlobId blobId = BlobId.of(this.bucketName, fileName);
    LOG.debug("blobId: {}", blobId);
    BlobInfo blobInfo = BlobInfo.builder(blobId).contentType(contentType).build();
    LOG.debug("blobInfo: {}", blobInfo);
    LOG.info("Starting upload to GCS for file: {} with content type:{}", fileName, contentType);
    //perform stream uploads of the InputStream
    try (WriteChannel writer = storage.writer(blobInfo)) {
      byte[] buffer = new byte[1024];
      int limit;
      while ((limit = input.read(buffer)) >= 0) {
        writer.write(ByteBuffer.wrap(buffer, 0, limit));
      }
    }
  }

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0