Skip to content

Conversation

@10110346
Copy link
Contributor

@10110346 10110346 commented Jul 4, 2017

What changes were proposed in this pull request?

Closes inputstream or outputstream and releases any system resources associated
with the stream.

How was this patch tested?

unit test

} {
closeFile()
try {
inputStream.close()
Copy link
Contributor

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.getInputStream in ExecutorRunner, so I don't think we should close the inputStream here.

Copy link
Contributor Author

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 closed

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

@10110346 10110346 Jul 4, 2017

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.

@SparkQA
Copy link

SparkQA commented Jul 4, 2017

Test build #79120 has finished for PR 18522 at commit c0cf41d.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

test("resolveURIs with multiple paths") {
def assertResolves(before: String, after: String): Unit = {
assume(before.split(",").length > 1)
assume(before.split(",").length >= 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, why do we fix this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
org.scalatest.exceptions.TestCanceledException: 1 was not greater than 1
at org.scalatest.Assertions$class.newTestCanceledException(Assertions.scala:511)
at org.scalatest.FunSuite.newTestCanceledException(FunSuite.scala:1555)
at org.scalatest.Assertions$AssertionsHelper.macroAssume(Assertions.scala:481)
at org.apache.spark.util.UtilsSuite$$anonfun$19.assertResolves$2(UtilsSuite.scala:491)
at org.apache.spark.util.UtilsSuite$$anonfun$19.apply$mcV$sp(UtilsSuite.scala:512)
at org.apache.spark.util.UtilsSuite$$anonfun$19.apply(UtilsSuite.scala:489)
at org.apache.spark.util.UtilsSuite$$anonfun$19.apply(UtilsSuite.scala:489)

@10110346 10110346 changed the title [MINOR]Closes stream and releases any system resources associated with this stream [CORE][MINOR]Closes stream and releases any system resources associated with this stream Jul 31, 2017
@10110346
Copy link
Contributor Author

process.getInputStream is closed in driverRunner, but it is not closed in ExecutorRunner.
Which approach is correct? @jiangxb1987 @srowen

@srowen
Copy link
Member

srowen commented Jul 31, 2017

I suspect that this doesn't hurt, because at the point you stop copying input to a file, you are done with the input, and I don't think there is any reason that the caller would ever continue reading it elsewhere. That said, the process is already terminated correctly in this case, which closes the streams too. I'm neutral on it unless this is theoretically solving a problem.

@10110346
Copy link
Contributor Author

Thanks @srowen
I think it's better to keep the same in driverRunner and ExecutorRunner . @cloud-fan

@srowen
Copy link
Member

srowen commented Aug 20, 2017

I'm not sure that this solves a problem, and has some changes that look unrelated

srowen added a commit to srowen/spark that referenced this pull request Sep 12, 2017
@srowen srowen mentioned this pull request Sep 12, 2017
@asfgit asfgit closed this in dd88fa3 Sep 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants