Ticket #19098: 19098-real-fix.patch
| File 19098-real-fix.patch, 6.1 KB (added by , 5 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/bugreport/BugReportDialog.java
229 229 ); 230 230 return SuppressionMode.NONE; 231 231 } else { 232 PluginDownloadTask downloadTask = PluginHandler.updateOrdisablePluginAfterException(e); 232 233 return GuiHelper.runInEDTAndWaitAndReturn(() -> { 233 PluginDownloadTask downloadTask = PluginHandler.updateOrdisablePluginAfterException(e);234 234 if (downloadTask != null) { 235 235 // Ask for restart to install new plugin 236 236 PluginPreference.notifyDownloadResults( -
src/org/openstreetmap/josm/plugins/PluginHandler.java
37 37 import java.util.TreeSet; 38 38 import java.util.concurrent.CopyOnWriteArrayList; 39 39 import java.util.concurrent.ExecutionException; 40 import java.util.concurrent.ExecutorService; 41 import java.util.concurrent.Future; 40 42 import java.util.concurrent.FutureTask; 41 43 import java.util.concurrent.TimeUnit; 42 44 import java.util.jar.JarFile; … … 64 66 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 65 67 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 66 68 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 69 import org.openstreetmap.josm.gui.progress.swing.ProgressMonitorExecutor; 67 70 import org.openstreetmap.josm.gui.util.GuiHelper; 68 71 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; 69 72 import org.openstreetmap.josm.gui.widgets.JosmTextArea; … … 953 956 monitor = NullProgressMonitor.INSTANCE; 954 957 } 955 958 try { 959 Map<String, PluginInformation> ret = new HashMap<>(); 960 ExecutorService service = new ProgressMonitorExecutor("plugin-loader-%d", Thread.NORM_PRIORITY); 956 961 ReadLocalPluginInformationTask task = new ReadLocalPluginInformationTask(monitor); 962 Future<?> future = service.submit(task); 957 963 try { 958 task.run();959 } catch ( RuntimeException e) { // NOPMD964 future.get(); 965 } catch (ExecutionException e) { 960 966 Logging.error(e); 961 return null; 967 return ret; 968 } catch (InterruptedException e) { 969 Logging.warn("InterruptedException in " + PluginHandler.class.getSimpleName() 970 + " while loading locally available plugin information"); 971 return ret; 962 972 } 963 Map<String, PluginInformation> ret = new HashMap<>();964 973 for (PluginInformation pi: task.getAvailablePlugins()) { 965 974 ret.put(pi.name, pi); 966 975 } … … 1112 1121 } 1113 1122 try { 1114 1123 monitor.beginTask(""); 1124 ExecutorService service = new ProgressMonitorExecutor("plugin-updater-%d", Thread.NORM_PRIORITY); 1115 1125 1116 1126 // try to download the plugin lists 1117 1127 ReadRemotePluginInformationTask task1 = new ReadRemotePluginInformationTask( 1118 1128 monitor.createSubTaskMonitor(1, false), 1119 1129 Preferences.main().getOnlinePluginSites(), displayErrMsg 1120 );1121 task1.run();1122 List<PluginInformation> allPlugins = task1.getAvailablePlugins();1130 ); 1131 List<PluginInformation> allPlugins = null; 1132 Future<?> future = service.submit(task1); 1123 1133 1124 1134 try { 1135 future.get(); 1136 allPlugins = task1.getAvailablePlugins(); 1125 1137 plugins = buildListOfPluginsToLoad(parent, monitor.createSubTaskMonitor(1, false)); 1126 1138 // If only some plugins have to be updated, filter the list 1127 1139 if (pluginsWanted != null && !pluginsWanted.isEmpty()) { … … 1128 1140 final Collection<String> pluginsWantedName = Utils.transform(pluginsWanted, piw -> piw.name); 1129 1141 plugins = SubclassFilteredCollection.filter(plugins, pi -> pluginsWantedName.contains(pi.name)); 1130 1142 } 1131 } catch ( RuntimeException e) { // NOPMD1132 Logging.warn(tr("Failed to download plugin information list") );1143 } catch (ExecutionException e) { 1144 Logging.warn(tr("Failed to download plugin information list") + ": ExecutionException"); 1133 1145 Logging.error(e); 1134 1146 // don't abort in case of error, continue with downloading plugins below 1147 } catch (InterruptedException e) { 1148 Logging.warn(tr("Failed to download plugin information list") + ": InterruptedException"); 1149 // don't abort in case of error, continue with downloading plugins below 1135 1150 } 1136 1151 1137 1152 // filter plugins which actually have to be updated … … 1169 1184 monitor.createSubTaskMonitor(1, false), 1170 1185 pluginsToDownload, 1171 1186 tr("Update plugins") 1172 ); 1187 ); 1188 future = service.submit(pluginDownloadTask); 1189 1173 1190 try { 1174 pluginDownloadTask.run();1175 } catch ( RuntimeException e) { // NOPMD1191 future.get(); 1192 } catch (ExecutionException e) { 1176 1193 Logging.error(e); 1177 1194 alertFailedPluginUpdate(parent, pluginsToUpdate); 1178 1195 return plugins; 1196 } catch (InterruptedException e) { 1197 Logging.warn("InterruptedException in " + PluginHandler.class.getSimpleName() 1198 + " while updating plugins"); 1199 alertFailedPluginUpdate(parent, pluginsToUpdate); 1200 return plugins; 1179 1201 } 1180 1202 1181 1203 // Update Plugin info for downloaded plugins
