Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

Exception when creating client #23

Description

@hurricup

Working on desktop application working with google photos. Sometimes having an exception:

Oct 24, 2019 5:22:06 PM io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference cleanQueue
SEVERE: *~*~*~ Channel ManagedChannelImpl{logId=17, target=photoslibrary.googleapis.com:443} was not shutdown properly!!! ~*~*~*
    Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
java.lang.RuntimeException: ManagedChannel allocation site
	at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.<init>(ManagedChannelOrphanWrapper.java:94)
	at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:52)
	at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:43)
	at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:514)
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:223)
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:164)
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:156)
	at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:157)
	at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:122)
	at com.google.photos.library.v1.upload.PhotosLibraryUploadStubImpl.<init>(PhotosLibraryUploadStubImpl.java:35)
	at com.google.photos.library.v1.upload.PhotosLibraryUploadStubImpl.createStub(PhotosLibraryUploadStubImpl.java:44)
	at com.google.photos.library.v1.PhotosLibraryClient.<init>(PhotosLibraryClient.java:103)
	at com.google.photos.library.v1.PhotosLibraryClient.initialize(PhotosLibraryClient.java:114)
	at org.hurricup.google.PhotosLibraryClientFactory.createClient(PhotosLibraryClientFactory.java:64)

Activity

  1. katrielalex commented on Dec 4, 2019

    @katrielalex

    Apparently this is an issue in gax-java googleapis/google-cloud-java#3912 (fixed in release 1.36.0: googleapis/gax-java@v1.35.1...v1.36.0), but this package uses 1.45.0 so I'm not sure why we're still seeing it.

  2. ylexus commented on Feb 23, 2020

    @ylexus

    @katrielalex actually I think think this happens because PhotosLibraryClient, after creating PhotosLibraryUploadStub via PhotosLibraryUploadStubImpl.createStub(settings), never closes it. The PhotosLibraryStub does get closed via InternalPhotosLibraryClient#close(), but not the PhotosLibraryUploadStub.

  3. mixin82 commented on Dec 30, 2020

    @mixin82
    Contributor

    That's correct @ylexus. The issue manifests itself after the GC collects ManagedChannelOrphanWrapper instances and we then want to create or close another connection. Here's a way to reproduce this issue:

            PhotosLibraryClient client1, client2;
    
            client1 = PhotosLibraryClientFactory.createClient(secret_file_path, REQUIRED_SCOPES);
            client1.close();
    
            // let the GC dispose of ManagedChannelOrphanWrapper instances
            client1 = null;
            System.gc();
            Thread.sleep(1000);
    
            // Issue #23
            client2 = PhotosLibraryClientFactory.createClient(secret_file_path, REQUIRED_SCOPES);

    I think it's the same as issue #33. Here's a slightly different way to reproduce that:

            PhotosLibraryClient client1, client2;
    
            client1 = PhotosLibraryClientFactory.createClient(secret_file_path, REQUIRED_SCOPES);
            client1.close();
            client2 = PhotosLibraryClientFactory.createClient(secret_file_path, REQUIRED_SCOPES);
    
            // let the GC dispose of ManagedChannelOrphanWrapper instances
            client1 = null;
            System.gc();
            Thread.sleep(1000);
    
            // Issue #33
            client2.close();

    I did a change to close the uploadStub when PhotosLibraryClient closes and that should resolve both issues.

  4. self-assigned this
    on Jan 13, 2021
  5. jfschmakeit commented on Jan 14, 2021

    @jfschmakeit
    Contributor

    Just following up in the pull request before we can merge, but thanks for the investigation and the pull request @mixin82 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions