click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Malcolm Edgar (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (CLK-613) Flush & close inconsistency
Date Mon, 18 Jan 2010 12:12:54 GMT

     [ https://issues.apache.org/jira/browse/CLK-613?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Malcolm Edgar resolved CLK-613.
-------------------------------

    Resolution: Fixed

Fixed the ClickUtils.encoding bug. 

The other item is more of a discussion, can raise this as a separate issue for further consideration.

thanks Malcolm Edgar

> Flush & close inconsistency
> ---------------------------
>
>                 Key: CLK-613
>                 URL: https://issues.apache.org/jira/browse/CLK-613
>             Project: Click
>          Issue Type: Bug
>    Affects Versions: 2.1.0 RC1
>            Reporter: Andrey Rybin
>            Assignee: Malcolm Edgar
>
> 1) ClickUtils.encode has bug:
>    oos = new ObjectOutputStream(gos);
>             oos.writeObject(object);
>             oos.close();// <-- here must be .flush() 
>         } finally {
>             close(oos);
> 2) My suggestion is to add one new method to ClickUtils
> public static void flushAndClose (Closeable someStreamOrWriter) { //@Nullable
>     if (someStreamOrWriter != null) {
>       if (someStreamOrWriter instanceof Flushable) {//can be closed already - so IOException
is ok
>         try { ((Flushable) someStreamOrWriter).flush(); } catch (Throwable ignore) {}
>       }//if can flush
>       try {
>         someStreamOrWriter.close();
>       } catch (Throwable e) {
>         log.debug("flushAndClose: can't close "+ someStreamOrWriter, e);
>       }
>     }//i
>   }//flushAndClose
> and use it (as coding standard)  for  OutputStreams and Writers.
> 3) All occurrences of "safe" - "try { x.close() } catch.." - and - try { w.flush(); }
catch   try { w.close() - should be replaced with
> ClickUtils.close(x);
> ClickUtils.flushAndClose(w);
> Here my ".close coding standard violation" list:
> CompressionServletResponseWrapper
>    finishResponse
> VelocityTemplateService
>    getInitProperties
> ErrorReport
>    getRenderedSource
>    

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message