Skip to content

Commit

Permalink
[api-analysis] Join on Charset job and PluginModelManager / fix recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Dec 29, 2024
1 parent af85163 commit 27680b1
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;

import org.eclipse.core.internal.resources.CharsetDeltaJob;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
Expand Down Expand Up @@ -169,7 +170,9 @@ public void aboutToRun(IJobChangeEvent event) {
deleteAllProjects();
IPath projectPath = IPath.fromOSString(projectDir);
IProject project = getProject(projectPath);
RuntimeException exception = new RuntimeException("Can't get API result due to API application error");
jobManager.join(CharsetDeltaJob.FAMILY_CHARSET_DELTA, null);
jobManager.join(org.eclipse.pde.internal.core.PluginModelManager.class, null);
RuntimeException exception = new RuntimeException("Can't get API result due to API application error(s)");
String version = getVersion();
for (int i = 0; i < 5; i++) {
ApiAnalysisResult result = new ApiAnalysisResult(version);
Expand All @@ -187,14 +190,18 @@ public void aboutToRun(IJobChangeEvent event) {
throw exception;
}

private boolean isRecoverable(Exception error) {
if (error instanceof CoreException) {
String message = error.getMessage();
if (message != null) {
return COMPONENT_DISPOSED_ERROR.matcher(message).matches();
private boolean isRecoverable(Throwable throwable) {
if (throwable == null) {
return false;
}
if (throwable instanceof CoreException) {
String message = throwable.getMessage();
if (message != null && COMPONENT_DISPOSED_ERROR.matcher(message).find()) {
debug("Recoverable error found: " + message + " retry analysis again...");
return true;
}
}
return false;
return isRecoverable(throwable.getCause());
}

private IStatus runAnalysis(IPath projectPath, IProject project, ApiAnalysisResult result)
Expand Down Expand Up @@ -480,8 +487,8 @@ private void disableAutoBuild() throws CoreException {
IWorkspaceDescription desc = workspace.getDescription();
desc.setAutoBuilding(false);
workspace.setDescription(desc);
PDECore.getDefault().getPreferencesManager().setValue(ICoreConstants.DISABLE_API_ANALYSIS_BUILDER, false);
PDECore.getDefault().getPreferencesManager().setValue(ICoreConstants.RUN_API_ANALYSIS_AS_JOB, false);
PDECore.getDefault().getPreferencesManager().setValue(ICoreConstants.DISABLE_API_ANALYSIS_BUILDER, true);
PDECore.getDefault().getPreferencesManager().setValue(ICoreConstants.RUN_API_ANALYSIS_AS_JOB, runAsJob);
}

private Properties getPreferences() throws IOException {
Expand Down

0 comments on commit 27680b1

Please sign in to comment.