Bug #4668

Writing into the wrong virtual graph in DiagramEditorStates.saveEditorState

Added by Jani Simomaa about 4 years ago. Updated almost 4 years ago.

Status:ClosedStart date:
Priority:4Due date:
Assignee:Jani Simomaa% Done:

100%

Category:DiagramSpent time:-
Target version:1.13.1
Release notes:
Story pointsS
Velocity based estimate-
ReleaseSimantics 1.13.2Release relationshipAuto

Description

No idea why this exception was thrown:

org.simantics.db.exception.ArgumentException: Tried to remove literal value from persistent resource [id=$385357] using virtual graph 'preferences'
    at org.simantics.db.impl.graph.WriteGraphImpl.denyValue0(WriteGraphImpl.java:1034)
    at org.simantics.db.impl.graph.WriteGraphImpl.denyValue(WriteGraphImpl.java:996)
    at org.simantics.db.layer0.adapter.impl.EntityRemover.remove(EntityRemover.java:74)
    at org.simantics.db.layer0.adapter.impl.EntityRemover.remove(EntityRemover.java:38)
    at org.simantics.db.layer0.util.RemoverUtil.tryRemover(RemoverUtil.java:57)
    at org.simantics.db.layer0.util.RemoverUtil.remove(RemoverUtil.java:50)
    at org.simantics.modeling.ui.diagramEditor.DiagramEditorStates$1.perform(DiagramEditorStates.java:117)
    at fi.vtt.simantics.procore.internal.SessionImplSocket$1.run(SessionImplSocket.java:506)
    at fi.vtt.simantics.procore.internal.SessionRequestManager$3.run(SessionRequestManager.java:185)
    at org.simantics.db.impl.query.QueryThread.run(QueryThread.java:239)

This code in DiagramEditorStates.java looked a bit hazardous to Tuukka:

    public static void saveEditorState(final String virtualGraph, final Resource diagram, final EditorState editorState, final ListenerSupport support) {
        Session session = Simantics.getSession();

        VirtualGraph vg = virtualGraph == null ? null
                : session.getService(VirtualGraphSupport.class).getWorkspacePersistent(virtualGraph);

        session.asyncRequest(new WriteRequest(vg) {
            @Override
            public void perform(WriteGraph graph) throws DatabaseException {
                DiagramResource DIA = DiagramResource.getInstance(graph);

                // Remove all previous editor states.
                for (Resource state : graph.getObjects(diagram, DIA.HasEditorState))
                    RemoverUtil.remove(graph, state);

                newEditorState(graph, diagram, editorState);
            }
        }, new Callback<DatabaseException>() {
            @Override
            public void run(DatabaseException parameter) {
                if (parameter != null)
                    support.exception(parameter);
            }
        });
    }

Associated revisions

Revision 28666
Added by Tuukka Lehtonen about 4 years ago

Tried to fix DiagramEditorStates to remove old states in a more robust fashion.

refs #4668

History

#1 Updated by Jani Simomaa about 4 years ago

  • Description updated (diff)

#2 Updated by Tuukka Lehtonen about 4 years ago

  • Status changed from New to Feedback
  • Assignee set to Jani Simomaa
  • Target version set to 1.13.1
  • % Done changed from 0 to 100

Jani, please try repeating this, if possible.

#3 Updated by Tuukka Lehtonen almost 4 years ago

  • Subject changed from ArgumentException (no reason why) to Writing into the wrong virtual graph in DiagramEditorStates.saveEditorState
  • Category set to Diagram
  • Status changed from Feedback to Closed

Also available in: Atom PDF