Commons Email
  1. Commons Email
  2. EMAIL-71

Email.getHostName() throws NullPointerException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.2
    • Labels:
      None

      Description

      If setHostName() has not been called, getHostName() tries to return this.session.getProperty(MAIL_HOST). If mail session has not been created yet, this will throw a NullPointerException. getHostName() should check that this.session is not null before trying to access it.

      The same applies to getSmtpPort() and getSslSmtpPort().

        Activity

        Hide
        Henri Yandell added a comment -

        Confirmed - question being, return null or throw an IllegalStateException?

        Show
        Henri Yandell added a comment - Confirmed - question being, return null or throw an IllegalStateException?
        Hide
        Carsten Ziegeler added a comment -

        I ran into the same problem today I think it should return null as it's just a getter method.
        I wanted to use this method to check, if someone else has already set the host name and if not apply a default.

        Show
        Carsten Ziegeler added a comment - I ran into the same problem today I think it should return null as it's just a getter method. I wanted to use this method to check, if someone else has already set the host name and if not apply a default.
        Hide
        Siegfried Goeschl added a comment -

        Reviews and applied the patch - thanks to Corey Scott again ...

        Show
        Siegfried Goeschl added a comment - Reviews and applied the patch - thanks to Corey Scott again ...

          People

          • Assignee:
            Siegfried Goeschl
            Reporter:
            Teemu Lång
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development