Skip to content

Commit d37c62a

Browse files
author
guillaume
committed
fix DrivesTaskManager when a new partition comes and the mount point was
already associated to the same drive resource
1 parent 0195819 commit d37c62a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net.lecousin.core/src/main/java/net/lecousin/framework/concurrent/DrivesTaskManager.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,18 @@ private void newPartition(Pair<Object,File> driveAndPartition) {
190190
synchronized (rootManagers) {
191191
previous = rootManagers.get(path);
192192
if (previous != null) {
193-
Threading.unregisterResource(rootResources.get(path));
194193
rootManagers.remove(path);
195194
rootResources.remove(path);
196195
rootManagers.put(path, tm);
197-
rootResources.put(path, drive);
196+
Object prevResource = rootResources.put(path, drive);
197+
if (!rootResources.containsValue(prevResource))
198+
Threading.unregisterResource(prevResource);
198199
} else {
199200
rootManagers.put(path, tm);
200201
rootResources.put(path, drive);
201202
}
202203
}
203-
if (previous != null)
204+
if (previous != null && previous != tm)
204205
previous.transferAndClose(tm);
205206
Threading.logger.info("New partition added to DrivesTaskManager: " + mount.getAbsolutePath());
206207
}

0 commit comments

Comments
 (0)