You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "zhengruifeng (via GitHub)" <gi...@apache.org> on 2025/11/24 10:42:24 UTC
[PR] [SPARK-54115][TESTS][FOLLOW-UP] Refine `org.apache.spark.util.UtilsSuite` [spark]
zhengruifeng opened a new pull request, #53192:
URL: https://github.com/apache/spark/pull/53192
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'common/utils/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
### Why are the changes needed?
> Use doReturn() in those rare occasions when you cannot use when(Object)
`when` is preferred in the official doc https://javadoc.io/static/org.mockito/mockito-core/5.12.0/org/mockito/Mockito.html#when(T)
### Does this PR introduce _any_ user-facing change?
no, test-only
### How was this patch tested?
ci
### Was this patch authored or co-authored using generative AI tooling?
no
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54115][TESTS][FOLLOW-UP] Refine `org.apache.spark.util.UtilsSuite` [spark]
Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #53192:
URL: https://github.com/apache/spark/pull/53192#discussion_r2558689617
##########
core/src/test/scala/org/apache/spark/util/UtilsSuite.scala:
##########
@@ -1132,37 +1131,35 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with PrivateMe
test("ThreadInfoOrdering") {
val task1T = mock[ThreadInfo]
- doReturn(11L).when(task1T).getThreadId
- doReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
- .when(task1T).getThreadName
- doReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
- .when(task1T).toString
+ when(task1T.getThreadId).thenReturn(11L)
+ when(task1T.getThreadName)
+ .thenReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
+ when(task1T.toString)
+ .thenReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
val task2T = mock[ThreadInfo]
- doReturn(12L).when(task2T).getThreadId
- doReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
- .when(task2T).getThreadName
- doReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
- .when(task2T).toString
+ when(task2T.getThreadId).thenReturn(12L)
+ when(task2T.getThreadName)
+ .thenReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
+ when(task2T.toString)
+ .thenReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
val connectExecuteOp1T = mock[ThreadInfo]
- doReturn(21L).when(connectExecuteOp1T).getThreadId
- doReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
- .when(connectExecuteOp1T).getThreadName
- doReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
- .when(connectExecuteOp1T).toString
+ when(connectExecuteOp1T.getThreadId).thenReturn(21L)
+ when(connectExecuteOp1T.getThreadName)
+ .thenReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
+ when(connectExecuteOp1T.toString)
+ .thenReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
val connectExecuteOp2T = mock[ThreadInfo]
- doReturn(22L).when(connectExecuteOp2T).getThreadId
- doReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
- .when(connectExecuteOp2T).getThreadName
- doReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
- .when(connectExecuteOp2T).toString
-
- val threadInfoOrderingMethod =
- PrivateMethod[Ordering[ThreadInfo]](Symbol("threadInfoOrdering"))
+ when(connectExecuteOp2T.getThreadId).thenReturn(22L)
+ when(connectExecuteOp2T.getThreadName)
+ .thenReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
+ when(connectExecuteOp2T.toString)
+ .thenReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
+
val sorted = Seq(connectExecuteOp1T, connectExecuteOp2T, task1T, task2T)
- .sorted(Utils.invokePrivate(threadInfoOrderingMethod()))
+ .sorted(Utils.threadInfoOrdering)
Review Comment:
Hmm... this looks simple, but I was told to prefer using `invokePrivate` to avoid exposing private methods/fields, not sure which is the best practice for this case.
cc @LuciferYang for more inputs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54115][TESTS][FOLLOW-UP] Refine `org.apache.spark.util.UtilsSuite` [spark]
Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #53192:
URL: https://github.com/apache/spark/pull/53192#discussion_r2558769075
##########
core/src/test/scala/org/apache/spark/util/UtilsSuite.scala:
##########
@@ -1132,37 +1131,35 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with PrivateMe
test("ThreadInfoOrdering") {
val task1T = mock[ThreadInfo]
- doReturn(11L).when(task1T).getThreadId
- doReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
- .when(task1T).getThreadName
- doReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
- .when(task1T).toString
+ when(task1T.getThreadId).thenReturn(11L)
+ when(task1T.getThreadName)
+ .thenReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
+ when(task1T.toString)
+ .thenReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
val task2T = mock[ThreadInfo]
- doReturn(12L).when(task2T).getThreadId
- doReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
- .when(task2T).getThreadName
- doReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
- .when(task2T).toString
+ when(task2T.getThreadId).thenReturn(12L)
+ when(task2T.getThreadName)
+ .thenReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
+ when(task2T.toString)
+ .thenReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
val connectExecuteOp1T = mock[ThreadInfo]
- doReturn(21L).when(connectExecuteOp1T).getThreadId
- doReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
- .when(connectExecuteOp1T).getThreadName
- doReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
- .when(connectExecuteOp1T).toString
+ when(connectExecuteOp1T.getThreadId).thenReturn(21L)
+ when(connectExecuteOp1T.getThreadName)
+ .thenReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
+ when(connectExecuteOp1T.toString)
+ .thenReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
val connectExecuteOp2T = mock[ThreadInfo]
- doReturn(22L).when(connectExecuteOp2T).getThreadId
- doReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
- .when(connectExecuteOp2T).getThreadName
- doReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
- .when(connectExecuteOp2T).toString
-
- val threadInfoOrderingMethod =
- PrivateMethod[Ordering[ThreadInfo]](Symbol("threadInfoOrdering"))
+ when(connectExecuteOp2T.getThreadId).thenReturn(22L)
+ when(connectExecuteOp2T.getThreadName)
+ .thenReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
+ when(connectExecuteOp2T.toString)
+ .thenReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
+
val sorted = Seq(connectExecuteOp1T, connectExecuteOp2T, task1T, task2T)
- .sorted(Utils.invokePrivate(threadInfoOrderingMethod()))
+ .sorted(Utils.threadInfoOrdering)
Review Comment:
This appears to be a new piece of code from the 4.1 cycle rather than legacy code. If we also consider it acceptable for third-party libraries to use `threadInfoOrdering` within the `spark` package, then this modification is acceptable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54115][TESTS][FOLLOW-UP] Refine `org.apache.spark.util.UtilsSuite` [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #53192:
URL: https://github.com/apache/spark/pull/53192#discussion_r2558743718
##########
core/src/test/scala/org/apache/spark/util/UtilsSuite.scala:
##########
@@ -1132,37 +1131,35 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with PrivateMe
test("ThreadInfoOrdering") {
val task1T = mock[ThreadInfo]
- doReturn(11L).when(task1T).getThreadId
- doReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
- .when(task1T).getThreadName
- doReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
- .when(task1T).toString
+ when(task1T.getThreadId).thenReturn(11L)
+ when(task1T.getThreadName)
+ .thenReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
+ when(task1T.toString)
+ .thenReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
val task2T = mock[ThreadInfo]
- doReturn(12L).when(task2T).getThreadId
- doReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
- .when(task2T).getThreadName
- doReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
- .when(task2T).toString
+ when(task2T.getThreadId).thenReturn(12L)
+ when(task2T.getThreadName)
+ .thenReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
+ when(task2T.toString)
+ .thenReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
val connectExecuteOp1T = mock[ThreadInfo]
- doReturn(21L).when(connectExecuteOp1T).getThreadId
- doReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
- .when(connectExecuteOp1T).getThreadName
- doReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
- .when(connectExecuteOp1T).toString
+ when(connectExecuteOp1T.getThreadId).thenReturn(21L)
+ when(connectExecuteOp1T.getThreadName)
+ .thenReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
+ when(connectExecuteOp1T.toString)
+ .thenReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
val connectExecuteOp2T = mock[ThreadInfo]
- doReturn(22L).when(connectExecuteOp2T).getThreadId
- doReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
- .when(connectExecuteOp2T).getThreadName
- doReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
- .when(connectExecuteOp2T).toString
-
- val threadInfoOrderingMethod =
- PrivateMethod[Ordering[ThreadInfo]](Symbol("threadInfoOrdering"))
+ when(connectExecuteOp2T.getThreadId).thenReturn(22L)
+ when(connectExecuteOp2T.getThreadName)
+ .thenReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
+ when(connectExecuteOp2T.toString)
+ .thenReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
+
val sorted = Seq(connectExecuteOp1T, connectExecuteOp2T, task1T, task2T)
- .sorted(Utils.invokePrivate(threadInfoOrderingMethod()))
+ .sorted(Utils.threadInfoOrdering)
Review Comment:
`private[spark]` is not public.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54115][TESTS][FOLLOW-UP] Refine `org.apache.spark.util.UtilsSuite` [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #53192: [SPARK-54115][TESTS][FOLLOW-UP] Refine `org.apache.spark.util.UtilsSuite`
URL: https://github.com/apache/spark/pull/53192
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54115][TESTS][FOLLOW-UP] Refine `org.apache.spark.util.UtilsSuite` [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #53192:
URL: https://github.com/apache/spark/pull/53192#discussion_r2558797125
##########
core/src/test/scala/org/apache/spark/util/UtilsSuite.scala:
##########
@@ -1132,37 +1131,35 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with PrivateMe
test("ThreadInfoOrdering") {
val task1T = mock[ThreadInfo]
- doReturn(11L).when(task1T).getThreadId
- doReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
- .when(task1T).getThreadName
- doReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
- .when(task1T).toString
+ when(task1T.getThreadId).thenReturn(11L)
+ when(task1T.getThreadName)
+ .thenReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
+ when(task1T.toString)
+ .thenReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
val task2T = mock[ThreadInfo]
- doReturn(12L).when(task2T).getThreadId
- doReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
- .when(task2T).getThreadName
- doReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
- .when(task2T).toString
+ when(task2T.getThreadId).thenReturn(12L)
+ when(task2T.getThreadName)
+ .thenReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
+ when(task2T.toString)
+ .thenReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
val connectExecuteOp1T = mock[ThreadInfo]
- doReturn(21L).when(connectExecuteOp1T).getThreadId
- doReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
- .when(connectExecuteOp1T).getThreadName
- doReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
- .when(connectExecuteOp1T).toString
+ when(connectExecuteOp1T.getThreadId).thenReturn(21L)
+ when(connectExecuteOp1T.getThreadName)
+ .thenReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
+ when(connectExecuteOp1T.toString)
+ .thenReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
val connectExecuteOp2T = mock[ThreadInfo]
- doReturn(22L).when(connectExecuteOp2T).getThreadId
- doReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
- .when(connectExecuteOp2T).getThreadName
- doReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
- .when(connectExecuteOp2T).toString
-
- val threadInfoOrderingMethod =
- PrivateMethod[Ordering[ThreadInfo]](Symbol("threadInfoOrdering"))
+ when(connectExecuteOp2T.getThreadId).thenReturn(22L)
+ when(connectExecuteOp2T.getThreadName)
+ .thenReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
+ when(connectExecuteOp2T.toString)
+ .thenReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
+
val sorted = Seq(connectExecuteOp1T, connectExecuteOp2T, task1T, task2T)
- .sorted(Utils.invokePrivate(threadInfoOrderingMethod()))
+ .sorted(Utils.threadInfoOrdering)
Review Comment:
third-party lib can do whatever they want using reflection, the point is what Spark guarantees/promises. Apparently, there is no compatibility guarantee/promise for `private[spark]` APIs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54115][TESTS][FOLLOW-UP] Refine `org.apache.spark.util.UtilsSuite` [spark]
Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #53192:
URL: https://github.com/apache/spark/pull/53192#issuecomment-3570938408
The AQE test failure is unrelated, thanks, merging to master/4.1!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-54115][TESTS][FOLLOW-UP] Refine `org.apache.spark.util.UtilsSuite` [spark]
Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #53192:
URL: https://github.com/apache/spark/pull/53192#discussion_r2558802855
##########
core/src/test/scala/org/apache/spark/util/UtilsSuite.scala:
##########
@@ -1132,37 +1131,35 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with PrivateMe
test("ThreadInfoOrdering") {
val task1T = mock[ThreadInfo]
- doReturn(11L).when(task1T).getThreadId
- doReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
- .when(task1T).getThreadName
- doReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
- .when(task1T).toString
+ when(task1T.getThreadId).thenReturn(11L)
+ when(task1T.getThreadName)
+ .thenReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
+ when(task1T.toString)
+ .thenReturn("Executor task launch worker for task 1.0 in stage 1.0 (TID 11)")
val task2T = mock[ThreadInfo]
- doReturn(12L).when(task2T).getThreadId
- doReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
- .when(task2T).getThreadName
- doReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
- .when(task2T).toString
+ when(task2T.getThreadId).thenReturn(12L)
+ when(task2T.getThreadName)
+ .thenReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
+ when(task2T.toString)
+ .thenReturn("Executor task launch worker for task 2.0 in stage 1.0 (TID 22)")
val connectExecuteOp1T = mock[ThreadInfo]
- doReturn(21L).when(connectExecuteOp1T).getThreadId
- doReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
- .when(connectExecuteOp1T).getThreadName
- doReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
- .when(connectExecuteOp1T).toString
+ when(connectExecuteOp1T.getThreadId).thenReturn(21L)
+ when(connectExecuteOp1T.getThreadName)
+ .thenReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
+ when(connectExecuteOp1T.toString)
+ .thenReturn("SparkConnectExecuteThread_opId=16148fb4-4189-43c3-b8d4-8b3b6ddd41c7")
val connectExecuteOp2T = mock[ThreadInfo]
- doReturn(22L).when(connectExecuteOp2T).getThreadId
- doReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
- .when(connectExecuteOp2T).getThreadName
- doReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
- .when(connectExecuteOp2T).toString
-
- val threadInfoOrderingMethod =
- PrivateMethod[Ordering[ThreadInfo]](Symbol("threadInfoOrdering"))
+ when(connectExecuteOp2T.getThreadId).thenReturn(22L)
+ when(connectExecuteOp2T.getThreadName)
+ .thenReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
+ when(connectExecuteOp2T.toString)
+ .thenReturn("SparkConnectExecuteThread_opId=4e4d1cac-ffde-46c1-b7c2-808b726cb47e")
+
val sorted = Seq(connectExecuteOp1T, connectExecuteOp2T, task1T, task2T)
- .sorted(Utils.invokePrivate(threadInfoOrderingMethod()))
+ .sorted(Utils.threadInfoOrdering)
Review Comment:
The reasoning is correct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org