lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Friedman, Eric" <>
Subject RE: Locking problems
Date Wed, 12 Jun 2002 14:09:17 GMT
 I hasten to add that it's not terribly efficient to check this system
property every time lucene asks to obtain a lock.  Better would be to assign
a boolean once and then check that in the obtain() method. 

-----Original Message-----
From: Friedman, Eric
To: 'Stefan Bergstrand '; 'Lucene Developer '
Sent: 6/12/02 7:03 AM
Subject: RE: Locking problems


your locksDisabled() method is a reimplementation of functionality
provided by the Java SDK:

Boolean.getBoolean(String name)  does exactly what your method does:

Returns true if and only if the system property named by the argument
and is equal to the string "true".

-----Original Message-----
From: Stefan Bergstrand
To: Lucene Developer
Sent: 6/12/02 3:28 AM
Subject: Re: Locking problems

Ok, now I have fixed a way to turn locking off. Here is the modified
method in FSDirectory, and a helper method. Locking is turned off by
setting -DdisableLuceneLocks=true on the command line.

Thanks to Matt Tucker for pointing out the place where to modify.

/Stefan B

  /** Construct a {@link Lock}.
   * @param name the name of the lock file
  public final Lock makeLock(String name) {
    final File lockFile = new File(directory, name);
    return new Lock() {
	public boolean obtain() throws IOException {

	    if (locksDisabled()){
		return true;

	    if (Constants.JAVA_1_1) 
	      return true;    // locks disabled in jdk 1.1

	    return lockFile.createNewFile();
	public void release() {

	    if (locksDisabled()){

	    if (Constants.JAVA_1_1) 
	      return;         // locks disabled in jdk 1.1

	public String toString() {
	  return "Lock@" + lockFile;

  protected final boolean locksDisabled(){
      if (System.getProperty("disableLuceneLocks") == null){
	  return false;
      } else {

Stefan Bergstrand
Polopoly - Cultivating the information garden
Kungsgatan 88, SE-112 27 Stockholm, SWEDEN
Ph:   +46 8 506 782 67
Cell: +46 704 47 82 67,

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message