Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional safe-logging annotations on type variables #1437

Merged
merged 2 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-1437.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Additional safe-logging annotations on type variables
links:
- https://github.com/palantir/tritium/pull/1437
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ public MetricName.Builder putSafeTags(@Safe String key, @Safe String value) {
}

@CanIgnoreReturnValue
public MetricName.Builder putSafeTags(@Safe Map.Entry<String, ? extends String> entry) {
public MetricName.Builder putSafeTags(@Safe Map.Entry<@Safe String, @Safe ? extends String> entry) {
Preconditions.checkNotNull(entry, "entry");
tagMap = tagMap.withEntry(entry.getKey(), entry.getValue());
return (MetricName.Builder) this;
}

@SuppressWarnings("unchecked")
@CanIgnoreReturnValue
public MetricName.Builder safeTags(@Safe Map<String, ? extends String> entries) {
public MetricName.Builder safeTags(@Safe Map<@Safe String, @Safe ? extends String> entries) {
Preconditions.checkNotNull(entries, "entries");
tagMap = TagMap.of((Map<String, String>) entries);
return (MetricName.Builder) this;
}

@SuppressWarnings("unchecked")
@CanIgnoreReturnValue
public MetricName.Builder putAllSafeTags(@Safe Map<String, ? extends String> entries) {
public MetricName.Builder putAllSafeTags(@Safe Map<@Safe String, @Safe ? extends String> entries) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likely safe to remove the parameter annotation in these cases, but I could go either way

Preconditions.checkNotNull(entries, "entries");
if (!entries.isEmpty()) {
tagMap = tagMap.isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface MetricName {
* <p>All tags and keys must be {@link Safe} to log.
*/
@Safe
SortedMap<String, String> safeTags();
SortedMap<@Safe String, @Safe String> safeTags();

static Builder builder() {
return new Builder();
Expand Down