0

Basically I have been using Vaadin Designer to design my UI. One of my use cases asks me to upload an iCalendar file, I use a grammar (ANTLR) to get from it what I need. I came across my issue when after seeing the Vaadin Upload documentation and applying it to my use case when running it, nothing would happen and no exception would be thrown. After a bit of research and debugging I believe this is due to the Thread for the upload being shutdown for some reason.

Here is my code, any help?

private void uploadLogic() {

    class IcalendarUploader implements Upload.Receiver, Upload.SucceededListener, Upload.FinishedListener, Upload.FailedListener {

        @Override
        public OutputStream receiveUpload(String filename, String mimeType) {

            try {
                //We'll store the uploadad file as temporary file.
                tempFile = File.createTempFile("temp", ".ics");
                fos =  new FileOutputStream(tempFile);
            } catch (IOException e) {
                Notification.show(e.getMessage(), Notification.Type.WARNING_MESSAGE);
                return null;
            }


        }

        @Override
        public void uploadFinished(Upload.FinishedEvent event) {

            try {
                controller.importIcalendar(tempFile);
                tempFile.delete();

                Notification.show("Uploaded iCalendar file with :\n" + controller.iCalendarDetails(),
                        Notification.Type.HUMANIZED_MESSAGE);

            } catch (IOException e) {

                Notification.show(e.getMessage(), Notification.Type.WARNING_MESSAGE);
            }

        }

        @Override
        public void uploadSucceeded(Upload.SucceededEvent event) {

            try {
                if(controller.saveTimeSlot()){
                    Notification.show("Uploaded iCalendar file with :\n" + controller.iCalendarDetails()
                                    +"\nSaved time slot with success",
                            Notification.Type.HUMANIZED_MESSAGE);
                }else {
                    Notification.show("Uploaded iCalendar file with :\n" + controller.iCalendarDetails()
                                    + "\nTime slot has an overlapp!",
                            Notification.Type.WARNING_MESSAGE);
                }
            } catch (DataConcurrencyException e) {
                Notification.show(e.getMessage(), Notification.Type.WARNING_MESSAGE);
            } catch (DataIntegrityViolationException e) {
                Notification.show(e.getMessage(), Notification.Type.WARNING_MESSAGE);
            }


        }

        @Override
        public void uploadFailed(Upload.FailedEvent event) {

            Notification.show("Upload failed", Notification.Type.ERROR_MESSAGE);
        }
    }

    IcalendarUploader receiver = new IcalendarUploader();
    upload.setReceiver(receiver);
}
  • 1
    do any of the error notification occur? Can you add logging with stack traces to these areas? – petey May 16 '17 at 15:34
  • @petey no warnings or notifications are reproduced when debugging the FileOutputStream it all goes good, I can even check that the temporary file that is generated is correct. What I see is that for some reason the thread is dumped so it never returns and the program continues to run like nothing had happened although the temporary files are being created. – Ricardo Silveira May 16 '17 at 15:38
  • This is the only exception that is thrown but only inside the debugger not on the prompt, inside the AbstractConnection class, that after this moves to the QueuedThreadPool to stop the Thread. Method threw 'java.lang.IllegalStateException' exception. Cannot evaluate org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.toString() – Ricardo Silveira May 16 '17 at 15:43
  • So you do not reach the uploadFailed or uploadSuccceeded method in debugger? – Steffen Harbich May 22 '17 at 14:26

0 Answers0