tengqm commented on code in PR #5753:
URL: https://github.com/apache/gravitino/pull/5753#discussion_r1873244681
##########
api/src/main/java/org/apache/gravitino/credential/GCSTokenCredential.java:
##########
@@ -33,35 +33,48 @@ public class GCSTokenCredential implements Credential {
/** GCS credential property, token name. */
public static final String GCS_TOKEN_NAME = "token";
- private final String token;
- private final long expireMs;
+ private String token;
+ private long expireTimeInMs;
/**
* @param token The GCS token.
- * @param expireMs The GCS token expire time at ms.
+ * @param expireTimeInMs The GCS token expire time at ms.
*/
- public GCSTokenCredential(String token, long expireMs) {
- Preconditions.checkArgument(
- StringUtils.isNotBlank(token), "GCS session token should not be null");
+ public GCSTokenCredential(String token, long expireTimeInMs) {
+ validate(token, expireTimeInMs);
this.token = token;
- this.expireMs = expireMs;
+ this.expireTimeInMs = expireTimeInMs;
}
+ /**
+ * This is the constructor that is used by credential factory to create an
instance of credential
+ * according to the credential information.
+ */
+ public GCSTokenCredential() {}
+
@Override
public String credentialType() {
return GCS_TOKEN_CREDENTIAL_TYPE;
}
@Override
public long expireTimeInMs() {
- return expireMs;
+ return expireTimeInMs;
}
@Override
public Map<String, String> credentialInfo() {
return (new ImmutableMap.Builder<String, String>()).put(GCS_TOKEN_NAME,
token).build();
}
+ @Override
+ public void initWithCredentialInfo(Map<String, String> credentialInfo, long
expireTimeInMs) {
Review Comment:
My take of this is that the workflow is already flawed.
There should not be a `initialize` or `initializeWithThisOrThat` method.
These work are supposed to be done in a static class method, i.e. an exposed
constructor. This is true especially when we consider that the data used are
inherently immutable.
Since we are already invoking the constructor elsewhere and I don't want to
provoke
a wide range modification, changing this to `initialize` would make more
senses,
at least to me.
If, however, we have other use cases for initialization, say, initialize the
object
with something else, we can stick to the `initializeWithCredentialInfo` name.
In this context, I don't see a value in the wordy name. It only adds burden
to my
limited brain capacity. I was thinking ... maybe the object can be
initialized with
something else? No ... that is not true.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]