-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Normal
-
Affects Version/s: 8.6.0.1
-
Component/s: Components
-
Security Level: Jimmy
-
None
Steps to Reproduce
Create a custom component class
public class MyZhtmlComp extends AbstractTag { MyZhtmlComp() { super("div"); } }
instantiate it using java code and add it to a page
@Override public void doAfterCompose(Component comp) throws Exception { final MyZhtmlComp myZhtmlComp = new MyZhtmlComp(); comp.appendChild(myZhtmlComp); }
Current Result
Doing this many times will consume significant amounts of CPU time, caused by unnecessarily thrown,caught and ignored "DefinitionNotFoundException"s
Expected Result
avoid unnecessary exceptions
Debug Info
Root Cause
the current PageImpl.getComponentDefinition catches and ignores 2 exceptions
a new method _langdef.getComponentDefinitionIfAny(cls) that doesn't throw exceptions would allow a more efficient implementation in this case:
compdef = _langdef.getComponentDefinitionIfAny(cls); if(compdef == null) { return _langdef.getShadowDefinitionIfAny(cls); }
Workaround
setting a component definition before instantiating the component prevents the search and exceptions
@Override public void doAfterCompose(Component comp) throws Exception { ComponentsCtrl.setCurrentInfo(ComponentsCtrl.DUMMY); //or an existing definition final MyZhtmlComp myZhtmlComp = new MyZhtmlComp(); comp.appendChild(myZhtmlComp); }