Skip to content
This repository was archived by the owner on Dec 23, 2023. It is now read-only.

Commit a9451b6

Browse files
authored
Checker Framework: 2.8.1 -> 2.8.2 (#1925)
This commit also suppresses a new nullness warning.
1 parent 8a189aa commit a9451b6

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ subprojects {
252252

253253
dependencies {
254254
if (useCheckerFramework) {
255-
ext.checkerFrameworkVersion = '2.8.1'
255+
ext.checkerFrameworkVersion = '2.8.2'
256256

257257
// 2.4.0 is the last version of the Checker Framework compiler that supports annotations
258258
// in comments, though it should continue to work with newer versions of the Checker Framework.

impl_core/src/main/java/io/opencensus/implcore/trace/export/SpanExporterImpl.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.common.annotations.VisibleForTesting;
2020
import io.opencensus.common.Duration;
2121
import io.opencensus.common.ToLongFunction;
22+
import io.opencensus.implcore.internal.CheckerFrameworkUtils;
2223
import io.opencensus.implcore.internal.DaemonThreadFactory;
2324
import io.opencensus.implcore.trace.RecordEventsSpanImpl;
2425
import io.opencensus.metrics.DerivedLongCumulative;
@@ -318,13 +319,17 @@ private long getPushedSpans() {
318319
}
319320
}
320321

321-
@SuppressWarnings("argument.type.incompatible")
322-
private void exportBatches(ArrayList<RecordEventsSpanImpl> spanList) {
322+
private void exportBatches(ArrayList<RecordEventsSpanImpl> spansCopy) {
323323
ArrayList<SpanData> spanDataList = new ArrayList<>(bufferSize);
324-
for (int i = 0; i < spanList.size(); i++) {
325-
spanDataList.add(spanList.get(i).toSpanData());
324+
for (int i = 0; i < spansCopy.size(); i++) {
325+
spanDataList.add(spansCopy.get(i).toSpanData());
326+
326327
// Remove the reference to the RecordEventsSpanImpl to allow GC to free the memory.
327-
spanList.set(i, null);
328+
// TODO: Refactor the handling of the spans list to remove this call to castNonNull. Setting
329+
// the elements to null after they are read is safe because 'exportBatches' is only ever
330+
// called on a copy of 'spans', and the copy is not reused.
331+
spansCopy.set(i, (RecordEventsSpanImpl) CheckerFrameworkUtils.castNonNull(null));
332+
328333
if (spanDataList.size() == bufferSize) {
329334
// One full batch, export it now. Wrap the list with unmodifiableList to ensure exporter
330335
// does not change the list.

0 commit comments

Comments
 (0)