Skip to content

Making Credentials classes Serializable #67

@mziccard

Description

@mziccard

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

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.triage meI really want to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions