-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(artifacts): Make ArtifactCredentials null-safe (#4586)
* refactor(artifacts): Make artifact accounts immutable and null-safe There are a lot of config properties that can be set for artifacts. In general, they don't care about the difference between unset and null values, but this is enforced at various points of rather than at the API boundary. In order to make it more clear that this is the case, update the configuration classes to be immutable and to translate null strings to empty strings upon creation. This removes the ability of any consuming code to be able to see an null value in these string properties. In particular, we make all fields on artifact accounts immutable, and replace the setters with a constructor. The ConstructorBinding annotation is what tells Spring to bind properties using the constructor (without it, it will look for setters and fail). We also provide a Builder for convenience (primarily for testing) to avoid needing to use the many-arg-constructor. As the constructor will be called by Spring, which does allow null properties we need to treat all input as potentially null and convert to non-null in the constructor. * refactor(artifacts): Make ArtifactCredentials null-safe Now that the artifact accounts are immutable, the artifact credentials that read from them can be made NonNullByDefault. This commit also removes a number of now-redundant null-checks on its fields, replacing them with .isEmpty() on a now guaranteed to be non-null string. This commit also updates one of the interface methods to return an ImmutableList (which all but one implementation was effectively doing by returning Collections.singletonList), and makes the interface NonnullByDefault. There was a single implementation of download() that was not null-safe. I've updated it to eagerly throw an exception; all callers of that method that was updated immediately pass the output to IOUtils.copy which will throw a null pointer exception. This change will simply provide more context around the exception. * refactor(artifacts): Make auth fields optional The username, password, and usernamePasswordFile fields are really optional, so let's store them as an Optional<String> (where the contents of the optional is non-null and non-empty) instead of using the empty string to mean optional. * style(aritfacts): Remove guava from API boundary This commit removes the ImmutableList from the API boundary of ArtifactCredentials. The list should still be immutable, but we'll add a comment to do what type checking won't here. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
13d2d03
commit e268b68
Showing
52 changed files
with
582 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.