Skip to content

Commit ff53573

Browse files
frauzufallctrueden
authored andcommitted
ImageJUpdater: Do not update the updater separately
The removed code does the following: * check if the updater can be updated * if yes, download updater and it's dependencies and install it, do not ask for approval * try to restart the updater in place * if that does not work, ask for restart of Fiji This is why it should be removed: * if other components depend on the updater, this can break the installation because the other component will not get updated at the same time as the updater * the updater will be updated without the users approval CTR: I asked Johannes why this logic was introduced. Here is what he said: > The reason was dependency hell. If you don't update the updater first, > then create a new class loader, then re-load the updater and run it, > it really can break everything, especially when imagej-ui-swing is > updated (and not necessarily the updater). CTR: So really, there are things that can go wrong either way. In the interest of simplicity, we remove the logic. If all hell breaks loose, we can put it back, and deal with the fallout as best we can. But I expect that removing this logic will fix more problems than it causes. Closes #83. Signed-off-by: Curtis Rueden <[email protected]>
1 parent 4f70b9a commit ff53573

File tree

1 file changed

+2
-60
lines changed

1 file changed

+2
-60
lines changed

src/main/java/net/imagej/ui/swing/updater/ImageJUpdater.java

+2-60
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ public class ImageJUpdater implements UpdaterUI {
8080
@Parameter(required = false)
8181
private UploaderService uploaderService;
8282

83-
@Parameter(required = false)
84-
private CommandService commandService;
85-
86-
private final static String UPDATER_UPDATING_THREAD_NAME = "Updating the Updater itself!";
87-
8883
@Override
8984
public void run() {
9085

@@ -103,7 +98,7 @@ public void run() {
10398

10499
UpdaterUserInterface.set(new SwingUserInterface(log, statusService));
105100

106-
if (!areWeUpdatingTheUpdater() && new File(imagejRoot, "update").exists()) {
101+
if (new File(imagejRoot, "update").exists()) {
107102
if (!UpdaterUserInterface.get().promptYesNo("It is suggested that you restart ImageJ, then continue the update.\n"
108103
+ "Alternately, you can attempt to continue the upgrade without\n"
109104
+ "restarting, but ImageJ might crash.\n\n"
@@ -165,56 +160,6 @@ protected void updateConflictList() {
165160
return;
166161
}
167162

168-
if (!areWeUpdatingTheUpdater() && Installer.isTheUpdaterUpdateable(files, commandService)) {
169-
try {
170-
// download just the updater
171-
Installer.updateTheUpdater(files, main.getProgress("Installing the updater..."), commandService);
172-
}
173-
catch (final UpdateCanceledException e) {
174-
main.error("Canceled");
175-
return;
176-
}
177-
catch (final IOException e) {
178-
main.error("Installer failed: " + e);
179-
return;
180-
}
181-
182-
// make a class path using the updated files
183-
final List<URL> classPath = new ArrayList<>();
184-
for (FileObject component : Installer.getUpdaterFiles(files, commandService, false)) {
185-
final File updated = files.prefixUpdate(component.getFilename(false));
186-
if (updated.exists()) try {
187-
classPath.add(updated.toURI().toURL());
188-
continue;
189-
} catch (MalformedURLException e) {
190-
log.error(e);
191-
}
192-
final String name = component.getLocalFilename(false);
193-
File file = files.prefix(name);
194-
try {
195-
classPath.add(file.toURI().toURL());
196-
} catch (MalformedURLException e) {
197-
log.error(e);
198-
}
199-
}
200-
try {
201-
log.info("Trying to install and execute the new updater");
202-
final URL[] urls = classPath.toArray(new URL[classPath.size()]);
203-
URLClassLoader remoteClassLoader = new URLClassLoader(urls, getClass().getClassLoader().getParent());
204-
Class<?> runnable = remoteClassLoader.loadClass(ImageJUpdater.class.getName());
205-
final Thread thread = new Thread((Runnable)runnable.newInstance());
206-
thread.setName(UPDATER_UPDATING_THREAD_NAME);
207-
thread.start();
208-
thread.join();
209-
return;
210-
} catch (Throwable t) {
211-
log.error(t);
212-
}
213-
214-
main.info("Please restart ImageJ and call Help>Update to continue with the update");
215-
return;
216-
}
217-
218163
try {
219164
final String missingUploaders = main.files.protocolsMissingUploaders(main.getUploaderService(), main.getProgress(null));
220165
if (missingUploaders != null) {
@@ -411,11 +356,8 @@ protected static boolean moveOutOfTheWay(final File file) {
411356
return file.renameTo(backup);
412357
}
413358

414-
private boolean areWeUpdatingTheUpdater() {
415-
return UPDATER_UPDATING_THREAD_NAME.equals(Thread.currentThread().getName());
416-
}
417-
418359
public static void main(String[] args) {
419360
new ImageJUpdater().run();
420361
}
362+
421363
}

0 commit comments

Comments
 (0)