Vaadin UI.access () throws an ExecutionException

I see this exception in the Vaadin project. However, the functionality does not really break. The code in the method run()does what it intends to complete, but this exception appears.

E 140619 124701.131 [Thread-2] MainUI - Uncaught throwable: 
java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
    at com.vaadin.server.VaadinSession$FutureAccess.get(VaadinSession.java:123)
    at com.vaadin.server.VaadinService.runPendingAccessTasks(VaadinService.java:1802)
    at com.vaadin.server.VaadinSession.unlock(VaadinSession.java:1012)
    at com.vaadin.server.VaadinService.ensureAccessQueuePurged(VaadinService.java:1763)
    at com.vaadin.server.VaadinService.accessSession(VaadinService.java:1729)
    at com.vaadin.server.VaadinSession.access(VaadinSession.java:1402)
    at com.vaadin.ui.UI.access(UI.java:1372)

going on here

ui.acccess(new Runnable() {
    @Override
    public void run() {
        //code here
    }
} 

What should I do? Can I just throw an exception and ignore it, or is there an error somewhere in my code?

It uses the @Push annotation for MainUI extends the interface and there is code like:

@Override
protected void init(VaadinRequest request) {
    WrappedSession wrappedSession = request.getWrappedSession();
    final String id = wrappedSession.getId();
    log.info("Created new UI for session id {}", id);

    VaadinSession.getCurrent().setErrorHandler(new DefaultErrorHandler() {
        @Override
        public void error(com.vaadin.server.ErrorEvent event) {
            super.error(event);
            log.error("Uncaught throwable: ", event.getThrowable());
        }
    });

    ...
}

Another example

[This section was added by another author]

I, Basil Bourque, I get the same exception in the same use. The exception is selected for use in production (and not for development).

Using Vaadin 7.1.3 with Push with Tomcat 8.0.12 on Java 8 Update 20 on Mac OS X Mountain Lion.

An exception:

Nov 04, 2014 4:45:50 AM com.vaadin.server.DefaultErrorHandler doDefault
SEVERE: 
java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at com.vaadin.server.VaadinSession$FutureAccess.get(VaadinSession.java:123)
    at com.vaadin.server.VaadinService.runPendingAccessTasks(VaadinService.java:1800)
    at com.vaadin.server.VaadinSession.unlock(VaadinSession.java:1013)
    at com.vaadin.server.VaadinService.ensureAccessQueuePurged(VaadinService.java:1761)
    at com.vaadin.server.VaadinService.accessSession(VaadinService.java:1727)
    at com.vaadin.server.VaadinSession.access(VaadinSession.java:1403)
    at com.vaadin.ui.UI.access(UI.java:1389)
    at com.rainwatersoft.powerwrangler.curr_sup_dem.CurrSupDemReportUpdater.update(CurrSupDemReportUpdater.java:164)
    at com.rainwatersoft.powerwrangler.curr_sup_dem.CurrSupDemReportUpdater.checkForUpdate(CurrSupDemReportUpdater.java:125)
    at com.rainwatersoft.powerwrangler.curr_sup_dem.CurrSupDemReportUpdater.lambda$considerUpdate$2(CurrSupDemReportUpdater.java:110)
    at com.rainwatersoft.powerwrangler.curr_sup_dem.CurrSupDemReportUpdater$$Lambda$3/1011224121.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException

Lambda Java 8 Runnable UI:: access.

layout.getUI().access( () -> { // Runnable
    layout.freshen( this.interval );
} );
+4
1

:

// remember UI and request attributes
val ui = UI.getCurrent
val attributes = RequestContextHolder.getRequestAttributes

future.onSuccess {
  case e => ui.access(
    new Runnable {
      override def run(): Unit = {
        try {
          RequestContextHolder.setRequestAttributes(attributes)
          success.apply(e)
        } finally {
          RequestContextHolder.resetRequestAttributes()
        }
      }
    }
  )
}

future.onFailure {
  case t => ui.access(
    new Runnable {
      override def run(): Unit = {
        try {
          _logger.error("Something goes wrong in async await request", t)
          RequestContextHolder.setRequestAttributes(attributes)
          failure.apply(t)
        } finally {
          RequestContextHolder.resetRequestAttributes()
        }
      }
    }
  )
}

spring4vaadin Vaadin 7.2.x.

0

Source: https://habr.com/ru/post/1545800/


All Articles