Skip to content
Snippets Groups Projects
Commit f9261757 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1126-minervanet-error-report-169' into 'master'

Resolve "MINERVANET - Error Report 169"

Closes #1126

See merge request !1080
parents e8c893c2 cc54af95
No related branches found
No related tags found
1 merge request!1080Resolve "MINERVANET - Error Report 169"
Pipeline #21652 failed
......@@ -6,6 +6,7 @@ minerva (15.0.0~beta.2) stable; urgency=medium
structured log form
* Bug fix: antisenseRNA shape is infered from SBGN when antisenseRNA text is
present in glyph label (#1114)
* Bug fix: export to SBGN sometimes crashed due to concurrency issues (#1126)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 27 Feb 2020 14:00:00 +0200
......
......@@ -277,11 +277,10 @@ public class CopyCommand extends NewModelCommand {
* original reaction
* @return copy of the reaction
*/
private Reaction createCopy(Reaction reaction) {
Reaction createCopy(Reaction reaction) {
Reaction copy = reaction.copy();
reaction.getNodes().clear();
for (AbstractNode node : copy.getNodes()) {
reaction.addNode(node);
for (AbstractNode node : reaction.getNodes()) {
node.setReaction(reaction);
}
copy.getNodes().clear();
......
......@@ -3,8 +3,9 @@ package lcsb.mapviewer.commands;
import static org.junit.Assert.*;
import java.awt.geom.Point2D;
import java.util.Calendar;
import java.util.*;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.junit.*;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
......@@ -18,6 +19,7 @@ import lcsb.mapviewer.model.map.layout.graphics.Layer;
import lcsb.mapviewer.model.map.model.*;
import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction;
import lcsb.mapviewer.model.map.reaction.type.TransportReaction;
import lcsb.mapviewer.model.map.species.*;
public class CopyCommandTest extends CommandTestFunctions {
......@@ -312,4 +314,47 @@ public class CopyCommandTest extends CommandTestFunctions {
assertEquals(0, comparator.compare(copy, model));
}
@Test
public void testMultithreadedCopyReaction() throws Exception {
MutableBoolean exceptionHappened = new MutableBoolean(false);
Reaction r = new TransportReaction("x");
r.addReactant(new Reactant(createProtein()));
r.addReactant(new Reactant(createProtein()));
r.addReactant(new Reactant(createProtein()));
r.addReactant(new Reactant(createProtein()));
r.addProduct(new Product(createProtein()));
for (AbstractNode node : r.getNodes()) {
node.setLine(new PolylineData(new Point2D.Double(0.0, 0.0), new Point2D.Double(110.0, 10.0)));
}
List<Thread> threads = new ArrayList<>();
for (int i = 0; i < 100; i++) {
threads.add(new Thread(new Runnable() {
@Override
public void run() {
try {
new CopyCommand(null).createCopy(r);
} catch (Exception e) {
e.printStackTrace();
exceptionHappened.setTrue();
}
}
}));
}
for (Thread thread : threads) {
thread.start();
}
for (Thread thread : threads) {
thread.join();
}
assertFalse(exceptionHappened.booleanValue());
for (AbstractNode node : r.getNodes()) {
assertEquals(r, node.getReaction());
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment