Closed hurricup closed 3 years ago
Apparently this is an issue in gax-java https://github.com/googleapis/google-cloud-java/issues/3912 (fixed in release 1.36.0: https://github.com/googleapis/gax-java/compare/v1.35.1...v1.36.0), but this package uses 1.45.0 so I'm not sure why we're still seeing it.
@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.
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.
Just following up in the pull request before we can merge, but thanks for the investigation and the pull request @mixin82 !
Working on desktop application working with google photos. Sometimes having an exception: