Uploaded image for project: 'Axis-C++'
  1. Axis-C++
  2. AXISCPP-721

Axis###Exception::getMessage() returns a static variable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • current (nightly)
    • None
    • Server - Engine
    • None

    Description

      Axis exceptions' method getMessage() returns a static variable. Here is an example of the code for AxisSoapException:

      const string AxisSoapException::getMessage (const exception* objException)
      {
      static string objExDetail = objException->what();

      return objExDetail;
      }

      What is the purpose of making objExDetail static? Doing so means that it is initialized the first time this method is called (once per instance of the class), and after that the same value will be returned no matter what objException is. Here is a version without static:

      string AxisSoapException::getMessage (const exception& objException) const {
      return objException.what();
      }

      I also made the method const since we will not modify members. Also why use a pointer when we don't have to?
      I also think that since this code is common between Axis exceptions, it should be move to a common base class.

      Attachments

        1. ExceptionModel_before.JPG
          171 kB
          Marcus Dushshantha Chandradasa

        Activity

          People

            dchandradasa Marcus Dushshantha Chandradasa
            hnordberg Henrik Nordberg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: