Index: DataObjectPool.java
===================================================================
RCS file: /cvs/openide/src/org/openide/loaders/DataObjectPool.java,v
retrieving revision 1.33.2.3.6.1
diff -c -r1.33.2.3.6.1 DataObjectPool.java
*** DataObjectPool.java 2001/06/12 07:15:19 1.33.2.3.6.1
--- DataObjectPool.java 2001/06/15 18:55:09
***************
*** 65,74 ****
if (toNotify != null) {
return null;
}
synchronized (this) {
! Item doh = (Item)map.get (fo);
! return doh == null ? null : doh.getDataObjectOrNull ();
! }
}
--- 65,98 ----
if (toNotify != null) {
return null;
}
+ Item doh = null;
+ DataObject rval = null;
synchronized (this) {
! doh = (Item)map.get (fo);
! if ( doh == null
! || (rval = doh.getDataObjectOrNull()) == null) {
! return null;
! }
! }
! synchronized (doh) {
! while (!doh.initialized) {
! try {
! doh.wait();
! } catch (InterruptedException e) {
! break;
! }
! }
! }
! return rval;
! }
!
! public void createFinished(DataObject obj) {
! Item doh = obj.item;
!
! synchronized (doh) {
! doh.initialized = true;
! doh.notifyAll();
! }
}
***************
*** 90,96 ****
DataLoader.RecognizedFiles rec
) throws IOException {
try {
! return loader.handleFindDataObject(fo, rec);
} catch (IOException ioe) {
throw ioe;
} catch (ThreadDeath td) {
--- 114,132 ----
DataLoader.RecognizedFiles rec
) throws IOException {
try {
! DataObject rval;
! Item doh;
!
! rval = loader.handleFindDataObject(fo, rec);
! if (rval == null) {
! return null;
! }
! doh = rval.item;
! synchronized (doh) {
! doh.initialized = true;
! doh.notifyAll();
! }
! return rval;
} catch (IOException ioe) {
throw ioe;
} catch (ThreadDeath td) {
***************
*** 183,205 ****
* @return object with common information for this DataObject
* @exception DataObjectExistsException if the file object is already registered
*/
! public synchronized Item register (FileObject fo, DataLoader loader)
! throws DataObjectExistsException {
! Item doh = (Item)map.get (fo);
! // if Item for this file has not been created yet
! if (doh == null) {
! doh = new Item (fo);
! map.put (fo, doh);
! if (toNotify == null) {
! toNotify = new LinkedList ();
! }
! toNotify.add (doh);
! VALIDATOR.notifyRegistered (fo);
!
! return doh;
! } else {
! DataObject obj = doh.getDataObjectOrNull ();
if (obj == null || VALIDATOR.reregister (obj, loader)) {
// the item is to be finalize => create new
--- 219,250 ----
* @return object with common information for this DataObject
* @exception DataObjectExistsException if the file object is already registered
*/
! static int serial=0;
! public Item register (FileObject fo, DataLoader loader)
! throws DataObjectExistsException {
! Item doh = null;
! DataObject obj = null;
! int seq = 0;
!
! synchronized (this) {
!
!
! doh = (Item)map.get (fo);
! // if Item for this file has not been created yet
! if (doh == null) {
! doh = new Item (fo);
! map.put (fo, doh);
! if (toNotify == null) {
! toNotify = new LinkedList ();
! }
! toNotify.add (doh);
!
! VALIDATOR.notifyRegistered (fo);
!
! return doh;
! }
! obj = doh.getDataObjectOrNull ();
if (obj == null || VALIDATOR.reregister (obj, loader)) {
// the item is to be finalize => create new
***************
*** 213,227 ****
return doh;
}
!
!
! // PENDING only for debug
! // System.err.println ("Original stack (" + doh.getDataObject () + "): ");
! // System.err.println (doh.toString ());
! // Thread.dumpStack();
! // throw exception with the existing data object
! throw new DataObjectExistsException (obj);
! }
}
/** Notifies all newly created objects to
--- 258,279 ----
return doh;
}
! }
! synchronized (doh) {
! while (!doh.initialized) {
! try {
! doh.wait();
! } catch (InterruptedException e) {
! break;
! }
! }
! }
! // PENDING only for debug
! // System.err.println ("Original stack (" + doh.getDataObject () + "): ");
! // System.err.println (doh.toString ());
! // Thread.dumpStack();
! // throw exception with the existing data object
! throw new DataObjectExistsException (obj);
}
/** Notifies all newly created objects to
***************
*** 364,369 ****
--- 416,422 ----
static final class Item extends Object implements Runnable {
/** primary file */
FileObject primaryFile;
+ boolean initialized = false;
/** weak reference data object with this primary file */
private Reference obj;