-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[CORE][MINOR]Closes stream and releases any system resources associated with this stream #18522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,7 +212,7 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with Logging { | |
| Random.nextBytes(bytes) | ||
|
|
||
| val os = new ByteArrayOutputStream() | ||
| Utils.copyStream(new ByteArrayInputStream(bytes), os) | ||
| Utils.copyStream(new ByteArrayInputStream(bytes), os, true) | ||
|
|
||
| assert(os.toByteArray.toList.equals(bytes.toList)) | ||
| } | ||
|
|
@@ -488,7 +488,7 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with Logging { | |
|
|
||
| test("resolveURIs with multiple paths") { | ||
| def assertResolves(before: String, after: String): Unit = { | ||
| assume(before.split(",").length > 1) | ||
| assume(before.split(",").length >= 1) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, why do we fix this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When running UtilsSuite, the following warning occurred: Test Canceled: 1 was not greater than 1 |
||
| def resolve(uri: String): String = Utils.resolveURIs(uri) | ||
| assert(resolve(before) === after) | ||
| assert(resolve(after) === after) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK this inputStream is passed from outside, like
process.getInputStreaminExecutorRunner, so I don't think we should close the inputStream here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,you are right.
But this function is only used in
ExecutorRunner, also if an exception occurs within this function,this will ensure the inputStream is closedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The another reason is that this function runs in another thread
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't be closed here, because the lifecycle of this stream is outside of this class. In practice, the streams used with this class are closed on error anyway.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I referred to
DriverRunner:DriverRunner-->runDriver-->redirectStream-->copyStream, the inputStream is closed in
copyStream.