3333
3434import com .google .api .client .json .GenericJson ;
3535import com .google .api .client .json .JsonObjectParser ;
36- import com .google .api .client .util .Preconditions ;
3736import com .google .api .core .ObsoleteApi ;
3837import com .google .auth .Credentials ;
3938import com .google .auth .http .HttpTransportFactory ;
4039import com .google .common .annotations .VisibleForTesting ;
4140import com .google .common .base .MoreObjects ;
4241import com .google .common .base .MoreObjects .ToStringHelper ;
42+ import com .google .common .base .Preconditions ;
4343import com .google .common .base .Strings ;
4444import com .google .common .collect .ImmutableList ;
4545import com .google .common .collect .ImmutableMap ;
@@ -79,7 +79,7 @@ enum GoogleCredentialsInfo {
7979 COMPUTE_ENGINE_CREDENTIALS ("Compute Engine Credentials" , null );
8080
8181 private final String credentialName ;
82- @ Nullable private final String fileType ;
82+ private final @ Nullable String fileType ;
8383
8484 GoogleCredentialsInfo (String credentialName , @ Nullable String fileType ) {
8585 this .credentialName = credentialName ;
@@ -97,17 +97,17 @@ String getCredentialName() {
9797
9898 // The following package-private fields to provide additional info for errors message
9999 // Source of the credential (e.g. env var value or well know file location)
100- String source ;
100+ @ Nullable String source ;
101101 // User-friendly name of the Credential class
102- String name ;
102+ @ Nullable String name ;
103103 // Identity of the credential
104104 // Note: This field may contain data such as serviceAccountEmail which should not be serialized
105- transient String principal ;
105+ transient @ Nullable String principal ;
106106
107107 private final String universeDomain ;
108108 private final boolean isExplicitUniverseDomain ;
109109
110- protected final String quotaProjectId ;
110+ protected final @ Nullable String quotaProjectId ;
111111
112112 private static final DefaultCredentialsProvider defaultCredentialsProvider =
113113 new DefaultCredentialsProvider ();
@@ -230,7 +230,8 @@ public static GoogleCredentials getApplicationDefault(HttpTransportFactory trans
230230 * @throws IOException if the credential cannot be created from the stream.
231231 */
232232 @ ObsoleteApi (
233- "This method is obsolete because of a potential security risk. Use the credential specific load method instead" )
233+ "This method is obsolete because of a potential security risk. Use the credential specific"
234+ + " load method instead" )
234235 public static GoogleCredentials fromStream (InputStream credentialsStream ) throws IOException {
235236 return fromStream (credentialsStream , OAuth2Utils .HTTP_TRANSPORT_FACTORY );
236237 }
@@ -296,7 +297,8 @@ static String extractFromJson(Map<String, Object> json, String field) throws IOE
296297 * @throws IOException if the credential cannot be created from the stream.
297298 */
298299 @ ObsoleteApi (
299- "This method is obsolete because of a potential security risk. Use the credential specific load method instead" )
300+ "This method is obsolete because of a potential security risk. Use the credential specific"
301+ + " load method instead" )
300302 public static GoogleCredentials fromStream (
301303 InputStream credentialsStream , HttpTransportFactory transportFactory ) throws IOException {
302304 Preconditions .checkNotNull (transportFactory );
@@ -389,7 +391,7 @@ boolean isDefaultUniverseDomain() throws IOException {
389391 * @return a new map with quotaProjectId added if needed
390392 */
391393 static Map <String , List <String >> addQuotaProjectIdToRequestMetadata (
392- String quotaProjectId , Map <String , List <String >> requestMetadata ) {
394+ @ Nullable String quotaProjectId , Map <String , List <String >> requestMetadata ) {
393395 Preconditions .checkNotNull (requestMetadata );
394396 Map <String , List <String >> newRequestMetadata = new HashMap <>(requestMetadata );
395397 if (quotaProjectId != null && !requestMetadata .containsKey (QUOTA_PROJECT_ID_HEADER_KEY )) {
@@ -527,7 +529,7 @@ public Builder toBuilder() {
527529 }
528530
529531 @ Override
530- public String getQuotaProjectId () {
532+ public @ Nullable String getQuotaProjectId () {
531533 return this .quotaProjectId ;
532534 }
533535
@@ -538,7 +540,7 @@ public String getQuotaProjectId() {
538540 *
539541 * @return the project id for a Credential type
540542 */
541- public String getProjectId () {
543+ public @ Nullable String getProjectId () {
542544 return null ;
543545 }
544546
@@ -653,8 +655,8 @@ public Map<String, String> getCredentialInfo() {
653655 }
654656
655657 public static class Builder extends OAuth2Credentials .Builder {
656- @ Nullable protected String quotaProjectId ;
657- @ Nullable protected String universeDomain ;
658+ protected @ Nullable String quotaProjectId ;
659+ protected @ Nullable String universeDomain ;
658660 @ Nullable String source ;
659661
660662 protected Builder () {}
@@ -679,7 +681,7 @@ public GoogleCredentials build() {
679681 }
680682
681683 @ CanIgnoreReturnValue
682- public Builder setQuotaProjectId (String quotaProjectId ) {
684+ public Builder setQuotaProjectId (@ Nullable String quotaProjectId ) {
683685 this .quotaProjectId = quotaProjectId ;
684686 return this ;
685687 }
@@ -689,22 +691,23 @@ public Builder setUniverseDomain(String universeDomain) {
689691 return this ;
690692 }
691693
692- public String getQuotaProjectId () {
694+ public @ Nullable String getQuotaProjectId () {
693695 return this .quotaProjectId ;
694696 }
695697
696- public String getUniverseDomain () {
698+ public @ Nullable String getUniverseDomain () {
697699 return this .universeDomain ;
698700 }
699701
700- Builder setSource (String source ) {
702+ @ CanIgnoreReturnValue
703+ Builder setSource (@ Nullable String source ) {
701704 this .source = source ;
702705 return this ;
703706 }
704707
705708 @ Override
706709 @ CanIgnoreReturnValue
707- public Builder setAccessToken (AccessToken token ) {
710+ public Builder setAccessToken (@ Nullable AccessToken token ) {
708711 super .setAccessToken (token );
709712 return this ;
710713 }
0 commit comments