Skip to content

Commit 27f0baf

Browse files
committed
[SPARK-53817] Use o.a.s.util.Pair instead of o.a.commons.lang3.tuple.Pair
### What changes were proposed in this pull request? This PR aims to - Use `org.apache.spark.util.Pair` class instead of `org.apache.commons.lang3.tuple.Pair` - Add a Checkstyle rule to ban `org.apache.commons.lang3.tuple` package ### Why are the changes needed? To be consistent with the Apache Spark main repository. - apache/spark#51568 Since Java 16, we can use `Records` officially in Java and Spark supports `Pair` via Java Record. | VERSION | JEP | | - | - | | Java 14 | [JEP 359: Records (Preview)](https://openjdk.org/jeps/359) | | Java 15 | [JEP 384: Records (Second Preview)](https://openjdk.org/jeps/384) | | Java 16 | [JEP 395: Records](https://openjdk.org/jeps/395) | ### Does this PR introduce _any_ user-facing change? No behavior change. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #368 from dongjoon-hyun/SPARK-53817. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 5eed495 commit 27f0baf

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

config/checkstyle/checkstyle.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
<property name="illegalPkgs" value="org.apache.log4j"/>
205205
<property name="illegalPkgs" value="org.apache.commons.lang"/>
206206
<property name="illegalPkgs" value="org.apache.commons.collections"/>
207+
<property name="illegalPkgs" value="org.apache.commons.lang3.tuple" />
207208
</module>
208209
</module>
209210
</module>

spark-operator/src/main/java/org/apache/spark/k8s/operator/metrics/source/KubernetesMetricsInterceptor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
import com.codahale.metrics.MetricRegistry;
3636
import io.fabric8.kubernetes.client.http.*;
3737
import lombok.extern.slf4j.Slf4j;
38-
import org.apache.commons.lang3.tuple.Pair;
3938

4039
import org.apache.spark.metrics.source.Source;
40+
import org.apache.spark.util.Pair;
4141

4242
/** Interceptor for Kubernetes client to collect metrics. */
4343
@Slf4j
@@ -174,9 +174,9 @@ private void updateRequestMetrics(HttpRequest request) {
174174
parseNamespaceScopedResource(request.uri().getPath());
175175
resourceNamePairOptional.ifPresent(
176176
pair -> {
177-
getMeterByRequestMethodAndResourceName(pair.getValue(), request.method()).mark();
177+
getMeterByRequestMethodAndResourceName(pair.getRight(), request.method()).mark();
178178
getMeterByRequestMethodAndResourceName(
179-
pair.getKey() + "." + pair.getValue(), request.method())
179+
pair.getLeft() + "." + pair.getRight(), request.method())
180180
.mark();
181181
});
182182
}

0 commit comments

Comments
 (0)