[152778] Fix memory leak from static field held by adapter manager
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/JavaServerPlugin.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/JavaServerPlugin.java
index d129069..acd18d6 100644
--- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/JavaServerPlugin.java
+++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/JavaServerPlugin.java
@@ -336,7 +336,7 @@
for (int i = 0; i < size; i++) {
try {
list.add(new RuntimeFacetMapping(cf[i]));
- Trace.trace(Trace.CONFIG, " Loaded runtimeFacetMapping: " + cf[i].getAttribute("id"));
+ Trace.trace(Trace.CONFIG, " Loaded runtimeFacetMapping: " + cf[i].getAttribute("runtimeTypeId"));
} catch (Throwable t) {
Trace.trace(Trace.SEVERE, " Could not load runtimeFacetMapping: " + cf[i].getAttribute("id"), t);
}
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorPart.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorPart.java
index dc70bb9..20637f8 100644
--- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorPart.java
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/ConfigurationWebModuleEditorPart.java
@@ -20,6 +20,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jst.server.core.IWebModule;
import org.eclipse.jst.server.tomcat.core.internal.ITomcatServerWorkingCopy;
@@ -315,7 +316,8 @@
webAppTable.removeAll();
setErrorMessage(null);
-
+
+ ILabelProvider labelProvider = ServerUICore.getLabelProvider();
List list = configuration.getWebModules();
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
@@ -331,8 +333,9 @@
projectImage = TomcatUIPlugin.getImage(TomcatUIPlugin.IMG_PROJECT_MISSING);
IModule module2 = ServerUtil.getModule(memento);
if (module2 != null) {
- projectName = ServerUICore.getLabelProvider().getText(module2);
- projectImage = ServerUICore.getLabelProvider().getImage(module2);
+
+ projectName = labelProvider.getText(module2);
+ projectImage = labelProvider.getImage(module2);
item.setData(module2);
}
}
@@ -349,6 +352,7 @@
setErrorMessage(NLS.bind(Messages.errorMissingWebModule, module.getDocumentBase()));
}
}
+ labelProvider = null;
if (readOnly) {
addProject.setEnabled(false);
diff --git a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/WebModuleDialog.java b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/WebModuleDialog.java
index 1b8dab7..1a481db 100644
--- a/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/WebModuleDialog.java
+++ b/plugins/org.eclipse.jst.server.tomcat.ui/tomcatui/org/eclipse/jst/server/tomcat/ui/internal/editor/WebModuleDialog.java
@@ -13,6 +13,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jst.server.core.IWebModule;
import org.eclipse.jst.server.tomcat.core.internal.ITomcatConfiguration;
import org.eclipse.jst.server.tomcat.core.internal.ITomcatServer;
@@ -143,6 +144,7 @@
whs.setHelp(projTable, ContextIds.CONFIGURATION_EDITOR_WEBMODULE_DIALOG_PROJECT);
// fill table with web module projects
+ ILabelProvider labelProvider = ServerUICore.getLabelProvider();
IModule[] modules = ServerUtil.getModules(server2.getServerType().getRuntimeType().getModuleTypes());
if (modules != null) {
int size = modules.length;
@@ -152,16 +154,17 @@
IStatus status = server2.canModifyModules(new IModule[] { module3 }, null, null);
if (status != null && status.isOK()) {
TableItem item = new TableItem(projTable, SWT.NONE);
- item.setText(0, ServerUICore.getLabelProvider().getText(module3));
- item.setImage(0, ServerUICore.getLabelProvider().getImage(module3));
+ item.setText(0, labelProvider.getText(module3));
+ item.setImage(0, labelProvider.getImage(module3));
item.setData(module3);
}
}
}
}
+ labelProvider.dispose();
new Label(composite, SWT.NONE).setText(" ");
}
-
+
new Label(composite, SWT.NONE).setText(Messages.configurationEditorWebModuleDialogDocumentBase);
docBase = new Text(composite, SWT.BORDER);
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java
index 981a1d3..b478cde 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java
@@ -161,12 +161,13 @@
if (sections == null) {
sections = new ArrayList();
sectionToInsertionId = new HashMap();
+ ServerEditor serverEditor = commandManager.getServerEditor();
Iterator iterator = ServerEditorCore.getServerEditorPageSectionFactories().iterator();
while (iterator.hasNext()) {
IServerEditorPageSectionFactory factory = (IServerEditorPageSectionFactory) iterator.next();
String insertionId = factory.getInsertionId();
- IServerEditorPartFactory pageFactory = ServerEditor.getPageFactory(this);
+ IServerEditorPartFactory pageFactory = serverEditor.getPageFactory(this);
if (pageFactory.supportsInsertionId(insertionId)) {
String serverTypeId = null;
if (server != null)
@@ -194,7 +195,7 @@
}
return sections;
}
-
+
private List getSections(String insertionId) {
if (insertionId == null)
return null;
@@ -234,7 +235,7 @@
section.init(site, input);
}
}
-
+
/**
* Executes the given operation and adds it to the operation history
* with the correct context.
@@ -287,6 +288,10 @@
toolkit.dispose();
toolkit = null;
}
+
+ commandManager = null;
+ sectionToInsertionId = null;
+ sections = null;
}
/**
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ProjectPropertyPage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ProjectPropertyPage.java
index 9e8bdab..f58d1a0 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ProjectPropertyPage.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ProjectPropertyPage.java
@@ -17,6 +17,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -131,14 +132,16 @@
int size2 = servers.length;
count = 0;
+ ILabelProvider labelProvider = ServerUICore.getLabelProvider();
for (int j = 0; j < size2; j++) {
item = new TableItem(table, SWT.NONE);
- item.setText(ServerUICore.getLabelProvider().getText(servers[j]));
- item.setImage(ServerUICore.getLabelProvider().getImage(servers[j]));
+ item.setText(labelProvider.getText(servers[j]));
+ item.setImage(labelProvider.getImage(servers[j]));
item.setData(servers[j]);
if (servers[j].equals(defaultServer))
count = j + 1;
}
+ labelProvider.dispose();
table.setSelection(count);
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java
index 91f779a..49b88ca 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java
@@ -136,7 +136,7 @@
// used for disabling resource change check when saving through editor
protected boolean isSaving = false;
- protected static Map pageToFactory = new HashMap();
+ protected Map pageToFactory = new HashMap();
/**
* ServerEditor constructor comment.
@@ -196,7 +196,7 @@
actionList.toArray(editorActions);
}
- public static IServerEditorPartFactory getPageFactory(ServerEditorPart part) {
+ public IServerEditorPartFactory getPageFactory(ServerEditorPart part) {
try {
return (IServerEditorPartFactory) pageToFactory.get(part);
} catch (Exception e) {
@@ -359,6 +359,7 @@
ILabelProvider labelProvider = ServerUICore.getLabelProvider();
if (server != null)
setPartName(labelProvider.getText(server));
+ labelProvider.dispose();
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error saving server editor", e);
@@ -682,6 +683,8 @@
serverName = server.getName();
} else
setPartName("-");
+ labelProvider.dispose();
+ labelProvider = null;
cutAction = new TextAction(site.getShell().getDisplay(), TextAction.CUT_ACTION);
copyAction = new TextAction(site.getShell().getDisplay(), TextAction.COPY_ACTION);
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerResourceCommandManager.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerResourceCommandManager.java
index 3c87d2e..8f56608 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerResourceCommandManager.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerResourceCommandManager.java
@@ -95,4 +95,8 @@
// allow edit
return true;
}
+
+ public ServerEditor getServerEditor() {
+ return editor;
+ }
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java
index 59978a4..39b66d6 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java
@@ -12,6 +12,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.ui.ISharedImages;
@@ -76,7 +77,9 @@
ModuleServer ms = (ModuleServer) element;
if (columnIndex == 0) {
//return ServerUICore.getLabelProvider().getImage(ms.module[ms.module.length - 1]);
- Image image = ServerUICore.getLabelProvider().getImage(ms.module[ms.module.length - 1]);
+ ILabelProvider labelProvider = ServerUICore.getLabelProvider();
+ Image image = labelProvider.getImage(ms.module[ms.module.length - 1]);
+ labelProvider.dispose();
if (decorator != null) {
Image dec = decorator.decorateImage(image, ms);
if (dec != null)
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/SelectClientComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/SelectClientComposite.java
index 7be4919..78462b0 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/SelectClientComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/SelectClientComposite.java
@@ -12,6 +12,7 @@
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.wst.server.core.internal.IClient;
import org.eclipse.wst.server.ui.ServerUICore;
import org.eclipse.wst.server.ui.internal.*;
@@ -107,15 +108,17 @@
whs.setHelp(elementTable, ContextIds.SELECT_CLIENT);
if (clients != null) {
+ ILabelProvider labelProvider = ServerUICore.getLabelProvider();
int size = clients.length;
for (int i = 0; i < size; i++) {
TableItem item = new TableItem(elementTable, SWT.NONE);
- item.setText(0, ServerUICore.getLabelProvider().getText(clients[i]));
- item.setImage(0, ServerUICore.getLabelProvider().getImage(clients[i]));
+ item.setText(0, labelProvider.getText(clients[i]));
+ item.setImage(0, labelProvider.getImage(clients[i]));
item.setData(clients[i]);
}
+ labelProvider.dispose();
}
-
+
description = new Label(this, SWT.WRAP);
description.setText("");
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);