data model changes - #16189
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for different OAuth types (STANDARD, PKCE, and REFRESH_TOKEN_ROTATION) within the CDAP data pipeline. It updates OAuthProvider, OAuthStore, PutOAuthProviderRequest, and OAuthHandler to handle, store, and retrieve the new oauthType field, defaulting to STANDARD. The feedback suggests several improvements: handling potential null values in PutOAuthProviderRequest's getter to prevent NullPointerExceptions during GSON deserialization, and removing redundant @nullable annotations and null checks in OAuthProvider and OAuthStore since oauthType is guaranteed to be non-null.
| public OAuthProvider.OAuthType getOAuthType() { | ||
| return oauthType; | ||
| } |
There was a problem hiding this comment.
When PutOAuthProviderRequest is deserialized from JSON (e.g., via GSON in OAuthHandler), GSON bypasses the constructor if there is no default constructor, leaving the oauthType field as null if it is missing from the request payload. To prevent potential NullPointerExceptions in callers, the getter should return a default value of OAuthType.STANDARD if oauthType is null.
| public OAuthProvider.OAuthType getOAuthType() { | |
| return oauthType; | |
| } | |
| public OAuthProvider.OAuthType getOAuthType() { | |
| return oauthType == null ? OAuthProvider.OAuthType.STANDARD : oauthType; | |
| } |
| @Nullable | ||
| private final OAuthType oauthType; |
There was a problem hiding this comment.
The oauthType field is annotated with @Nullable, but both constructors and the builder guarantee that it is initialized to a non-null value (defaulting to OAuthType.STANDARD if null). To avoid confusion and redundant null checks, the @Nullable annotation should be removed.
| @Nullable | |
| private final OAuthType oauthType; | |
| private final OAuthType oauthType; |
| @Nullable | ||
| public OAuthType getOAuthType() { | ||
| return oauthType; | ||
| } |
| fields.add(Fields.stringField( | ||
| OAUTH_TYPE_COL, | ||
| Optional.ofNullable(oauthProvider.getOAuthType()) | ||
| .orElse(OAuthProvider.OAuthType.STANDARD).toString())); |
0d2ee57 to
641e6b6
Compare
4c7b74b to
cec6114
Compare
cec6114 to
b8283ff
Compare
No description provided.