Project

Profile

Help

Bug #3400

closed

saxon:send-mail fails with NullPointerException if any configuration options are absent

Added by Michael Kay over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Category:
Saxon extensions
Sprint/Milestone:
-
Start date:
2017-08-18
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7, 9.8
Fix Committed on Branch:
9.8
Fixed in Maintenance Release:
Platforms:

Description

See https://stackoverflow.com/questions/45741043/saxonsend-mail-function-return-java-lang-nullpointerexception-error

Created test case (in xslt3extra test suite) send-mail-001.

The code in checkMailProperty reads a property from the options map and fails with an NPE if it is absent.

Actions #1

Updated by Michael Kay over 6 years ago

Also, the "cc" option appears to be missing from the documentation.

Actions #2

Updated by Michael Kay over 6 years ago

Also, the example in the documentation uses the old map syntax with :=" rather than

Actions #3

Updated by Michael Kay over 6 years ago

  • Status changed from New to In Progress

I have rewritten the way that the SendMail function processes its first argument, to exploit the utility class OptionsParameter which is used to support all 3.1 functions having a map-valued options parameter.

I have changed boolean-valued parameters like "html" to accept a boolean, and integer-valued parameters like "port" to accept an integer, but for backwards compatibility I've retained the ability to convert this from a string by means of a new feature in the OptionsParameter class.

I've also added to the OptionsParameter class the ability to declare that certain properties are mandatory. We still need to review which parameters should be mandatory: I'm not sure for example whether it makes sense for username and password to be omitted.

I've extended the implementation so that if the first argument contains any (string-valued) property whose name begins with "mail.", it is copied to the properties supplied to the call on Session.getDefaultInstance(), to allow setting of properties such as "mail.smtp.timeout".

These changes need to be documented.

Actions #5

Updated by Michael Kay over 6 years ago

I have committed these changes to 9.8 as they appear to cause no regression, but before closing the issue we need

(a) to update the documentation

(b) to review exactly which of the mail parameters should be marked as required, and which can sensibly be omitted or defaulted.

Actions #6

Updated by Michael Kay over 6 years ago

  • Assignee changed from Michael Kay to O'Neil Delpratt
Actions #7

Updated by Michael Kay over 6 years ago

  • Fix Committed on Branch 9.8 added
Actions #8

Updated by O'Neil Delpratt over 6 years ago

Michael Kay wrote:

I have committed these changes to 9.8 as they appear to cause no regression, but before closing the issue we need

(a) to update the documentation

(b) to review exactly which of the mail parameters should be marked as required, and which can sensibly be omitted or defaulted.

The java mail API documentation gives details are required in the method getDefaultInstance(Properties props) on the Session class.

See: https://javaee.github.io/javamail/docs/api/

Also see: https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html

Which states:

It is expected that the client supplies values for the properties listed in Appendix A of the JavaMail spec (particularly mail.store.protocol, mail.transport.protocol, mail.host, mail.user, and mail.from) as the defaults are unlikely to work in all cases.

See Appendix A: https://javaee.github.io/javamail/docs/JavaMail-1.4.pdf

Key parameters:

  • mail.smtp.user

  • mail.smtp.host (smtp-server)

  • to (is not in the appendix but is still required to send the mail)

Actions #9

Updated by O'Neil Delpratt over 6 years ago

  • Status changed from In Progress to Resolved

Marking this as resolved: Documentation and code has been updated.

Actions #10

Updated by O'Neil Delpratt over 6 years ago

  • % Done changed from 0 to 100

Bug fix applied in the Saxon 9.8.0.7 maintenance release.

Actions #11

Updated by O'Neil Delpratt over 6 years ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 9.8.0.7 added

Please register to edit this issue

Also available in: Atom PDF