Lines 57-62
Link Here
|
57 |
import java.util.HashSet; |
57 |
import java.util.HashSet; |
58 |
import java.util.Map; |
58 |
import java.util.Map; |
59 |
import java.util.Set; |
59 |
import java.util.Set; |
|
|
60 |
import java.util.concurrent.CountDownLatch; |
60 |
import java.util.logging.Level; |
61 |
import java.util.logging.Level; |
61 |
import java.util.logging.Logger; |
62 |
import java.util.logging.Logger; |
62 |
import java.util.prefs.BackingStoreException; |
63 |
import java.util.prefs.BackingStoreException; |
Lines 127-132
Link Here
|
127 |
|
128 |
|
128 |
|
129 |
|
129 |
public Project getOwner(FileObject f) { |
130 |
public Project getOwner(FileObject f) { |
|
|
131 |
try { |
132 |
// wait until prefs deserialize |
133 |
externalLatch.await(); |
134 |
} catch (InterruptedException ex) { |
135 |
LOG.log(Level.INFO, ex.getMessage(), ex); |
136 |
} |
130 |
while (f != null) { |
137 |
while (f != null) { |
131 |
synchronized (this) { |
138 |
synchronized (this) { |
132 |
if (lastFoundKey != null && lastFoundKey.get() == f) { |
139 |
if (lastFoundKey != null && lastFoundKey.get() == f) { |
Lines 218-226
Link Here
|
218 |
private static final Map<URI,FileObject> deserializedExternalOwners = |
225 |
private static final Map<URI,FileObject> deserializedExternalOwners = |
219 |
Collections.synchronizedMap(new HashMap<URI,FileObject>()); |
226 |
Collections.synchronizedMap(new HashMap<URI,FileObject>()); |
220 |
|
227 |
|
|
|
228 |
/** |
229 |
* Latch released when the serialized external roots load. All file queries |
230 |
* must wait until the preferences reads. |
231 |
*/ |
232 |
private static final CountDownLatch externalLatch = new CountDownLatch(1); |
233 |
|
221 |
private static boolean externalRootsIncludeNonFolders = false; |
234 |
private static boolean externalRootsIncludeNonFolders = false; |
222 |
|
235 |
|
223 |
|
236 |
/** |
|
|
237 |
* Deserializes stored cross-reference of external files to their projects. |
238 |
* It is called from @OnStart, which runs asynchronously/in parallel, but |
239 |
* getOwner() queries require that the cross-ref is laoded so the answers are |
240 |
* consistent in time. |
241 |
*/ |
224 |
static void deserialize() { |
242 |
static void deserialize() { |
225 |
try { |
243 |
try { |
226 |
Preferences p = NbPreferences.forModule(SimpleFileOwnerQueryImplementation.class).node("externalOwners"); |
244 |
Preferences p = NbPreferences.forModule(SimpleFileOwnerQueryImplementation.class).node("externalOwners"); |
Lines 236-241
Link Here
|
236 |
NbPreferences.forModule(SimpleFileOwnerQueryImplementation.class).node("externalOwners").removeNode(); |
254 |
NbPreferences.forModule(SimpleFileOwnerQueryImplementation.class).node("externalOwners").removeNode(); |
237 |
} catch (BackingStoreException ex) { |
255 |
} catch (BackingStoreException ex) { |
238 |
LOG.log(Level.INFO, null, ex); |
256 |
LOG.log(Level.INFO, null, ex); |
|
|
257 |
} finally { |
258 |
externalLatch.countDown(); |
239 |
} |
259 |
} |
240 |
} |
260 |
} |
241 |
|
261 |
|