You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stefan Magnus Landrø <st...@gmail.com> on 2011/05/18 12:06:12 UTC

Serialization of stackTrace in REST-plugin

Hi there,

We are seeing some serialized stacktraces in addition to our custom
exception result in our json-output after upgrading to 2.2.3. Is there
a way to turn it off?

Cheers

Stefan

-- 
BEKK Open
http://open.bekk.no

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Serialization of stackTrace in REST-plugin

Posted by Stefan Magnus Landrø <st...@gmail.com>.
Hi there,

I'm not sure if you're right. It seems like our exception result is
never returned, only the exception itself, including the stacktrace.

Cheers,

Stefan

On Wed, May 18, 2011 at 5:51 PM, Martin Gainty <mg...@hotmail.com> wrote:
> it appears you have encountered a bug here is why:
> http://download.oracle.com/javase/6/docs/api/java/io/Writer.html#write%28java.lang.String%29
>
> org.apache.struts2.rest.handler.JsonLibHandler:
>  public String fromObject(Object obj, String resultCode, java.io.Writer
> stream) throws IOException {
>         if (obj != null) {
>             if (isArray(obj)) {
>                 JSONArray jsonArray = JSONArray.fromObject(obj);
>                 stream.write(jsonArray.toString());
>             } else {
>                 JSONObject jsonObject = JSONObject.fromObject(obj);
>                 stream.write(jsonObject.toString());
>             }
>         }
>         return null;
>     }
>
> //notice the stream.write is not covered by try/catch as in
> try {
>  stream.write(jsonArray.toString());
> }
> catch(java.io.Exception ioe)
> {
>  System.err.println("IOException has been encountered in
> org.apache.struts2.rest.handler.JsonLibHandler::fromObject");
> }
> ... so the stack trace produced by IOException would be returned..
>
> good catch!
> Martin Gainty
> ______________________________________________
> Note de déni et de confidentialité
>
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
> de ceci est interdite. Ce message sert à l'information seulement et n'aura
> pas n'importe quel effet légalement obligatoire. Étant donné que les email
> peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
> aucune responsabilité pour le contenu fourni.
>
>
>
>
>> Date: Wed, 18 May 2011 12:06:12 +0200
>> Subject: Serialization of stackTrace in REST-plugin
>> From: stefan.landro@gmail.com
>> To: user@struts.apache.org
>>
>> Hi there,
>>
>> We are seeing some serialized stacktraces in addition to our custom
>> exception result in our json-output after upgrading to 2.2.3. Is there
>> a way to turn it off?
>>
>> Cheers
>>
>> Stefan
>>
>> --
>> BEKK Open
>> http://open.bekk.no
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>



-- 
BEKK Open
http://open.bekk.no

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org