Skip to content

Commit 2ad32d4

Browse files
committed
fix
1 parent d1f4f17 commit 2ad32d4

File tree

20 files changed

+25
-27
lines changed

20 files changed

+25
-27
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ default AttributesBuilder put(String key, String... value) {
111111
*
112112
* @return this Builder
113113
*/
114-
@SuppressWarnings("unchecked")
114+
@SuppressWarnings("unchecked") // cast to T
115115
default <T> AttributesBuilder put(AttributeKey<List<T>> key, T... value) {
116116
if (value == null) {
117117
return this;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ default ExtendedAttributesBuilder put(String key, String... value) {
117117
*
118118
* @return this Builder
119119
*/
120-
@SuppressWarnings("unchecked")
120+
@SuppressWarnings("unchecked") // use of raw AttributeKey
121121
default <T> ExtendedAttributesBuilder put(AttributeKey<List<T>> key, T... value) {
122122
if (value == null) {
123123
return this;

context/src/main/java/io/opentelemetry/context/internal/shaded/WeakConcurrentMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public WeakConcurrentMap(
135135
}
136136

137137
@Override
138-
@SuppressWarnings("unchecked")
138+
@SuppressWarnings("unchecked") // safe cast to LookupKey<K>
139139
protected LookupKey<K> getLookupKey(K key) {
140140
LookupKey<K> lookupKey;
141141
if (reuseKeys) {

exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/MarshalerContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ void reset() {
138138
private final Pool<Map<?, ?>> mapPool = new Pool<>(IdentityHashMap::new, Map::clear);
139139

140140
/** Returns a pooled identity map. */
141-
@SuppressWarnings("unchecked")
141+
@SuppressWarnings("unchecked") // generic K,V
142142
public <K, V> Map<K, V> getIdentityMap() {
143143
return (Map<K, V>) mapPool.get();
144144
}
145145

146146
private final Pool<List<?>> listPool = new Pool<>(ArrayList::new, List::clear);
147147

148148
/** Returns a pooled list. */
149-
@SuppressWarnings("unchecked")
149+
@SuppressWarnings("unchecked") // generic T
150150
public <T> List<T> getList() {
151151
return (List<T>) listPool.get();
152152
}

exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/Serializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ public abstract <T> void serializeRepeatedMessageWithContext(
518518
* together with {@link StatelessMarshalerUtil#sizeRepeatedMessageWithContext(ProtoFieldInfo,
519519
* Collection, StatelessMarshaler, MarshalerContext, MarshalerContext.Key)}.
520520
*/
521-
@SuppressWarnings("unchecked")
521+
@SuppressWarnings("unchecked") // cast to List<T>
522522
public <T> void serializeRepeatedMessageWithContext(
523523
ProtoFieldInfo field,
524524
Collection<? extends T> messages,

exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/StatelessMarshalerUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public static <T> int sizeRepeatedMessageWithContext(
144144
* together with {@link Serializer#serializeRepeatedMessageWithContext(ProtoFieldInfo, Collection,
145145
* StatelessMarshaler, MarshalerContext, MarshalerContext.Key)}.
146146
*/
147-
@SuppressWarnings("unchecked")
147+
@SuppressWarnings("unchecked") // safe cast to List<T>
148148
public static <T> int sizeRepeatedMessageWithContext(
149149
ProtoFieldInfo field,
150150
Collection<? extends T> messages,

exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/AttributeKeyValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static <T> AttributeKeyValue<T> of(AttributeKey<T> attributeKey, T value) {
3232
}
3333

3434
/** Returns a List corresponding to the provided Map. This is a copy, not a view. */
35-
@SuppressWarnings("unchecked")
35+
@SuppressWarnings("unchecked") // Safe as we are just iterating over the map entries
3636
static <T> List<AttributeKeyValue<?>> of(Attributes attributes) {
3737
List<AttributeKeyValue<?>> result = new ArrayList<>(attributes.size());
3838
attributes.forEach(

exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/IncubatingUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void accept(ExtendedAttributeKey<?> attributeKey, Object o) {
8080
}
8181

8282
// TODO(jack-berg): move to KeyValueMarshaler when ExtendedAttributes is stable
83-
@SuppressWarnings("unchecked")
83+
@SuppressWarnings("unchecked") // casting to specific types based on attributeKey type
8484
private static KeyValueMarshaler create(ExtendedAttributeKey<?> attributeKey, Object value) {
8585
byte[] keyUtf8;
8686
if (attributeKey.getKey().isEmpty()) {

sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/YamlDeclarativeConfigProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private YamlDeclarativeConfigProperties(
7373
*
7474
* @see DeclarativeConfiguration#toConfigProperties(Object)
7575
*/
76-
@SuppressWarnings("unchecked")
76+
@SuppressWarnings("unchecked") // Safe due to type checks
7777
public static YamlDeclarativeConfigProperties create(
7878
Map<String, Object> properties, ComponentLoader componentLoader) {
7979
Map<String, Object> simpleEntries = new LinkedHashMap<>();

sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/metric/viewconfig/ViewConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static void registerViews(
9494
}
9595

9696
// Visible for testing
97-
@SuppressWarnings("unchecked")
97+
@SuppressWarnings("unchecked") // safe due to isInstance checks
9898
static List<ViewConfigSpecification> loadViewConfig(InputStream inputStream) {
9999
LoadSettings settings = LoadSettings.builder().build();
100100
Load yaml = new Load(settings);

0 commit comments

Comments
 (0)