Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public AttributesBuilder toBuilder() {
return new ArrayBackedAttributesBuilder(new ArrayList<>(data()));
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // entries are typed as Object[]
@Override
@Nullable
public <T> T get(AttributeKey<T> key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public <T> AttributesBuilder put(AttributeKey<T> key, @Nullable T value) {
}

@Override
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"unchecked", "rawtypes"}) // using "put" method with raw type AttributeKey
public AttributesBuilder putAll(Attributes attributes) {
if (attributes == null) {
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ default AttributesBuilder put(String key, String... value) {
*
* @return this Builder
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // cast to T
default <T> AttributesBuilder put(AttributeKey<List<T>> key, T... value) {
if (value == null) {
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final Map<K, V> asMap() {

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

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

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // data is typed as Object[]
private static <K> Object[] dedupe(Object[] data, Comparator<K> keyComparator) {
Object previousKey = null;
int size = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class IncubatingUtil {
private IncubatingUtil() {}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // casting to T
public static <T> T incubatingApiIfAvailable(T stableApi, String incubatingClassName) {
try {
Class<?> incubatingClass = Class.forName(incubatingClassName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // array is typed as List<Object>
public final class ReadOnlyArrayMap<K, V> extends AbstractMap<K, V> {

/** Returns a read-only view of the given {@code array}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ default LogRecordBuilder setBody(Value<?> body) {
* Sets attributes. If the {@link LogRecordBuilder} previously contained a mapping for any of the
* keys, the old values are replaced by the specified values.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // use of raw AttributeKey
default LogRecordBuilder setAllAttributes(Attributes attributes) {
if (attributes == null || attributes.isEmpty()) {
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void forEach(BiConsumer<String, String> consumer) {
}

@Override
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"unchecked", "rawtypes"}) // wrap takes List<Object>
public Map<String, String> asMap() {
return ReadOnlyArrayMap.wrap((List) getEntries());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ default Span setAttribute(AttributeKey<Long> key, int value) {
* @return this.
* @since 1.2.0
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // use of raw AttributeKey
default Span setAllAttributes(Attributes attributes) {
if (attributes == null || attributes.isEmpty()) {
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ default SpanBuilder setAttribute(AttributeKey<Long> key, int value) {
* @return this.
* @since 1.2.0
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // use of raw AttributeKey
default SpanBuilder setAllAttributes(Attributes attributes) {
if (attributes == null || attributes.isEmpty()) {
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public ExtendedAttributesBuilder toBuilder() {
return new ArrayBackedExtendedAttributesBuilder(new ArrayList<>(data()));
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // cast to T
@Override
@Nullable
public <T> T get(ExtendedAttributeKey<T> key) {
return (T) super.get(key);
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // use of raw ExtendedAttributeKey
@Override
public Attributes asAttributes() {
if (attributes == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ default ExtendedAttributesBuilder put(String key, String... value) {
*
* @return this Builder
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // use of raw AttributeKey
default <T> ExtendedAttributesBuilder put(AttributeKey<List<T>> key, T... value) {
if (value == null) {
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ default ExtendedLogRecordBuilder setBody(Value<?> body) {
* log record, there is no difference between adding attributes using the standard or extended
* attribute APIs.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // use of raw AttributeKey
@Override
default ExtendedLogRecordBuilder setAllAttributes(Attributes attributes) {
if (attributes == null || attributes.isEmpty()) {
Expand All @@ -100,7 +100,7 @@ default ExtendedLogRecordBuilder setAllAttributes(Attributes attributes) {
* log record, there is no difference between adding attributes using the standard or extended
* attribute APIs.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // use of raw ExtendedAttributeKey
default ExtendedLogRecordBuilder setAllAttributes(ExtendedAttributes attributes) {
if (attributes == null || attributes.isEmpty()) {
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private ArrayBasedContext(Object[] entries) {
public <V> V get(ContextKey<V> key) {
for (int i = 0; i < entries.length; i += 2) {
if (entries[i] == key) {
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // entries are typed as Object[]
V result = (V) entries[i + 1];
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public WeakConcurrentMap(
}

@Override
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // safe cast to LookupKey<K>
protected LookupKey<K> getLookupKey(K key) {
LookupKey<K> lookupKey;
if (reuseKeys) {
Expand Down
2 changes: 1 addition & 1 deletion dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rootProject.extra["versions"] = dependencyVersions


val autoValueVersion = "1.11.1"
val errorProneVersion = "2.43.0"
val errorProneVersion = "2.44.0"
val jmhVersion = "1.37"
// Mockito 5.x.x requires Java 11 https://github.com/mockito/mockito/releases/tag/v5.0.0
val mockitoVersion = "4.11.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ void reset() {
private final Pool<Map<?, ?>> mapPool = new Pool<>(IdentityHashMap::new, Map::clear);

/** Returns a pooled identity map. */
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // generic K,V
public <K, V> Map<K, V> getIdentityMap() {
return (Map<K, V>) mapPool.get();
}

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

/** Returns a pooled list. */
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // generic T
public <T> List<T> getList() {
return (List<T>) listPool.get();
}
Expand Down Expand Up @@ -220,7 +220,7 @@ public static Key key() {

private Object[] instances = new Object[16];

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // cast to generic T
public <T> T getInstance(Key key, Supplier<T> supplier) {
if (key.index >= instances.length) {
Object[] newData = new Object[instances.length * 2];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ public abstract <T> void serializeRepeatedMessageWithContext(
* together with {@link StatelessMarshalerUtil#sizeRepeatedMessageWithContext(ProtoFieldInfo,
* Collection, StatelessMarshaler, MarshalerContext, MarshalerContext.Key)}.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // cast to List<T>
public <T> void serializeRepeatedMessageWithContext(
ProtoFieldInfo field,
Collection<? extends T> messages,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static <T> int sizeRepeatedMessageWithContext(
* together with {@link Serializer#serializeRepeatedMessageWithContext(ProtoFieldInfo, Collection,
* StatelessMarshaler, MarshalerContext, MarshalerContext.Key)}.
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // safe cast to List<T>
public static <T> int sizeRepeatedMessageWithContext(
ProtoFieldInfo field,
Collection<? extends T> messages,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class AnyValueMarshaler {

private AnyValueMarshaler() {}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe by discriminated type
public static MarshalerWithSize create(Value<?> value) {
switch (value.getType()) {
case STRING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class AnyValueStatelessMarshaler implements StatelessMarshaler<Valu

private AnyValueStatelessMarshaler() {}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe by discriminated type
@Override
public void writeTo(Serializer output, Value<?> value, MarshalerContext context)
throws IOException {
Expand Down Expand Up @@ -71,7 +71,7 @@ public void writeTo(Serializer output, Value<?> value, MarshalerContext context)
throw new IllegalArgumentException("Unsupported value type.");
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe by discriminated type
@Override
public int getBinarySerializedSize(Value<?> value, MarshalerContext context) {
switch (value.getType()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class AttributeArrayAnyValueStatelessMarshaler<T>

private AttributeArrayAnyValueStatelessMarshaler() {}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe by discriminated type
@Override
public void writeTo(Serializer output, AttributeType type, List<T> list, MarshalerContext context)
throws IOException {
Expand Down Expand Up @@ -57,7 +57,7 @@ public void writeTo(Serializer output, AttributeType type, List<T> list, Marshal
}
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe by discriminated type
@Override
public int getBinarySerializedSize(AttributeType type, List<T> list, MarshalerContext context) {
switch (type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static <T> AttributeKeyValue<T> of(AttributeKey<T> attributeKey, T value) {
}

/** Returns a List corresponding to the provided Map. This is a copy, not a view. */
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe as we are just iterating over the map entries
static <T> List<AttributeKeyValue<?>> of(Attributes attributes) {
List<AttributeKeyValue<?>> result = new ArrayList<>(attributes.size());
attributes.forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static class ValueStatelessMarshaler
implements StatelessMarshaler2<AttributeKey<?>, Object> {
static final ValueStatelessMarshaler INSTANCE = new ValueStatelessMarshaler();

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe by discriminated type
@Override
public int getBinarySerializedSize(
AttributeKey<?> attributeKey, Object value, MarshalerContext context) {
Expand Down Expand Up @@ -106,7 +106,7 @@ public int getBinarySerializedSize(
throw new IllegalArgumentException("Unsupported attribute type.");
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe by discriminated type
@Override
public void writeTo(
Serializer output, AttributeKey<?> attributeKey, Object value, MarshalerContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private static class ValueStatelessMarshaler
implements StatelessMarshaler2<ExtendedAttributeKey<?>, Object> {
static final ValueStatelessMarshaler INSTANCE = new ValueStatelessMarshaler();

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe by discriminated type
@Override
public int getBinarySerializedSize(
ExtendedAttributeKey<?> attributeKey, Object value, MarshalerContext context) {
Expand Down Expand Up @@ -180,7 +180,7 @@ public int getBinarySerializedSize(
throw new IllegalArgumentException("Unsupported attribute type.");
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe by discriminated type
@Override
public void writeTo(
Serializer output,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void accept(ExtendedAttributeKey<?> attributeKey, Object o) {
}

// TODO(jack-berg): move to KeyValueMarshaler when ExtendedAttributes is stable
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // casting to specific types based on attributeKey type
private static KeyValueMarshaler create(ExtendedAttributeKey<?> attributeKey, Object value) {
byte[] keyUtf8;
if (attributeKey.getKey().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void accept(AttributeKeyValue<?> attributeKeyValue) {
return keyValueMarshalers;
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe by disriminated type
private static KeyValueMarshaler create(AttributeKey<?> attributeKey, Object value) {
byte[] keyUtf8;
if (attributeKey.getKey().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ private List<U> toProto(List<T> telemetry) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
marshaler.writeBinaryTo(bos);
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // cast to U
U result =
(U)
resourceTelemetryInstance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ private List<U> toProto(List<T> telemetry) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
marshaler.writeBinaryTo(bos);
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // safe cast to U
U result =
(U)
resourceTelemetryInstance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public SpanBuilder withStartTimestamp(long microseconds) {
return this;
}

@SuppressWarnings({"rawtypes", "unchecked"})
@SuppressWarnings({"rawtypes", "unchecked"}) // use of raw AttributeKey
@Override
public Span start() {
Baggage baggage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private static void addToBuilder(
+ type.name());
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // safe due to type check
@Nullable
private static <T> List<T> checkListOfType(Object value, Class<T> expectedType) {
if (!(value instanceof List)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private YamlDeclarativeConfigProperties(
*
* @see DeclarativeConfiguration#toConfigProperties(Object)
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe due to type checks
public static YamlDeclarativeConfigProperties create(
Map<String, Object> properties, ComponentLoader componentLoader) {
Map<String, Object> simpleEntries = new LinkedHashMap<>();
Expand Down Expand Up @@ -192,7 +192,7 @@ public Double getDouble(String name) {

@Nullable
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked") // Safe due to type check
public <T> List<T> getScalarList(String name, Class<T> scalarType) {
if (!SUPPORTED_SCALAR_TYPES.contains(scalarType)) {
throw new DeclarativeConfigException(
Expand Down
Loading
Loading