You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by "Malcolm Edgar (JIRA)" <ji...@apache.org> on 2010/01/18 13:02:54 UTC

[jira] Assigned: (CLK-613) Flush & close inconsistency

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

Malcolm Edgar reassigned CLK-613:
---------------------------------

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