Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[SPARK-49842][BUILD] Add byte-buddy dependency for modules that depend on mockito-core to ensure sbt test uses the correct byte-buddy with Java 21 #48281

Closed
wants to merge 5 commits into from

Conversation

LuciferYang
Copy link
Contributor

@LuciferYang LuciferYang commented Sep 27, 2024

What changes were proposed in this pull request?

This pr add byte-buddy dependency for modules that depend on mockito-core to ensure sbt test uses the correct byte-buddy

Why are the changes needed?

To ensure that sbt test can use the correct version of byte-buddy, I have only observed this issue when using sbt test with Java 21. This issue has not been observed when using sbt test with Java 17(Perhaps it just didn't print the Warning Message) or maven test with Java 17/21(Maven can confirm that there is no such issue).

Java 21 sbt daily test:

WARNING: A Java agent has been loaded dynamically (/home/runner/.cache/coursier/v1/https/maven-central.storage-download.googleapis.com/maven2/net/bytebuddy/byte-buddy-agent/1.14.15/byte-buddy-agent-1.14.15.jar)
WARNING: A Java agent has been loaded dynamically (/home/runner/.cache/coursier/v1/https/maven-central.storage-download.googleapis.com/maven2/net/bytebuddy/byte-buddy-agent/1.14.15/byte-buddy-agent-1.14.15.jar)
WARNING: A Java agent has been loaded dynamically (/home/runner/.cache/coursier/v1/https/maven-central.storage-download.googleapis.com/maven2/net/bytebuddy/byte-buddy-agent/1.14.15/byte-buddy-agent-1.14.15.jar)

We can see that byte-buddy-agent-1.14.15.jar is being used in the sbt tests with Java 21, but the version defined in the dependencyManagement of the parent pom.xml is 1.14.17:

spark/pom.xml

Lines 1221 to 1231 in 3093ad6

<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.14.17</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>1.14.17</version>
<scope>test</scope>

Inconsistent dependency versions pose potential risks, such as the possibility that maven tests may pass while sbt tests may fail. Therefore, we should correct it.Meanwhile, for consistency, I have added a test dependency on byte-buddy for all modules that depend on mockito-core.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Was this patch authored or co-authored using generative AI tooling?

No

@LuciferYang LuciferYang changed the title [WIP] Test the correct loading of byte-buddy [WIP][BUILD] Test the correct loading of byte-buddy Sep 27, 2024
@LuciferYang LuciferYang changed the title [WIP][BUILD] Test the correct loading of byte-buddy [SPARK-49842][BUILD] Test the correct loading of byte-buddy Oct 1, 2024
@LuciferYang LuciferYang changed the title [SPARK-49842][BUILD] Test the correct loading of byte-buddy [SPARK-49842][BUILD] Add byte-buddy dependency for modules that depend on mockito-core to ensure sbt test uses the correct byte-buddy with Java 21 Oct 1, 2024
@github-actions github-actions bot removed the INFRA label Oct 1, 2024
@LuciferYang LuciferYang marked this pull request as ready for review October 1, 2024 15:50
@LuciferYang
Copy link
Contributor Author

Merged into master for Spark 4.0. Thanks @HyukjinKwon

himadripal pushed a commit to himadripal/spark that referenced this pull request Oct 19, 2024
…end on `mockito-core` to ensure `sbt test` uses the correct `byte-buddy` with Java 21

### What changes were proposed in this pull request?
This pr add `byte-buddy` dependency for modules that depend on `mockito-core` to ensure `sbt test` uses the correct `byte-buddy`

### Why are the changes needed?
To ensure that `sbt test` can use the correct version of `byte-buddy`, I have only observed this issue when using `sbt test` with Java 21. This issue has not been observed when using `sbt test` with Java 17(Perhaps it just didn't print the Warning Message) or `maven test` with Java 17/21(Maven can confirm that there is no such issue).

Java 21 sbt daily test:

- https://github.com/apache/spark/actions/runs/11099131939/job/30881044324

```
WARNING: A Java agent has been loaded dynamically (/home/runner/.cache/coursier/v1/https/maven-central.storage-download.googleapis.com/maven2/net/bytebuddy/byte-buddy-agent/1.14.15/byte-buddy-agent-1.14.15.jar)
```

- https://github.com/apache/spark/actions/runs/11099131939/job/30881045891

```
WARNING: A Java agent has been loaded dynamically (/home/runner/.cache/coursier/v1/https/maven-central.storage-download.googleapis.com/maven2/net/bytebuddy/byte-buddy-agent/1.14.15/byte-buddy-agent-1.14.15.jar)
```

- https://github.com/apache/spark/actions/runs/11099131939/job/30881047740

```
WARNING: A Java agent has been loaded dynamically (/home/runner/.cache/coursier/v1/https/maven-central.storage-download.googleapis.com/maven2/net/bytebuddy/byte-buddy-agent/1.14.15/byte-buddy-agent-1.14.15.jar)
```

We can see that `byte-buddy-agent-1.14.15.jar` is being used in the sbt tests with Java 21, but the version defined in the `dependencyManagement` of the parent `pom.xml` is `1.14.17`:

https://github.com/apache/spark/blob/3093ad68d2a3c6bab9c1605381d27e700766be22/pom.xml#L1221-L1231

Inconsistent dependency versions pose potential risks, such as the possibility that maven tests may pass while sbt tests may fail. Therefore, we should correct it.Meanwhile, for consistency, I have added a test dependency on `byte-buddy` for all modules that depend on `mockito-core`.

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
- Pass GitHub Actions
- Manual inspection shows that `sbt test` with Java 21 is using version 1.14.17 of `byte-buddy-agent`

  - https://github.com/LuciferYang/spark/actions/runs/11072600528/job/30922654197
  - https://github.com/LuciferYang/spark/actions/runs/11072600528/job/30922654969
  - https://github.com/LuciferYang/spark/actions/runs/11072600528/job/30922655852
  - https://github.com/LuciferYang/spark/actions/runs/11072600528/job/30922656840

  ```
  WARNING: A Java agent has been loaded dynamically (/home/runner/.cache/coursier/v1/https/maven-central.storage-download.googleapis.com/maven2/net/bytebuddy/byte-buddy-agent/1.14.17/byte-buddy-agent-1.14.17.jar)
  ```

### Was this patch authored or co-authored using generative AI tooling?
No

Closes apache#48281 from LuciferYang/byte-buddy.

Lead-authored-by: yangjie01 <yangjie01@baidu.com>
Co-authored-by: YangJie <yangjie01@baidu.com>
Signed-off-by: yangjie01 <yangjie01@baidu.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants