@Override public Throwable getCause() { return exception.getCause(); }
if (e.getCause() instanceof NullPointerException) { failed.getAndIncrement();
/** * @see MessageBodyWriter#writeTo(Object, Class, Type, Annotation[], * MediaType, MultivaluedMap, OutputStream) */ public void writeTo(Multipart multipart, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { try { multipart.writeTo(entityStream); } catch (MessagingException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } final IOException ioExc = new IOException( "Could not serialize the Multipart"); ioExc.initCause(e); throw ioExc; } } }
/** * @see MessageBodyReader#readFrom(Class, Type, Annotation[], MediaType, * MultivaluedMap, InputStream) */ public Multipart readFrom(Class<Multipart> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpResponseHeaders, InputStream entityStream) throws IOException { final String contentType = "multipart/form-data"; final DataSource ds = new ByteArrayDataSource(entityStream, contentType); try { return new MimeMultipart(ds); } catch (MessagingException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } final IOException ioExc = new IOException( "Could not deserialize the data to a Multipart"); ioExc.initCause(e); throw ioExc; } }
/** * Generates output for requests that target media resources. */ public void generate(OutputStream contentStream, OutputProperties request, MediaMultipart source) throws IOException { OutputProperties prevProperties = null; try { prevProperties = GDataContentHandler.setThreadOutputProperties(request); source.writeTo(contentStream); } catch (MessagingException me) { // Unwrap basic I/O errors Throwable t = me.getCause(); if (t instanceof IOException) { throw (IOException) t; } // Wrap others based upon an invalid input entry IOException ioe = new IOException("Invalid multipart content"); ioe.initCause(new InvalidEntryException("Invalid media entry", me)); throw ioe; } finally { GDataContentHandler.setThreadOutputProperties(prevProperties); } } }
/** * Generates output for requests that target media resources. */ public void generate(OutputStream contentStream, OutputProperties request, MediaMultipart source) throws IOException { OutputProperties prevProperties = null; try { prevProperties = GDataContentHandler.setThreadOutputProperties(request); source.writeTo(contentStream); } catch (MessagingException me) { // Unwrap basic I/O errors Throwable t = me.getCause(); if (t instanceof IOException) { throw (IOException) t; } // Wrap others based upon an invalid input entry IOException ioe = new IOException("Invalid multipart content"); ioe.initCause(new InvalidEntryException("Invalid media entry", me)); throw ioe; } finally { GDataContentHandler.setThreadOutputProperties(prevProperties); } } }
private ExecutionResult doDeliver(Mail mail, InternetAddress[] addr, Iterator<HostAddress> targetServers) throws MessagingException { MessagingException lastError = null; while (targetServers.hasNext()) { try { return mailDelivrerToHost.tryDeliveryToHost(mail, addr, targetServers.next()); } catch (SendFailedException sfe) { lastError = handleSendFailExceptionOnMxIteration(mail, sfe); } catch (MessagingException me) { lastError = handleMessagingException(mail, me); if (configuration.isDebug()) { LOGGER.debug(me.getMessage(), me.getCause()); } else { LOGGER.info(me.getMessage()); } } } // If we encountered an exception while looping through, // throw the last MessagingException we caught. We only // do this if we were unable to send the message to any // server. If sending eventually succeeded, we exit // deliver() though the return at the end of the try // block. if (lastError != null) { throw lastError; } return ExecutionResult.temporaryFailure(); }
e.printStackTrace(); } catch (MessagingException e) { logger.warn(new MailerException("Unable to sent email to "+mailerConfigurator.getRecipients()+": "+e.getMessage()), e.getCause()); e.printStackTrace(); } catch (IOException e) {