Skip to content

Commit d1f4f17

Browse files
committed
add reasons for suppressed warnings
1 parent a00a673 commit d1f4f17

File tree

36 files changed

+47
-47
lines changed

36 files changed

+47
-47
lines changed

api/all/src/main/java/io/opentelemetry/api/common/ArrayBackedAttributes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public AttributesBuilder toBuilder() {
4141
return new ArrayBackedAttributesBuilder(new ArrayList<>(data()));
4242
}
4343

44-
@SuppressWarnings("unchecked")
44+
@SuppressWarnings("unchecked") // entries are typed as Object[]
4545
@Override
4646
@Nullable
4747
public <T> T get(AttributeKey<T> key) {

api/all/src/main/java/io/opentelemetry/api/common/ArrayBackedAttributesBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public <T> AttributesBuilder put(AttributeKey<T> key, @Nullable T value) {
4848
}
4949

5050
@Override
51-
@SuppressWarnings({"unchecked", "rawtypes"})
51+
@SuppressWarnings({"unchecked", "rawtypes"}) // using "put" method with raw type AttributeKey
5252
public AttributesBuilder putAll(Attributes attributes) {
5353
if (attributes == null) {
5454
return this;

api/all/src/main/java/io/opentelemetry/api/internal/ImmutableKeyValuePairs.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public final Map<K, V> asMap() {
7171

7272
/** Returns the value for the given {@code key}, or {@code null} if the key is not present. */
7373
@Nullable
74-
@SuppressWarnings("unchecked")
74+
@SuppressWarnings("unchecked") // data is typed as Object[]
7575
public final V get(K key) {
7676
if (key == null) {
7777
return null;
@@ -85,7 +85,7 @@ public final V get(K key) {
8585
}
8686

8787
/** Iterates over all the key-value pairs of labels contained by this instance. */
88-
@SuppressWarnings("unchecked")
88+
@SuppressWarnings("unchecked") // data is typed as Object[]
8989
public final void forEach(BiConsumer<? super K, ? super V> consumer) {
9090
if (consumer == null) {
9191
return;
@@ -150,7 +150,7 @@ private static void splitAndMerge(
150150
* Left source half is sourceArray[ beginIndex:middleIndex-1]. Right source half is sourceArray[
151151
* middleIndex:endIndex-1]. Result is targetArray[ beginIndex:endIndex-1].
152152
*/
153-
@SuppressWarnings("unchecked")
153+
@SuppressWarnings("unchecked") // sourceArray and targetArray is typed as Object[]
154154
private static <K> void merge(
155155
Object[] sourceArray,
156156
int beginIndex,
@@ -192,7 +192,7 @@ private static <K> int compareToNullSafe(
192192
return keyComparator.compare(key, pivotKey);
193193
}
194194

195-
@SuppressWarnings("unchecked")
195+
@SuppressWarnings("unchecked") // data is typed as Object[]
196196
private static <K> Object[] dedupe(Object[] data, Comparator<K> keyComparator) {
197197
Object previousKey = null;
198198
int size = 0;

api/all/src/main/java/io/opentelemetry/api/internal/IncubatingUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
public class IncubatingUtil {
1919
private IncubatingUtil() {}
2020

21-
@SuppressWarnings("unchecked")
21+
@SuppressWarnings("unchecked") // casting to T
2222
public static <T> T incubatingApiIfAvailable(T stableApi, String incubatingClassName) {
2323
try {
2424
Class<?> incubatingClass = Class.forName(incubatingClassName);

api/all/src/main/java/io/opentelemetry/api/internal/ReadOnlyArrayMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
3838
* at any time.
3939
*/
40-
@SuppressWarnings("unchecked")
40+
@SuppressWarnings("unchecked") // array is typed as List<Object>
4141
public final class ReadOnlyArrayMap<K, V> extends AbstractMap<K, V> {
4242

4343
/** Returns a read-only view of the given {@code array}. */

api/all/src/main/java/io/opentelemetry/api/logs/LogRecordBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ default LogRecordBuilder setBody(Value<?> body) {
9494
* Sets attributes. If the {@link LogRecordBuilder} previously contained a mapping for any of the
9595
* keys, the old values are replaced by the specified values.
9696
*/
97-
@SuppressWarnings("unchecked")
97+
@SuppressWarnings("unchecked") // use of raw AttributeKey
9898
default LogRecordBuilder setAllAttributes(Attributes attributes) {
9999
if (attributes == null || attributes.isEmpty()) {
100100
return this;

api/all/src/main/java/io/opentelemetry/api/trace/ArrayBasedTraceState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void forEach(BiConsumer<String, String> consumer) {
5454
}
5555

5656
@Override
57-
@SuppressWarnings({"unchecked", "rawtypes"})
57+
@SuppressWarnings({"unchecked", "rawtypes"}) // wrap takes List<Object>
5858
public Map<String, String> asMap() {
5959
return ReadOnlyArrayMap.wrap((List) getEntries());
6060
}

api/all/src/main/java/io/opentelemetry/api/trace/Span.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ default Span setAttribute(AttributeKey<Long> key, int value) {
180180
* @return this.
181181
* @since 1.2.0
182182
*/
183-
@SuppressWarnings("unchecked")
183+
@SuppressWarnings("unchecked") // use of raw AttributeKey
184184
default Span setAllAttributes(Attributes attributes) {
185185
if (attributes == null || attributes.isEmpty()) {
186186
return this;

api/all/src/main/java/io/opentelemetry/api/trace/SpanBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ default SpanBuilder setAttribute(AttributeKey<Long> key, int value) {
259259
* @return this.
260260
* @since 1.2.0
261261
*/
262-
@SuppressWarnings("unchecked")
262+
@SuppressWarnings("unchecked") // use of raw AttributeKey
263263
default SpanBuilder setAllAttributes(Attributes attributes) {
264264
if (attributes == null || attributes.isEmpty()) {
265265
return this;

api/incubator/src/main/java/io/opentelemetry/api/incubator/common/ArrayBackedExtendedAttributes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public ExtendedAttributesBuilder toBuilder() {
4747
return new ArrayBackedExtendedAttributesBuilder(new ArrayList<>(data()));
4848
}
4949

50-
@SuppressWarnings("unchecked")
50+
@SuppressWarnings("unchecked") // cast to T
5151
@Override
5252
@Nullable
5353
public <T> T get(ExtendedAttributeKey<T> key) {
5454
return (T) super.get(key);
5555
}
5656

57-
@SuppressWarnings("unchecked")
57+
@SuppressWarnings("unchecked") // use of raw ExtendedAttributeKey
5858
@Override
5959
public Attributes asAttributes() {
6060
if (attributes == null) {

0 commit comments

Comments
 (0)