Skip to content

Commit

Permalink
[176] Adapt SiriusDiagramActionBarContributor to avoid memory leak
Browse files Browse the repository at this point in the history
Create a specific ActionBarContributor for each specific implementation
of SiriusDiagramEditor to avoid a duplication of ActionRegistry: one for
"SiriusDiagramEditor.class" and one for real implementation
("DDiagramEditorImpl.class" or "EcoreEntitiesReadOnlyEditor.class").
Indeed, only one of the ActionRegistry is correctly cleaned at the
closing of the editor.

To avoid a performance problem, the timeout
"sun.awt.datatransfer.timeout" has been set to 100 ms instead of 10000
ms for the automatic tests (see comment on issue [1] for more details).

[1] #176 (comment)

Bug: #176
  • Loading branch information
lredor committed Mar 26, 2024
1 parent ceb41b8 commit 0473766
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 123 deletions.
2 changes: 1 addition & 1 deletion plugins/org.eclipse.sirius.diagram.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
default="true"
class="org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl"
matchingStrategy="org.eclipse.sirius.diagram.ui.part.SiriusMatchingStrategy"
contributorClass="org.eclipse.sirius.diagram.ui.part.SiriusDiagramActionBarContributor">
contributorClass="org.eclipse.sirius.diagram.ui.part.DDiagramEditorActionBarContributor">
</editor>
</extension>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.diagram.ui.part;

import org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl;

