Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE during hierarchical layout with fixed order ports #754

Closed
uruuru opened this issue Mar 26, 2021 · 1 comment · Fixed by #792
Closed

NPE during hierarchical layout with fixed order ports #754

uruuru opened this issue Mar 26, 2021 · 1 comment · Fixed by #792
Labels
alg-layered Affects the ELK Layered algorithm. bug Erroneous behaviour.

Comments

@uruuru
Copy link
Contributor

uruuru commented Mar 26, 2021

The graph below triggers the exception below.

Removing fixed order port constraints from n2_1 allows a proper layout.

graph root
hierarchyHandling: INCLUDE_CHILDREN
algorithm: layered
node n1 {
	layout [ size: 50, 50 ]
	elk.padding: "[top=50.0,left=50.0,bottom=50.0,right=50.0]"
	portConstraints: FIXED_ORDER
	label "n1" {
		layout [ size: 8, -9.5 ]
	}
} 
node n2 {
	layout [ size: 190, 150 ]
	elk.padding: "[top=120.0,left=50.0,bottom=50.0,right=50.0]"
	portConstraints: FIXED_ORDER
	node n2_1 {
		layout [ size: 80, 80 ]
		elk.padding: "[top=50.0,left=50.0,bottom=50.0,right=50.0]"
		portConstraints: FIXED_ORDER
		node n2_1_1 {
			layout [ size: 80, 80 ]
			elk.padding: "[top=50.0,left=50.0,bottom=50.0,right=50.0]"
			portConstraints: FIXED_ORDER
		}
	}
	node n2_2 {
		layout [ size: 80, 80 ]
		elk.padding: "[top=50.0,left=50.0,bottom=50.0,right=50.0]"
		portConstraints: FIXED_ORDER
	}
	edge e2_1_2_2: n2_1 -> n2_2
}
node n3 {
	layout [ size: 50, 50 ]
	elk.padding: "[top=50.0,left=50.0,bottom=50.0,right=50.0]"
	portConstraints: FIXED_ORDER
	label "n3" {
		layout [ size: 8, -9.5 ]
	}
}
edge e12_1: n1 -> n2.n2_1
edge e1_2_1_1: n1 -> n2.n2_1.n2_1_1
edge e2_2_3: n2.n2_2 -> n3
java.lang.NullPointerException
   at org.eclipse.elk.alg.layered.graph.LGraphUtil.createExternalPortDummy(LGraphUtil.java:937)
   at org.eclipse.elk.alg.layered.compound.CompoundGraphPreprocessor.transformHierarchyEdges(CompoundGraphPreprocessor.java:176)
   at org.eclipse.elk.alg.layered.compound.CompoundGraphPreprocessor.transformHierarchyEdges(CompoundGraphPreprocessor.java:156)
   at org.eclipse.elk.alg.layered.compound.CompoundGraphPreprocessor.process(CompoundGraphPreprocessor.java:104)
   at org.eclipse.elk.alg.layered.ElkLayered.doCompoundLayout(ElkLayered.java:182)
   at org.eclipse.elk.alg.layered.LayeredLayoutProvider.layout(LayeredLayoutProvider.java:53)
   at org.eclipse.elk.core.RecursiveGraphLayoutEngine.executeAlgorithm(RecursiveGraphLayoutEngine.java:250)
   at org.eclipse.elk.core.RecursiveGraphLayoutEngine.layoutRecursively(RecursiveGraphLayoutEngine.java:218)
   at org.eclipse.elk.core.RecursiveGraphLayoutEngine.layout(RecursiveGraphLayoutEngine.java:96)
   at org.eclipse.elk.core.RecursiveGraphLayoutEngine.layout(RecursiveGraphLayoutEngine.java:72)
   at org.eclipse.elk.core.service.DiagramLayoutEngine.layout(DiagramLayoutEngine.java:703)
   at org.eclipse.elk.core.service.DiagramLayoutEngine.layout(DiagramLayoutEngine.java:631)
   at org.eclipse.elk.core.service.DiagramLayoutEngine$1.execute(DiagramLayoutEngine.java:373)
   at org.eclipse.elk.core.service.util.MonitoredOperation$1.run(MonitoredOperation.java:234)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   at java.lang.Thread.run(Thread.java:748)

Issue occurs in the following snippet where portPosition has been passed to the method by the caller as null.

                    informationAboutIt = portPosition.y;

The portPosition is only used for fixed order if no port index has been set. However, as the graph does not contain ports, the created dummy ports likely do not have an index.

@uruuru uruuru added bug Erroneous behaviour. alg-layered Affects the ELK Layered algorithm. labels Mar 26, 2021
@soerendomroes
Copy link
Contributor

I don't thing that we can get sensible positions or indices for dummy ports. We could either throw a UnsupportedConfigurationException that states this or try to set a default port position or index.

In other calls of createExternalPortDummy a new KVector() is used as a position instead of null. I suggest to do this also in this case.

soerendomroes added a commit to soerendomroes/elk that referenced this issue Mar 3, 2022
Fixes eclipse#754 (NPE)

Signed-off-by: Soeren Domroes <sdo@informatik.uni-kiel.de>
soerendomroes added a commit to soerendomroes/elk that referenced this issue Mar 17, 2022
)

Fixes eclipse#754 (NPE)

Signed-off-by: Soeren Domroes <sdo@informatik.uni-kiel.de>
Eddykasp pushed a commit to Eddykasp/elk that referenced this issue Jun 7, 2022
)

Fixes eclipse#754 (NPE)

Signed-off-by: Soeren Domroes <sdo@informatik.uni-kiel.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alg-layered Affects the ELK Layered algorithm. bug Erroneous behaviour.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants