You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Henrik Nordberg (JIRA)" <ax...@ws.apache.org> on 2005/06/30 19:35:58 UTC

[jira] Created: (AXISCPP-721) Axis###Exception::getMessage() returns a static variable

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

         Key: AXISCPP-721
         URL: http://issues.apache.org/jira/browse/AXISCPP-721
     Project: Axis-C++
        Type: Bug
  Components: Server - Engine  
    Versions: current (nightly)    
    Reporter: Henrik Nordberg
    Priority: Minor


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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (AXISCPP-721) Axis###Exception::getMessage() returns a static variable

Posted by "Dushshantha Chandradasa (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-721?page=all ]
     
Dushshantha Chandradasa closed AXISCPP-721:
-------------------------------------------


> Axis###Exception::getMessage() returns a static variable
> --------------------------------------------------------
>
>          Key: AXISCPP-721
>          URL: http://issues.apache.org/jira/browse/AXISCPP-721
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Minor
>  Attachments: ExceptionModel_before.JPG
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (AXISCPP-721) Axis###Exception::getMessage() returns a static variable

Posted by "Dushshantha Chandradasa (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-721?page=all ]

Dushshantha Chandradasa reassigned AXISCPP-721:
-----------------------------------------------

    Assign To: Dushshantha Chandradasa

> Axis###Exception::getMessage() returns a static variable
> --------------------------------------------------------
>
>          Key: AXISCPP-721
>          URL: http://issues.apache.org/jira/browse/AXISCPP-721
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Minor

>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (AXISCPP-721) Axis###Exception::getMessage() returns a static variable

Posted by "Dushshantha Chandradasa (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-721?page=all ]

Dushshantha Chandradasa updated AXISCPP-721:
--------------------------------------------

    Attachment: ExceptionModel_before.JPG

Samisa wrote: 


PFA the class diagram of current exception model we have.

            

            Looking into the several issues we have against the exception model, it is worth considering a re-arrangement here.

http://issues.apache.org/jira/browse/AXISCPP-707

http://issues.apache.org/jira/browse/AXISCPP-721

http://issues.apache.org/jira/browse/AXISCPP-722

 

            The idea is *very* simple here.  (basic OO stuff)

1.       We have m_sMessage and m_iExceptionCode as data members in all the derived classes – move them to base class. Move the access methods to the base class as well.

2.       Drop all processException() methods and move the logic to constructor

3.       getMessage() methods in the derived classes do not get the message rather return the message corresponding to the exception code. Hence rename getMessage() getMessageForExceptionCode()

4.       We have “what()” in the base class to get the error message. This is a virtual method inherited from the ‘exception’ class hence we cannot change the naming. However, better to have a more sensible name like getMessage to wrap this

5.       There are too many constructors in the derived classes, I would like only two constructors for each class

a.       Copy constructor

b.       Constructor with 2 parameters, exception code and message, with message defaulting to null. ExceptionClass(int code, char* msg = null)

 



> Axis###Exception::getMessage() returns a static variable
> --------------------------------------------------------
>
>          Key: AXISCPP-721
>          URL: http://issues.apache.org/jira/browse/AXISCPP-721
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Minor
>  Attachments: ExceptionModel_before.JPG
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-721) Axis###Exception::getMessage() returns a static variable

Posted by "Henrik Nordberg (JIRA)" <ax...@ws.apache.org>.
    [ http://issues.apache.org/jira/browse/AXISCPP-721?page=comments#action_12315082 ] 

Henrik Nordberg commented on AXISCPP-721:
-----------------------------------------

 Samisa wrote: 
>
> b. Constructor with 2 parameters, exception code and message, with message defaulting to null. ExceptionClass(int code, char* msg = null)
>

Please change the second argument from char* to const char*, if you must use C style strings. Having it non-const implies that ExceptionClass will own that pointer, which I don't think is the intention (even if that was the case before).

Also, and I know I have suggested this a couple of times already, but why not use "const std::string&" ?

Thanks
 - Henrik

> Axis###Exception::getMessage() returns a static variable
> --------------------------------------------------------
>
>          Key: AXISCPP-721
>          URL: http://issues.apache.org/jira/browse/AXISCPP-721
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Minor
>  Attachments: ExceptionModel_before.JPG
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (AXISCPP-721) Axis###Exception::getMessage() returns a static variable

Posted by "Dushshantha Chandradasa (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-721?page=all ]
     
Dushshantha Chandradasa resolved AXISCPP-721:
---------------------------------------------

    Resolution: Fixed

Made modifications to the Exception model.

> Axis###Exception::getMessage() returns a static variable
> --------------------------------------------------------
>
>          Key: AXISCPP-721
>          URL: http://issues.apache.org/jira/browse/AXISCPP-721
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Minor
>  Attachments: ExceptionModel_before.JPG
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-721) Axis###Exception::getMessage() returns a static variable

Posted by "Dushshantha Chandradasa (JIRA)" <ax...@ws.apache.org>.
    [ http://issues.apache.org/jira/browse/AXISCPP-721?page=comments#action_12315119 ] 

Dushshantha Chandradasa commented on AXISCPP-721:
-------------------------------------------------

>> Please change the second argument from char* to const char*, if you must use C style strings. Having it non-const implies that ExceptionClass will own that pointer, which I don't think is the intention (even if that was the case before). 
  
      Yes i changed it to const char* .  Thank you very much henrik 


>>Also, and I know I have suggested this a couple of times already, but why not use "const std::string&" ? 


Mark wrote:

STL is being removed from the Axis C++ external API (AXISCPP-681 and others). If you are OK with this, please could you make m_sMessage a const
char* instead of a std::string? I realise this involves more code but it helps to avoid incompatibilities in the STL.
Thanks,
Mark



> Axis###Exception::getMessage() returns a static variable
> --------------------------------------------------------
>
>          Key: AXISCPP-721
>          URL: http://issues.apache.org/jira/browse/AXISCPP-721
>      Project: Axis-C++
>         Type: Bug
>   Components: Server - Engine
>     Versions: current (nightly)
>     Reporter: Henrik Nordberg
>     Assignee: Dushshantha Chandradasa
>     Priority: Minor
>  Attachments: ExceptionModel_before.JPG
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira