Skip to content

Commit

Permalink
Additional safe-logging annotations on type variables (#1437)
Browse files Browse the repository at this point in the history
Additional safe-logging annotations on type variables
  • Loading branch information
carterkozak authored Apr 11, 2022
1 parent 51972f7 commit 8576e41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
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) {
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

0 comments on commit 8576e41

Please sign in to comment.