Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

void touchFile() should return the boolean result of the setLastModified

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


Peter_Lenahan at ibi

Nov 3, 2009, 5:05 PM

Post #1 of 3 (155 views)
Permalink
void touchFile() should return the boolean result of the setLastModified

This is an issue found by Findbugs.
In the file FSDirectory the method void touchFile() should return the boolean result of the setLastModified method call.


public abstract class FSDirectory extends Directory {


@Override
public void touchFile(String name) {
ensureOpen();
File file = new File(directory, name);
file.setLastModified(System.currentTimeMillis());
}

Because this class is abstract this method may be overridden, and this may create an upward compatibility issue.


Suggested change

@Override
public Boolean touchFile(String name) {
ensureOpen();
File file = new File(directory, name);
Return file.setLastModified(System.currentTimeMillis());
}


lucene at mikemccandless

Nov 4, 2009, 2:08 AM

Post #2 of 3 (134 views)
Permalink
Re: void touchFile() should return the boolean result of the setLastModified [In reply to]

I agree it's not great that touchFile swallows the return status from
File.setLastModified, but, technically changing it would break our jar
drop-in back compat.

Actually, I think instead, we should deprecate the method? As best I
can tell, Lucene does not use this anywhere.

I'll open an issue, but I think we have to wait for 3.1 (we're trying
not to add new deprecations in 3.0).

Mike

On Tue, Nov 3, 2009 at 8:05 PM, <Peter_Lenahan[at]ibi.com> wrote:
> This is an issue found by Findbugs.
> In the file FSDirectory the method void touchFile() should return the boolean result of the setLastModified method call.
>
>
> public abstract class FSDirectory extends Directory {
>
>
> @Override
>  public void touchFile(String name) {
>    ensureOpen();
>    File file = new File(directory, name);
>    file.setLastModified(System.currentTimeMillis());
>  }
>
> Because this class is abstract this method may be overridden, and this may create an upward compatibility issue.
>
>
> Suggested change
>
> @Override
>  public Boolean touchFile(String name) {
>    ensureOpen();
>    File file = new File(directory, name);
>    Return file.setLastModified(System.currentTimeMillis());
>  }
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org


uwe at thetaphi

Nov 4, 2009, 7:52 AM

Post #3 of 3 (127 views)
Permalink
RE: void touchFile() should return the boolean result of the setLastModified [In reply to]

We discussed about this method yesterday in the evening. The abstract base
class defines the method as throwing an IOException. So the correct
behaviour would be to throw an IOException if setLastModified returns false
(which happens according to the docs, if the date cannot be changed because
of an IO/FS prob).

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe[at]thetaphi.de


> -----Original Message-----
> From: Michael McCandless [mailto:lucene[at]mikemccandless.com]
> Sent: Wednesday, November 04, 2009 2:09 AM
> To: java-user[at]lucene.apache.org
> Subject: Re: void touchFile() should return the boolean result of the
> setLastModified
>
> I agree it's not great that touchFile swallows the return status from
> File.setLastModified, but, technically changing it would break our jar
> drop-in back compat.
>
> Actually, I think instead, we should deprecate the method? As best I
> can tell, Lucene does not use this anywhere.
>
> I'll open an issue, but I think we have to wait for 3.1 (we're trying
> not to add new deprecations in 3.0).
>
> Mike
>
> On Tue, Nov 3, 2009 at 8:05 PM, <Peter_Lenahan[at]ibi.com> wrote:
> > This is an issue found by Findbugs.
> > In the file FSDirectory the method void touchFile() should return the
> boolean result of the setLastModified method call.
> >
> >
> > public abstract class FSDirectory extends Directory {
> >
> >
> > @Override
> >  public void touchFile(String name) {
> >    ensureOpen();
> >    File file = new File(directory, name);
> >    file.setLastModified(System.currentTimeMillis());
> >  }
> >
> > Because this class is abstract this method may be overridden, and this
> may create an upward compatibility issue.
> >
> >
> > Suggested change
> >
> > @Override
> >  public Boolean touchFile(String name) {
> >    ensureOpen();
> >    File file = new File(directory, name);
> >    Return file.setLastModified(System.currentTimeMillis());
> >  }
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
> For additional commands, e-mail: java-user-help[at]lucene.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.