google-code-export / uimafit

Automatically exported from code.google.com/p/uimafit
2 stars 1 forks source link

HideOutput should not extend OutputStream #129

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, HideOutput extends OutputStream, adds an empty write method, and 
then passes itself to System.setOut and System.setErr. At the same time, 
expected usage of HideOutput is something like:

    HideOutput hider = new HideOutput();
    ... some noisy command ...
    hider.restoreOutput();

Since HideOutput is an OutputStream, it looks like we're failing to close an 
OutputStream, and newer versions of Eclipse flag this with a warning.

The solution is simple - just make a private instance of OutputStream that does 
nothing, use that instead of "this", and remove the "extends OutputStream". A 
patch along these lines is attached.

However, technically, this is backwards incompatible. If anyone had been using 
HideOutput as a null OutputStream, this would break their code. (That's not the 
recommended usage, or the example usage in tests, but you never know what 
people will do...)

So, what should we do here? 

Original issue reported on code.google.com by steven.b...@gmail.com on 20 Jul 2012 at 8:31

Attachments:

GoogleCodeExporter commented 9 years ago
I installed Eclipse 4.2 yesterday but I didn't see a warning here.

Other than that, I'd suggest to address this for the next major release.

Original comment by richard.eckart on 22 Jul 2012 at 10:24

GoogleCodeExporter commented 9 years ago
Ah, I see the warning now. Looks like that only shows up when opening a file 
that uses HideOutput.

Original comment by richard.eckart on 22 Jul 2012 at 10:25

GoogleCodeExporter commented 9 years ago
So is your vote to just break the inheritance, or ...?

Original comment by steven.b...@gmail.com on 22 Jul 2012 at 3:00

GoogleCodeExporter commented 9 years ago
Yep. There are several incompatible changes already on the list. At some point 
there are bound to be some intentional incompatible changes. 

Original comment by richard.eckart on 22 Jul 2012 at 3:04

GoogleCodeExporter commented 9 years ago
Ok. Fixed in r911.

Original comment by steven.b...@gmail.com on 23 Jul 2012 at 9:07