jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
695 stars 125 forks source link

NPE when setting collapsed=true to generated column #3549

Closed gorbunkov closed 3 months ago

gorbunkov commented 3 months ago

Environment

Jmix version: 1.6.0

Bug Description

When generated column is added to the table and collapsed="true" is set for this column, then NPE occurs on screen opening.

See forum.

Steps To Reproduce

      <groupTable id="usersTable"
                    width="100%"
                    dataContainer="usersDc"
                    multiselect="true">
            <columns>
                <!-- ... -->
                <column collapsed="true" id="generatedColumn"/>
            </columns>
    @Install(to = "usersTable.generatedColumn", subject = "columnGenerator")
    private Component countryTableCityCountryNameColumnGenerator(User user) {
        return new Table.PlainTextCell("I am IronMan");
    }

Current Behavior

NPE when the screen is opened

Caused by: java.lang.NullPointerException: Cannot invoke "io.jmix.core.metamodel.model.MetaPropertyPath.getMetaProperties()" because "metaPropertyPath" is null
    at io.jmix.security.impl.constraint.SecureOperationsImpl.isEntityAttrUpdatePermitted(SecureOperationsImpl.java:88) ~[jmix-security-1.6.0.jar:na]
    at io.jmix.security.constraint.EntityAttributeConstraint.applyTo(EntityAttributeConstraint.java:50) ~[jmix-security-1.6.0.jar:na]
    at io.jmix.security.constraint.EntityAttributeConstraint.applyTo(EntityAttributeConstraint.java:26) ~[jmix-security-1.6.0.jar:na]
    at io.jmix.core.AccessManager.lambda$applyConstraints$2(AccessManager.java:77) ~[jmix-core-1.6.0.jar:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[na:na]
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[na:na]
    at io.jmix.core.AccessManager.applyConstraints(AccessManager.java:76) ~[jmix-core-1.6.0.jar:na]
    at io.jmix.core.AccessManager.applyRegisteredConstraints(AccessManager.java:86) ~[jmix-core-1.6.0.jar:na]
    at io.jmix.ui.component.impl.AbstractTable.setColumnCollapsedUiPermissionsAware(AbstractTable.java:1674) ~[jmix-ui-1.6.0.jar:na]
    at io.jmix.ui.component.impl.AbstractTable$ColumnImpl.setCollapsed(AbstractTable.java:2034) ~[jmix-ui-1.6.0.jar:na]
    at io.jmix.ui.xml.layout.loader.AbstractTableLoader.lambda$loadColumn$0(AbstractTableLoader.java:457) ~[jmix-ui-1.6.0.jar:na]
    at io.jmix.ui.xml.layout.loader.ComponentLoaderContext.executePostInitTasks(ComponentLoaderContext.java:141) ~[jmix-ui-1.6.0.jar:na]
    at io.jmix.ui.sys.ScreensImpl.createScreen(ScreensImpl.java:228) ~[jmix-ui-1.6.0.jar:na]
    at io.jmix.ui.sys.ScreensImpl.create(ScreensImpl.java:145) ~[jmix-ui-1.6.0.jar:na]
    at io.jmix.ui.menu.MenuItemCommands$ScreenCommand.createScreen(MenuItemCommands.java:230) ~[jmix-ui-1.6.0.jar:na]
    at io.jmix.ui.menu.MenuItemCommands$ScreenCommand.run(MenuItemCommands.java:169) ~[jmix-ui-1.6.0.jar:na]
    at io.jmix.ui.menu.SideMenuBuilder$MenuCommandExecutor.accept(SideMenuBuilder.java:272) ~[jmix-ui-1.6.0.jar:na]
    at io.jmix.ui.menu.SideMenuBuilder$MenuCommandExecutor.accept(SideMenuBuilder.java:257) ~[jmix-ui-1.6.0.jar:na]
    at io.jmix.ui.component.mainwindow.impl.SideMenuImpl$MenuItemImpl.menuSelected(SideMenuImpl.java:587) ~[jmix-ui-1.6.0.jar:na]
    at io.jmix.ui.widget.JmixSideMenu$1.menuItemTriggered(JmixSideMenu.java:91) ~[jmix-ui-1.6.0.jar:na]
    ... 95 common frames omitted
khurry commented 3 months ago

Same error appears when we hide generated column in a screen (using "settings" button of a table) with settings facet. Then, after sceen reopen we get the NPE