Ticket #11843: 11843-plugin.patch

File 11843-plugin.patch, 4.1 KB (added by simon04, 9 years ago)
  • src/org/openstreetmap/josm/plugins/PluginHandler.java

    diff --git a/src/org/openstreetmap/josm/plugins/PluginHandler.java b/src/org/openstreetmap/josm/plugins/PluginHandler.java
    index 390e3fa..887e546 100644
    a b import java.util.Set;  
    3434import java.util.TreeSet;
    3535import java.util.concurrent.Callable;
    3636import java.util.concurrent.ExecutionException;
    37 import java.util.concurrent.ExecutorService;
    38 import java.util.concurrent.Executors;
    39 import java.util.concurrent.Future;
    4037import java.util.concurrent.FutureTask;
    4138import java.util.jar.JarFile;
    4239
    public final class PluginHandler {  
    812809        }
    813810        try {
    814811            ReadLocalPluginInformationTask task = new ReadLocalPluginInformationTask(monitor);
    815             ExecutorService service = Executors.newSingleThreadExecutor(Utils.newThreadFactory("plugin-loader-%d", Thread.NORM_PRIORITY));
    816             Future<?> future = service.submit(task);
    817812            try {
    818                 future.get();
    819             } catch (ExecutionException e) {
     813                task.run();
     814            } catch (RuntimeException e) {
    820815                Main.error(e);
    821816                return null;
    822             } catch (InterruptedException e) {
    823                 Main.warn("InterruptedException in "+PluginHandler.class.getSimpleName()+" while loading locally available plugin information");
    824                 return null;
    825817            }
    826818            Map<String, PluginInformation> ret = new HashMap<>();
    827819            for (PluginInformation pi: task.getAvailablePlugins()) {
    public final class PluginHandler {  
    969961        }
    970962        try {
    971963            monitor.beginTask("");
    972             ExecutorService service = Executors.newSingleThreadExecutor(Utils.newThreadFactory("plugin-updater-%d", Thread.NORM_PRIORITY));
    973964
    974965            // try to download the plugin lists
    975966            //
    public final class PluginHandler {  
    977968                    monitor.createSubTaskMonitor(1, false),
    978969                    Main.pref.getOnlinePluginSites(), displayErrMsg
    979970            );
    980             Future<?> future = service.submit(task1);
     971            task1.run();
    981972            List<PluginInformation> allPlugins = null;
    982973
    983974            try {
    984                 future.get();
    985975                allPlugins = task1.getAvailablePlugins();
    986976                plugins = buildListOfPluginsToLoad(parent, monitor.createSubTaskMonitor(1, false));
    987977                // If only some plugins have to be updated, filter the list
    public final class PluginHandler {  
    1000990                        }
    1001991                    }
    1002992                }
    1003             } catch (ExecutionException e) {
     993            } catch (RuntimeException e) {
    1004994                Main.warn(tr("Failed to download plugin information list")+": ExecutionException");
    1005995                Main.error(e);
    1006996                // don't abort in case of error, continue with downloading plugins below
    1007             } catch (InterruptedException e) {
    1008                 Main.warn(tr("Failed to download plugin information list")+": InterruptedException");
    1009                 // don't abort in case of error, continue with downloading plugins below
    1010997            }
    1011998
    1012999            // filter plugins which actually have to be updated
    public final class PluginHandler {  
    10451032                        tr("Update plugins")
    10461033                );
    10471034
    1048                 future = service.submit(pluginDownloadTask);
    10491035                try {
    1050                     future.get();
    1051                 } catch (ExecutionException e) {
     1036                    pluginDownloadTask.run();
     1037                } catch (RuntimeException e) {
    10521038                    Main.error(e);
    10531039                    alertFailedPluginUpdate(parent, pluginsToUpdate);
    10541040                    return plugins;
    1055                 } catch (InterruptedException e) {
    1056                     Main.warn("InterruptedException in "+PluginHandler.class.getSimpleName()+" while updating plugins");
    1057                     alertFailedPluginUpdate(parent, pluginsToUpdate);
    1058                     return plugins;
    10591041                }
    10601042
    10611043                // Update Plugin info for downloaded plugins