Github user srowen commented on the pull request:

    https://github.com/apache/spark/pull/10289#issuecomment-164740892
  
    @holdenk yeah I think that explains the problem in `BlockManagerSuite`, 
good catch. I'm not sure why the other one is a problem though; not overriding 
`afterEach` is fine as it means the superclass method does execute. Maybe that 
one isn't actually a problem @kiszk?
    
    The general form of these overrides should be to run superclass init first, 
and superclass cleanup after:
    
    ```
    override def beforeEach(): Unit = {
      super.beforeEach()
      ... init here ...
    }
    
    override def afterEach(): Unit = {
      try {
        ... cleanup here ...
      } finally {
        super.afterEach()
      }
    }
    ```
    
    Same for `beforeAll()` and `afterAll()`. _The `try-finally` isn't necessary 
if the cleanup really can't generate an exception._
    
    We have a number of instances where this isn't done quite right across the 
code base,. AFAICT most don't matter. It's not that many though. @kiszk what do 
you think about correcting this pattern everywhere to head off potential bugs 
of this form later?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to