Skip to content

Commit 9461819

Browse files
committed
fixes
1 parent 77bc79e commit 9461819

File tree

16 files changed

+29
-81
lines changed

16 files changed

+29
-81
lines changed

api/testing-internal/src/main/java/io/opentelemetry/api/testing/internal/AbstractDefaultMeterTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
/** Unit tests for No-op {@link Meter}. */
2828
@SuppressLogger
29+
@SuppressWarnings("this-escape")
2930
public abstract class AbstractDefaultMeterTest {
3031
private final Meter meter = getMeter();
3132

api/testing-internal/src/main/java/io/opentelemetry/api/testing/internal/AbstractDefaultTracerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/** Unit tests for No-op {@link Tracer}. */
2828
// Need to suppress warnings for MustBeClosed because Android 14 does not support
2929
// try-with-resources.
30-
@SuppressWarnings("MustBeClosedChecker")
30+
@SuppressWarnings({"MustBeClosedChecker", "this-escape"})
3131
public abstract class AbstractDefaultTracerTest {
3232
private final Tracer defaultTracer = getTracer();
3333
private static final String SPAN_NAME = "MySpanName";

buildSrc/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ plugins {
55
id("com.diffplug.spotless") version "8.0.0"
66
}
77

8-
if (!hasLauncherForJavaVersion(17)) {
8+
if (!hasLauncherForJavaVersion(21)) {
99
throw GradleException(
10-
"JDK 17 is required to build and gradle was unable to detect it on the system. " +
10+
"JDK 21 is required to build and gradle was unable to detect it on the system. " +
1111
"Please install it and see https://docs.gradle.org/current/userguide/toolchains.html#sec:auto_detection " +
1212
"for details on how gradle detects java toolchains."
1313
)
@@ -73,6 +73,6 @@ dependencies {
7373
// target.
7474
java {
7575
toolchain {
76-
languageVersion.set(JavaLanguageVersion.of(17))
76+
languageVersion.set(JavaLanguageVersion.of(21))
7777
}
7878
}

buildSrc/src/main/kotlin/otel.errorprone-conventions.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ tasks {
5151

5252
// We use animal sniffer
5353
disable("Java8ApiChecker")
54-
disable("AndroidJdkLibsChecker")
5554

5655
// apparently disabling android doesn't disable this
5756
disable("StaticOrDefaultInterfaceMethod")

buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ tasks.withType<AbstractArchiveTask>().configureEach {
3333

3434
java {
3535
toolchain {
36-
languageVersion.set(JavaLanguageVersion.of(17))
36+
languageVersion.set(JavaLanguageVersion.of(21))
3737
}
3838

3939
withJavadocJar()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"MissingSummary",
5050
"UngroupedOverloads",
5151
"ThreadPriorityCheck",
52-
"FieldMissingNullable"
52+
"FieldMissingNullable",
53+
"this-escape"
5354
})
5455
public class WeakConcurrentMap<K, V>
5556
extends AbstractWeakConcurrentMap<K, V, WeakConcurrentMap.LookupKey<K>> {

exporters/common/src/main/java/io/opentelemetry/exporter/internal/FailedExportException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static final class HttpExportException extends FailedExportException {
5656

5757
private static final long serialVersionUID = -6787390183017184775L;
5858

59-
@Nullable private final HttpSender.Response response;
59+
@Nullable private final transient HttpSender.Response response;
6060
@Nullable private final Throwable cause;
6161

6262
private HttpExportException(@Nullable HttpSender.Response response, @Nullable Throwable cause) {
@@ -100,7 +100,7 @@ public static final class GrpcExportException extends FailedExportException {
100100

101101
private static final long serialVersionUID = -9157548250286695364L;
102102

103-
@Nullable private final GrpcResponse response;
103+
@Nullable private final transient GrpcResponse response;
104104
@Nullable private final Throwable cause;
105105

106106
private GrpcExportException(@Nullable GrpcResponse response, @Nullable Throwable cause) {

sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/AggregatorHandle.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public abstract class AggregatorHandle<T extends PointData> {
4141
private final boolean isDoubleType;
4242
private volatile boolean valuesRecorded = false;
4343

44-
protected AggregatorHandle(ExemplarReservoirFactory reservoirFactory) {
45-
this.isDoubleType = isDoubleType();
44+
protected AggregatorHandle(ExemplarReservoirFactory reservoirFactory, boolean isDoubleType) {
45+
this.isDoubleType = isDoubleType;
4646
if (isDoubleType) {
4747
this.doubleReservoirFactory = reservoirFactory.createDoubleExemplarReservoir();
4848
this.longReservoirFactory = null;
@@ -80,19 +80,6 @@ public final T aggregateThenMaybeReset(
8080
reset);
8181
}
8282

83-
/**
84-
* Indicates whether this {@link AggregatorHandle} supports double or long values.
85-
*
86-
* <p>If it supports doubles, it MUST implement {@link #doAggregateThenMaybeResetDoubles(long,
87-
* long, Attributes, List, boolean)} and {@link #doRecordDouble(double)}.
88-
*
89-
* <p>If it supports long, it MUST implement {@link #doAggregateThenMaybeResetLongs(long, long,
90-
* Attributes, List, boolean)} and {@link #doRecordLong(long)}.
91-
*
92-
* @return true if it supports doubles, false if it supports longs.
93-
*/
94-
protected abstract boolean isDoubleType();
95-
9683
/** Implementation of the {@link #aggregateThenMaybeReset(long, long, Attributes, boolean)} . */
9784
protected T doAggregateThenMaybeResetDoubles(
9885
long startEpochNanos,

sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleBase2ExponentialHistogramAggregator.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static final class Handle extends AggregatorHandle<ExponentialHistogramPointData
100100
int maxBuckets,
101101
int maxScale,
102102
MemoryMode memoryMode) {
103-
super(reservoirFactory);
103+
super(reservoirFactory, /* isDoubleType= */ true);
104104
this.maxBuckets = maxBuckets;
105105
this.maxScale = maxScale;
106106
this.sum = 0;
@@ -260,11 +260,6 @@ protected synchronized void doRecordDouble(double value) {
260260
}
261261
}
262262

263-
@Override
264-
protected boolean isDoubleType() {
265-
return true;
266-
}
267-
268263
@Override
269264
public void recordLong(long value, Attributes attributes, Context context) {
270265
// Since there is no LongExplicitBucketHistogramAggregator and we need to support measurements

sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleExplicitBucketHistogramAggregator.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ static final class Handle extends AggregatorHandle<HistogramPointData> {
110110
private final long[] counts;
111111

112112
// Used only when MemoryMode = REUSABLE_DATA
113-
@Nullable private MutableHistogramPointData reusablePoint;
113+
@Nullable private final MutableHistogramPointData reusablePoint;
114114

115115
Handle(
116116
List<Double> boundaryList,
117117
double[] boundaries,
118118
ExemplarReservoirFactory reservoirFactory,
119119
MemoryMode memoryMode) {
120-
super(reservoirFactory);
120+
super(reservoirFactory, /* isDoubleType= */ true);
121121
this.boundaryList = boundaryList;
122122
this.boundaries = boundaries;
123123
this.counts = new long[this.boundaries.length + 1];
@@ -127,6 +127,8 @@ static final class Handle extends AggregatorHandle<HistogramPointData> {
127127
this.count = 0;
128128
if (memoryMode == MemoryMode.REUSABLE_DATA) {
129129
this.reusablePoint = new MutableHistogramPointData(counts.length);
130+
} else {
131+
this.reusablePoint = null;
130132
}
131133
}
132134

@@ -138,11 +140,6 @@ public void recordLong(long value, Attributes attributes, Context context) {
138140
super.recordDouble((double) value, attributes, context);
139141
}
140142

141-
@Override
142-
protected boolean isDoubleType() {
143-
return true;
144-
}
145-
146143
@Override
147144
protected HistogramPointData doAggregateThenMaybeResetDoubles(
148145
long startEpochNanos,

0 commit comments

Comments
 (0)