You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Michael McCandless <lu...@mikemccandless.com> on 2007/10/03 13:37:45 UTC

adding "throws IOException" to RAMDirectory.createOutput?

Hi,

As part of LUCENE-1011, I'd like to add "throws IOException" to
RAMDirectory.createOutput.

It is technically an API change since it's a checked exception and
people may need to change source code in their apps.  However, I
expect very few apps would actually be affected, because the super
(Directory.createOutput) already throws IOException so it's only
apps that directly call RAMDirectory.createOutput that may need to
change.  EG the common use of using RAMDirectory for holding your
index would be unaffected by this.

I'd like to do this because MockRAMDirectory, which subclasses
RAMDirectory and is very useful for testing because it "simulates"
windows behavior of not overwriting an open file, needs to be able to
throw IOException from its createOutput.  I was previously throwing
RuntimeException from MockRAMDirectory, but this is causing some tests
to fail because that RuntimeException is not expected by Lucene.

Any objections?

The only alternative I can think of is to turn off this windows-like
behavior for certain tests (don't like that because it "weakens" these
tests), or, change MockRAMDirectory to subclass directly from
Directory (don't like that because then I'm copying alot of code from
RAMDirectory).

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: adding "throws IOException" to RAMDirectory.createOutput?

Posted by Michael McCandless <lu...@mikemccandless.com>.
"Yonik Seeley" <yo...@apache.org> wrote:
> On 10/3/07, Michael McCandless <lu...@mikemccandless.com> wrote:
> > As part of LUCENE-1011, I'd like to add "throws IOException" to
> > RAMDirectory.createOutput.
> >
> > It is technically an API change since it's a checked exception and
> > people may need to change source code in their apps.  However, I
> > expect very few apps would actually be affected, because the super
> > (Directory.createOutput) already throws IOException so it's only
> > apps that directly call RAMDirectory.createOutput that may need to
> > change.  EG the common use of using RAMDirectory for holding your
> > index would be unaffected by this.
> 
> Seems fine.  It seems like in general, subclasses should retain the
> exception signature of superclass methods even if they don't currently
> throw that exception (some of those were removed in the past).

Agreed.

OK I will commit.

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: adding "throws IOException" to RAMDirectory.createOutput?

Posted by Yonik Seeley <yo...@apache.org>.
On 10/3/07, Michael McCandless <lu...@mikemccandless.com> wrote:
> As part of LUCENE-1011, I'd like to add "throws IOException" to
> RAMDirectory.createOutput.
>
> It is technically an API change since it's a checked exception and
> people may need to change source code in their apps.  However, I
> expect very few apps would actually be affected, because the super
> (Directory.createOutput) already throws IOException so it's only
> apps that directly call RAMDirectory.createOutput that may need to
> change.  EG the common use of using RAMDirectory for holding your
> index would be unaffected by this.

Seems fine.  It seems like in general, subclasses should retain the
exception signature of superclass methods even if they don't currently
throw that exception (some of those were removed in the past).

-Yonik

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: adding "throws IOException" to RAMDirectory.createOutput?

Posted by Michael Busch <bu...@gmail.com>.
Michael McCandless wrote:
> 
> As part of LUCENE-1011, I'd like to add "throws IOException" to
> RAMDirectory.createOutput.
> 

+1

- Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org