/**
* Specific ActionBarContributor for {@link DDiagramEditorImpl} instance to avoid potential leaks on actions for action
* bar of this editor.
*
* @author Laurent Redor
*/
public class DDiagramEditorActionBarContributor extends SiriusDiagramActionBarContributor {
@Override
protected Class<?> getEditorClass() {
return DDiagramEditorImpl.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Eclipse-LazyStart: true
Bundle-Activator: org.eclipse.sirius.ecore.design.service.EcoreSamplePlugin
Export-Package: org.eclipse.sirius.ecore.design.service;version="3.0.0",
org.eclipse.sirius.sample.ecore.design.action;version="3.0.0",
org.eclipse.sirius.sample.ecore.design.editor;version="3.0.0"
org.eclipse.sirius.sample.ecore.design.editor;version="3.0.0",
org.eclipse.sirius.sample.ecore.design.editor.ui.part;version="3.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.sirius.ext.base;version="2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/org.eclipse.sirius.sample.ecore.design/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
point="org.eclipse.ui.editors">
<editor
class="org.eclipse.sirius.sample.ecore.design.editor.EcoreEntitiesReadOnlyEditor"
contributorClass="org.eclipse.sirius.diagram.ui.part.SiriusDiagramActionBarContributor"
contributorClass="org.eclipse.sirius.sample.ecore.design.editor.ui.part.EcoreEntitiesActionBarContributor"
default="false"
extensions="ecore"
icon="icons/full/obj16/EcoreModelFile.gif"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.sample.ecore.design.editor.ui.part;

import org.eclipse.sirius.diagram.ui.part.SiriusDiagramActionBarContributor;
import org.eclipse.sirius.sample.ecore.design.editor.EcoreEntitiesReadOnlyEditor;

/**
* Specific ActionBarContributor for {@link EcoreEntitiesReadOnlyEditor} instance to avoid potential leaks on actions
* for action bar of this editor.
*
* @author Laurent Redor
*/
public class EcoreEntitiesActionBarContributor extends SiriusDiagramActionBarContributor {
@Override
protected Class<?> getEditorClass() {
return EcoreEntitiesReadOnlyEditor.class;
}
}
1 change: 1 addition & 0 deletions plugins/org.eclipse.sirius.tests.junit.xtext/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<org.eclipse.sirius.tests.skipLongTests>${tests.skipLongTests}</org.eclipse.sirius.tests.skipLongTests>
<org.eclipse.sirius.tests.skipUnreliableTests>${tests.skipUnreliableTests}</org.eclipse.sirius.tests.skipUnreliableTests>
<createLocalRepresentationInSeparateResource>${createLocalRepresentationInSeparateResource}</createLocalRepresentationInSeparateResource>
<sun.awt.datatransfer.timeout>100</sun.awt.datatransfer.timeout>
</systemProperties>
<skipTests>${tests.junit.skip}</skipTests>
<includes>
Expand Down
1 change: 1 addition & 0 deletions plugins/org.eclipse.sirius.tests.junit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<org.eclipse.sirius.tests.skipLongTests>${tests.skipLongTests}</org.eclipse.sirius.tests.skipLongTests>
<org.eclipse.sirius.tests.skipUnreliableTests>${tests.skipUnreliableTests}</org.eclipse.sirius.tests.skipUnreliableTests>
<createLocalRepresentationInSeparateResource>${createLocalRepresentationInSeparateResource}</createLocalRepresentationInSeparateResource>
<sun.awt.datatransfer.timeout>100</sun.awt.datatransfer.timeout>
</systemProperties>
<skipTests>${tests.junit.skip}</skipTests>
<includes>
Expand Down
240 changes: 120 additions & 120 deletions plugins/org.eclipse.sirius.tests.swtbot/pom.xml
Original file line number Diff line number Diff line change
@@ -1,120 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2007, 2017 THALES GLOBAL SERVICES
This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Obeo - Initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-parent</artifactId>
<version>7.4.1-SNAPSHOT</version>
<relativePath>../../packaging/org.eclipse.sirius.parent</relativePath>
</parent>

<properties>
<sonar.sources>pom.xml</sonar.sources>
<sonar.tests>src</sonar.tests>
</properties>

<artifactId>org.eclipse.sirius.tests.swtbot</artifactId>
<packaging>eclipse-test-plugin</packaging>
<version>7.4.1-SNAPSHOT</version>

<build>
<plugins>
<!-- Compile Acceleo3 modules -->
<plugin>
<groupId>org.eclipse.acceleo</groupId>
<artifactId>org.eclipse.acceleo.maven</artifactId>
<version>3.5.2</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>acceleo-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<skipTests>${tests.swtbot.skip}</skipTests>
<useBinaryResources>false</useBinaryResources>
<usePlatformResourcePath>true</usePlatformResourcePath>
<acceleoProject>
<root>${project.basedir}</root>
<entries>
<entry>
<input>src</input>
<output>target/classes</output>
</entry>
</entries>
</acceleoProject>
<packagesToRegister>
<packageToRegister>org.eclipse.emf.ecore.EcorePackage</packageToRegister>
</packagesToRegister>
</configuration>
</plugin>

<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<dependency-resolution>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>org.apache.log4j</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>

<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<dependencies>
<dependency>
<type>eclipse-feature</type>
<artifactId>org.eclipse.e4.rcp</artifactId>
<version>0.0.0</version>
</dependency>
</dependencies>
<systemProperties>
<org.eclipse.sirius.tests.skipLongTests>${tests.skipLongTests}</org.eclipse.sirius.tests.skipLongTests>
<org.eclipse.sirius.tests.skipUnreliableTests>${tests.skipUnreliableTests}</org.eclipse.sirius.tests.skipUnreliableTests>
<org.eclipse.swtbot.screenshots.dir>${project.build.directory}/screenshots</org.eclipse.swtbot.screenshots.dir>
<createLocalRepresentationInSeparateResource>${createLocalRepresentationInSeparateResource}</createLocalRepresentationInSeparateResource>
</systemProperties>
<skipTests>${tests.swtbot.skip}</skipTests>
<includes>
<include>${tests.swtbot.include}, ${tests.swtbot-sequence.include}</include>
</includes>
<useUIHarness>true</useUIHarness>
<useUIThread>false</useUIThread>
<argLine>${tests.vmargs}</argLine>
<product>org.eclipse.sdk.ide</product>
<application>org.eclipse.ui.ide.workbench</application>
<testFailureIgnore>${tests.ignoreFailures}</testFailureIgnore>
<forkedProcessTimeoutInSeconds>${tests.timeout}</forkedProcessTimeoutInSeconds>
</configuration>
</plugin>
</plugins>
</build>

</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2007, 2017 THALES GLOBAL SERVICES
This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Obeo - Initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-parent</artifactId>
<version>7.4.1-SNAPSHOT</version>
<relativePath>../../packaging/org.eclipse.sirius.parent</relativePath>
</parent>

<properties>
<sonar.sources>pom.xml</sonar.sources>
<sonar.tests>src</sonar.tests>
</properties>

<artifactId>org.eclipse.sirius.tests.swtbot</artifactId>
<packaging>eclipse-test-plugin</packaging>
<version>7.4.1-SNAPSHOT</version>

<build>
<plugins>
<!-- Compile Acceleo3 modules -->
<plugin>
<groupId>org.eclipse.acceleo</groupId>
<artifactId>org.eclipse.acceleo.maven</artifactId>
<version>3.5.2</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>acceleo-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<skipTests>${tests.swtbot.skip}</skipTests>
<useBinaryResources>false</useBinaryResources>
<usePlatformResourcePath>true</usePlatformResourcePath>
<acceleoProject>
<root>${project.basedir}</root>
<entries>
<entry>
<input>src</input>
<output>target/classes</output>
</entry>
</entries>
</acceleoProject>
<packagesToRegister>
<packageToRegister>org.eclipse.emf.ecore.EcorePackage</packageToRegister>
</packagesToRegister>
</configuration>
</plugin>

<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<dependency-resolution>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>org.apache.log4j</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>

<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<dependencies>
<dependency>
<type>eclipse-feature</type>
<artifactId>org.eclipse.e4.rcp</artifactId>
<version>0.0.0</version>
</dependency>
</dependencies>
<systemProperties>
<org.eclipse.sirius.tests.skipLongTests>${tests.skipLongTests}</org.eclipse.sirius.tests.skipLongTests>
<org.eclipse.sirius.tests.skipUnreliableTests>${tests.skipUnreliableTests}</org.eclipse.sirius.tests.skipUnreliableTests>
<org.eclipse.swtbot.screenshots.dir>${project.build.directory}/screenshots</org.eclipse.swtbot.screenshots.dir>
<createLocalRepresentationInSeparateResource>${createLocalRepresentationInSeparateResource}</createLocalRepresentationInSeparateResource>
<sun.awt.datatransfer.timeout>100</sun.awt.datatransfer.timeout> </systemProperties>
<skipTests>${tests.swtbot.skip}</skipTests>
<includes>
<include>${tests.swtbot.include}, ${tests.swtbot-sequence.include}</include>
</includes>
<useUIHarness>true</useUIHarness>
<useUIThread>false</useUIThread>
<argLine>${tests.vmargs}</argLine>
<product>org.eclipse.sdk.ide</product>
<application>org.eclipse.ui.ide.workbench</application>
<testFailureIgnore>${tests.ignoreFailures}</testFailureIgnore>
<forkedProcessTimeoutInSeconds>${tests.timeout}</forkedProcessTimeoutInSeconds>
</configuration>
</plugin>
</plugins>
</build>

</project>
Expand Down
1 change: 1 addition & 0 deletions plugins/org.eclipse.sirius.tests.tree/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<systemProperties>
<org.eclipse.sirius.tests.skipLongTests>${tests.skipLongTests}</org.eclipse.sirius.tests.skipLongTests>
<org.eclipse.sirius.tests.skipUnreliableTests>${tests.skipUnreliableTests}</org.eclipse.sirius.tests.skipUnreliableTests>
<sun.awt.datatransfer.timeout>100</sun.awt.datatransfer.timeout>
</systemProperties>
<skipTests>${tests.junit.skip}</skipTests>
<includes>
Expand Down
1 change: 1 addition & 0 deletions plugins/org.eclipse.sirius.tests.ui.properties/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<org.eclipse.sirius.tests.skipLongTests>${tests.skipLongTests}</org.eclipse.sirius.tests.skipLongTests>
<org.eclipse.sirius.tests.skipUnreliableTests>${tests.skipUnreliableTests}</org.eclipse.sirius.tests.skipUnreliableTests>
<createLocalRepresentationInSeparateResource>${createLocalRepresentationInSeparateResource}</createLocalRepresentationInSeparateResource>
<sun.awt.datatransfer.timeout>100</sun.awt.datatransfer.timeout>
</systemProperties>
<skipTests>${tests.junit.skip}</skipTests>
<includes>
Expand Down

0 comments on commit 0473766

Please sign in to comment.