In order for us to expose google-auth-library-java classes in google-cloud-java (thus dropping our AuthCredentials classes), we need Credentials classes to be Serializable.
One of the main obstacles to making Credentials classes serializable is that some of them contain an HttpTransport field, which is not serializable (see ComputeEngineCredentials for instance).
We faced this issue with our HttpServiceOptions classes and introduced the HttpTransportFactory interface:
/**
* A base interface for all {@link HttpTransport} factories.
*
* <p>Implementation must provide a public no-arg constructor. Loading of a factory implementation
* is done via {@link java.util.ServiceLoader}.
*/
public interface HttpTransportFactory {
HttpTransport create();
}
When serializing an option object we only transmit the class name for the transport factory and try to instantiate the factory from its classname upon deserialization.
Do you think something like this could be done for Credentials classes as well? Opinions are welcome.
/cc @anthmgoogle @garrettjonesgoogle @lesv
In order for us to expose
google-auth-library-javaclasses ingoogle-cloud-java(thus dropping ourAuthCredentialsclasses), we needCredentialsclasses to be Serializable.One of the main obstacles to making
Credentialsclasses serializable is that some of them contain anHttpTransportfield, which is not serializable (see ComputeEngineCredentials for instance).We faced this issue with our HttpServiceOptions classes and introduced the
HttpTransportFactoryinterface:When serializing an option object we only transmit the class name for the transport factory and try to instantiate the factory from its classname upon deserialization.
Do you think something like this could be done for
Credentialsclasses as well? Opinions are welcome./cc @anthmgoogle @garrettjonesgoogle @lesv