Skip to content

Commit deeead8

Browse files
committed
Fix improper use of sub-monitor in Workspace.write()
SubMonitor.split() should not be called without providing any ticks, which might happen if the map of to-be-created files is empty. Given that the called method is private and only called from this method, the empty check can simply be pulled up.
1 parent eca8380 commit deeead8

File tree

1 file changed

+4
-5
lines changed
  • resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources

1 file changed

+4
-5
lines changed

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2022 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -2829,15 +2829,14 @@ public void write(Map<IFile, byte[]> contentMap, boolean force, boolean derived,
28292829
byte[] content = e.getValue();
28302830
file.setContents(content, updateFlags, subMon.split(1));
28312831
}
2832-
createMultiple(filesToCreate, createFlags, subMon.split(filesToCreate.size()), executorService);
2832+
if (!filesToCreate.isEmpty()) {
2833+
createMultiple(filesToCreate, createFlags, subMon.split(filesToCreate.size()), executorService);
2834+
}
28332835
}
28342836

28352837
/** @see File#create(byte[], int, IProgressMonitor) **/
28362838
private void createMultiple(ConcurrentMap<File, byte[]> filesToCreate, int updateFlags, IProgressMonitor monitor,
28372839
ExecutorService executorService) throws CoreException {
2838-
if (filesToCreate.isEmpty()) {
2839-
return;
2840-
}
28412840
Set<File> files = filesToCreate.keySet();
28422841
for (File file : files) {
28432842
file.checkValidPath(file.path, IResource.FILE, true);

0 commit comments

Comments
 (0)