mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
1. fix timestamp storage crash: do not close the storage while build in progress
2. do not subscribe on 'project saved' events - server cached state is cleared too often
This commit is contained in:
@@ -31,7 +31,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ProjectManagerAdapter;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkType;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
@@ -98,12 +97,6 @@ public class JpsServerManager implements ApplicationComponent{
|
||||
mySystemDirectory = system;
|
||||
|
||||
projectManager.addProjectManagerListener(new ProjectWatcher());
|
||||
final MessageBusConnection appConnection = ApplicationManager.getApplication().getMessageBus().connect();
|
||||
appConnection.subscribe(ProjectEx.ProjectSaved.TOPIC, new ProjectEx.ProjectSaved() {
|
||||
public void saved(@NotNull Project project) {
|
||||
sendReloadRequest(project);
|
||||
}
|
||||
});
|
||||
|
||||
ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
|
||||
@Override
|
||||
@@ -402,7 +395,7 @@ public class JpsServerManager implements ApplicationComponent{
|
||||
|
||||
// debugging
|
||||
cmdLine.addParameter("-XX:+HeapDumpOnOutOfMemoryError");
|
||||
//cmdLine.addParameter("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5008");
|
||||
cmdLine.addParameter("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5008");
|
||||
|
||||
// javac's VM should use the same default locale that IDEA uses in order for javac to print messages in 'correct' language
|
||||
final String lang = System.getProperty("user.language");
|
||||
|
||||
@@ -17,10 +17,7 @@ package com.intellij.compiler.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.actions.SuppressFix;
|
||||
import com.intellij.codeInsight.daemon.impl.actions.SuppressForClassFix;
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.CompilerConfigurationImpl;
|
||||
import com.intellij.compiler.CompilerWorkspaceConfiguration;
|
||||
import com.intellij.compiler.HelpID;
|
||||
import com.intellij.compiler.*;
|
||||
import com.intellij.compiler.options.CompilerConfigurable;
|
||||
import com.intellij.ide.errorTreeView.*;
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
@@ -112,6 +109,7 @@ public class CompilerErrorTreeView extends NewErrorTreeViewPanel {
|
||||
public void run() {
|
||||
if (!project.isDisposed()) {
|
||||
project.save();
|
||||
JpsServerManager.getInstance().sendReloadRequest(project);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.compiler.options;
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.CompilerConfigurationImpl;
|
||||
import com.intellij.compiler.CompilerSettingsFactory;
|
||||
import com.intellij.compiler.JpsServerManager;
|
||||
import com.intellij.compiler.impl.rmiCompiler.RmicConfiguration;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.compiler.options.ExcludedEntriesConfigurable;
|
||||
@@ -120,7 +121,7 @@ public class CompilerConfigurable implements SearchableConfigurable.Parent, Conf
|
||||
}
|
||||
};
|
||||
|
||||
kids.add(createExcludesWrapper(excludes));
|
||||
kids.add(createExcludesWrapper(excludes, myProject));
|
||||
|
||||
ArrayList<Configurable> additional = new ArrayList<Configurable>();
|
||||
|
||||
@@ -156,7 +157,7 @@ public class CompilerConfigurable implements SearchableConfigurable.Parent, Conf
|
||||
return myKids;
|
||||
}
|
||||
|
||||
private static Configurable createExcludesWrapper(final ExcludedEntriesConfigurable excludes) {
|
||||
private static Configurable createExcludesWrapper(final ExcludedEntriesConfigurable excludes, final Project project) {
|
||||
return new SearchableConfigurable() {
|
||||
@Nls
|
||||
public String getDisplayName() {
|
||||
@@ -177,6 +178,11 @@ public class CompilerConfigurable implements SearchableConfigurable.Parent, Conf
|
||||
|
||||
public void apply() {
|
||||
excludes.apply();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
JpsServerManager.getInstance().sendReloadRequest(project);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
|
||||
@@ -98,6 +98,13 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
if (!workspaceConfiguration.USE_COMPILE_SERVER) {
|
||||
JpsServerManager.getInstance().shutdownServer();
|
||||
}
|
||||
else {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
JpsServerManager.getInstance().sendReloadRequest(myProject);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyResourcePatterns(String extensionString, final CompilerConfigurationImpl configuration)
|
||||
|
||||
@@ -9,13 +9,15 @@ import org.jetbrains.jps.incremental.storage.ProjectTimestamps;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 1/8/12
|
||||
*/
|
||||
public class ProjectDescriptor {
|
||||
public final class ProjectDescriptor {
|
||||
public final String projectName;
|
||||
public final Project project;
|
||||
public final FSState fsState;
|
||||
public final ProjectTimestamps timestamps;
|
||||
public ModuleRootsIndex rootsIndex;
|
||||
|
||||
private int myUseCounter = 1;
|
||||
|
||||
ProjectDescriptor(String projectName, Project project, FSState fsState, ProjectTimestamps timestamps) {
|
||||
this.projectName = projectName;
|
||||
this.project = project;
|
||||
@@ -23,8 +25,18 @@ public class ProjectDescriptor {
|
||||
this.timestamps = timestamps;
|
||||
this.rootsIndex = new ModuleRootsIndex(project);
|
||||
}
|
||||
public synchronized void incUsageCounter() {
|
||||
myUseCounter++;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
timestamps.close();
|
||||
public void release() {
|
||||
boolean shouldClose;
|
||||
synchronized (this) {
|
||||
--myUseCounter;
|
||||
shouldClose = myUseCounter == 0;
|
||||
}
|
||||
if (shouldClose) {
|
||||
timestamps.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,11 +86,16 @@ class ServerMessageHandler extends SimpleChannelHandler {
|
||||
final String projectId = fsEvent.getProjectId();
|
||||
final ProjectDescriptor pd = facade.getProjectDescriptor(projectId);
|
||||
if (pd != null) {
|
||||
for (String path : fsEvent.getChangedPathsList()) {
|
||||
facade.notifyFileChanged(pd, new File(path));
|
||||
try {
|
||||
for (String path : fsEvent.getChangedPathsList()) {
|
||||
facade.notifyFileChanged(pd, new File(path));
|
||||
}
|
||||
for (String path : fsEvent.getDeletedPathsList()) {
|
||||
facade.notifyFileDeleted(pd, new File(path));
|
||||
}
|
||||
}
|
||||
for (String path : fsEvent.getDeletedPathsList()) {
|
||||
facade.notifyFileDeleted(pd, new File(path));
|
||||
finally {
|
||||
pd.release();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -40,8 +40,7 @@ class ServerState {
|
||||
for (Map.Entry<String, ProjectDescriptor> entry : myProjects.entrySet()) {
|
||||
final String projectPath = entry.getKey();
|
||||
final ProjectDescriptor descriptor = entry.getValue();
|
||||
LOG.info("Global configuration changed: Closing descriptor for project " + projectPath);
|
||||
descriptor.close();
|
||||
descriptor.release();
|
||||
}
|
||||
myProjects.clear(); // projects should be reloaded against the latest data
|
||||
myGlobalLibraries.clear();
|
||||
@@ -80,6 +79,9 @@ class ServerState {
|
||||
final ProjectDescriptor pd;
|
||||
synchronized (myConfigurationLock) {
|
||||
pd = myProjects.get(projectPath);
|
||||
if (pd != null) {
|
||||
pd.incUsageCounter();
|
||||
}
|
||||
}
|
||||
return pd;
|
||||
}
|
||||
@@ -88,10 +90,8 @@ class ServerState {
|
||||
synchronized (myConfigurationLock) {
|
||||
for (String projectPath : projectPaths) {
|
||||
final ProjectDescriptor descriptor = myProjects.remove(projectPath);
|
||||
LOG.info("Clearing descriptor for project " + projectPath);
|
||||
if (descriptor != null) {
|
||||
LOG.info("Closing descriptor for project " + projectPath);
|
||||
descriptor.close();
|
||||
descriptor.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,19 +101,19 @@ class ServerState {
|
||||
final String projectName = getProjectName(projectPath);
|
||||
BuildType buildType = params.buildType;
|
||||
|
||||
ProjectDescriptor descriptor;
|
||||
ProjectDescriptor pd;
|
||||
synchronized (myConfigurationLock) {
|
||||
descriptor = myProjects.get(projectPath);
|
||||
if (descriptor == null) {
|
||||
LOG.info("Creating project descriptor for project " + projectPath);
|
||||
pd = myProjects.get(projectPath);
|
||||
if (pd == null) {
|
||||
final Project project = loadProject(projectPath, params);
|
||||
final FSState fsState = new FSState();
|
||||
descriptor = new ProjectDescriptor(projectName, project, fsState, new ProjectTimestamps(projectName));
|
||||
myProjects.put(projectPath, descriptor);
|
||||
pd = new ProjectDescriptor(projectName, project, fsState, new ProjectTimestamps(projectName));
|
||||
myProjects.put(projectPath, pd);
|
||||
}
|
||||
pd.incUsageCounter();
|
||||
}
|
||||
|
||||
final Project project = descriptor.project;
|
||||
final Project project = pd.project;
|
||||
|
||||
try {
|
||||
final List<Module> toCompile = new ArrayList<Module>();
|
||||
@@ -130,7 +130,7 @@ class ServerState {
|
||||
|
||||
final CompileScope compileScope = new CompileScope(project, toCompile);
|
||||
|
||||
final IncProjectBuilder builder = new IncProjectBuilder(descriptor, BuilderRegistry.getInstance());
|
||||
final IncProjectBuilder builder = new IncProjectBuilder(pd, BuilderRegistry.getInstance());
|
||||
if (msgHandler != null) {
|
||||
builder.addMessageHandler(msgHandler);
|
||||
}
|
||||
@@ -154,6 +154,7 @@ class ServerState {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
pd.release();
|
||||
clearZipIndexCache();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user