Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tycho-4.0.x] [api-analysis] Join on Charset job and PluginModelManager / fix recovery #4576

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading