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

NullPointerException when try to remove TabSheet tabs in runtime #1073

Closed
kosotd opened this issue Jul 19, 2018 · 2 comments
Closed

NullPointerException when try to remove TabSheet tabs in runtime #1073

kosotd opened this issue Jul 19, 2018 · 2 comments
Assignees
Labels
state: won't fix This will not be worked on type: bug Something isn't working

Comments

@kosotd
Copy link

kosotd commented Jul 19, 2018

Environment

  • Platform version: 6.9.2
  • Client type: Web

Description of the bug or enhancement
Steps to reproduce

  1. Create screen with TabSheet and buttons to add and remove tabs in runtime.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
        caption="msg://caption"
        class="com.company.tabsheetlistenertest.web.screens.Screen"
        messagesPack="com.company.tabsheetlistenertest.web.screens">
    <dialogMode height="600"
                width="800"/>
    <layout expand="tabSheet">
        <hbox>
            <button id="addTabsBtn"
                    caption="add tabs"
                    invoke="onAddTabsBtnClick"/>
            <button id="removeTabsBtn"
                    caption="remove tabs"
                    invoke="onRemoveTabsBtnClick"/>
        </hbox>
        <tabSheet id="tabSheet"/>
    </layout>
</window>
  1. Add to TabSheet SelectedTabChangeListener.
public class Screen extends AbstractWindow {

    @Inject
    private TabSheet tabSheet;
    @Inject
    private ComponentsFactory componentsFactory;

    @Override
    public void init(Map<String, Object> params) {
        super.init(params);

        tabSheet.addSelectedTabChangeListener(event -> {});
    }

    public void onAddTabsBtnClick() {
        for (int i = 0; i < 3; i++) {
            Button button = componentsFactory.createComponent(Button.class);
            button.setCaption("Button " + i);
            tabSheet.addTab("tab " + i, button);
        }
    }

    public void onRemoveTabsBtnClick() {
        tabSheet.removeAllTabs();
    }
}
  1. Open screen, tap addTabs button and next removeTabs button.
  2. Result:
java.lang.NullPointerException
 at com.haulmont.cuba.web.gui.components.WebTabSheet.getSelectedTab(WebTabSheet.java:438)
 at com.haulmont.cuba.web.gui.components.WebTabSheet.getSelectedTab(WebTabSheet.java:47)
 at com.haulmont.cuba.gui.components.TabSheet.getTab(TabSheet.java:78)
 at com.haulmont.cuba.web.gui.components.WebTabSheet.lambda$initComponentTabChangeListener$ba8aefab$1(WebTabSheet.java:513)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
 at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:200)
 at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:163)
 at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1037)
 at com.vaadin.ui.TabSheet.fireSelectedTabChange(TabSheet.java:904)
 at com.vaadin.ui.TabSheet.removeComponent(TabSheet.java:247)
 at com.haulmont.cuba.web.toolkit.ui.CubaTabSheet.removeComponent(CubaTabSheet.java:215)
 at com.vaadin.ui.AbstractComponentContainer.removeAllComponents(AbstractComponentContainer.java:75)
 at com.haulmont.cuba.web.gui.components.WebTabSheet.removeAllTabs(WebTabSheet.java:404)
 at com.company.tabsheetlistenertest.web.screens.Screen.onRemoveTabsBtnClick(Screen.java:34)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at com.haulmont.cuba.gui.xml.DeclarativeAction.actionPerform(DeclarativeAction.java:92)
 at com.haulmont.cuba.web.gui.components.WebButton.performAction(WebButton.java:45)
 at com.haulmont.cuba.web.gui.components.WebButton.lambda$new$61446b05$1(WebButton.java:37)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
 at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:200)
 at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:163)
 at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1037)
 at com.vaadin.ui.Button.fireClick(Button.java:377)
 at com.haulmont.cuba.web.toolkit.ui.CubaButton.fireClick(CubaButton.java:54)
 at com.vaadin.ui.Button$1.click(Button.java:54)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
 at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:158)
 at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:119)
 at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:444)
 at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:409)
 at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274)
 at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:90)
 at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
 at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1435)
 at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:361)
 at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:312)
 at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:203)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:107)
 at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:73)
 at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:107)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
 at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
 at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
 at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
 at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
 at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 at java.lang.Thread.run(Thread.java:748)

TabSheetListenerTest.zip

@jreznot jreznot added the type: bug Something isn't working label Jul 19, 2018
@dtsaryov
Copy link
Contributor

dtsaryov commented Jul 19, 2018

It seems that this issue was fixed here: #913

@glebfox please check

@glebfox glebfox removed their assignment Jul 20, 2018
@glebfox
Copy link
Member

glebfox commented Jul 20, 2018

@dtsaryov you're right, this issue was fixed in the linked issue, but it appears that the fix wasn't merged to the Release 6.9 (see milestone).

@glebfox glebfox added the state: won't fix This will not be worked on label Jul 20, 2018
@glebfox glebfox closed this as completed Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: won't fix This will not be worked on type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants