Re: svn commit: r810793 - /ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java

View: New views
3 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: svn commit: r810793 - /ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java

by Gilles Scokart :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

What is the benefits of having the parameters final ?


Gilles Scokart


2009/9/3 <bodewig@...>

> Author: bodewig
> Date: Thu Sep  3 07:26:20 2009
> New Revision: 810793
>
> URL: http://svn.apache.org/viewvc?rev=810793&view=rev
> Log:
> whitespace and make method paarameters final
>
> Modified:
>
>  ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
>
> Modified:
> ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
> URL:
> http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java?rev=810793&r1=810792&r2=810793&view=diff
>
> ==============================================================================
> ---
> ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
> (original)
> +++
> ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java
> Thu Sep  3 07:26:20 2009
> @@ -141,20 +141,20 @@
>         if (filtersCount > 0) {
>             boolean success = false;
>             try {
> -            for (int i = 0; i < filtersCount; i++) {
> -                Object o = finalFilters.elementAt(i);
> +                for (int i = 0; i < filtersCount; i++) {
> +                    Object o = finalFilters.elementAt(i);
>
> -                if (o instanceof AntFilterReader) {
> -                    instream =
> -                        expandReader((AntFilterReader)
> finalFilters.elementAt(i),
> -                                     instream, classLoadersToCleanUp);
> -                } else if (o instanceof ChainableReader) {
> -                    setProjectOnObject(o);
> -                    instream = ((ChainableReader) o).chain(instream);
> -                    setProjectOnObject(instream);
> +                    if (o instanceof AntFilterReader) {
> +                        instream =
> +                            expandReader((AntFilterReader)
> finalFilters.elementAt(i),
> +                                         instream, classLoadersToCleanUp);
> +                    } else if (o instanceof ChainableReader) {
> +                        setProjectOnObject(o);
> +                        instream = ((ChainableReader) o).chain(instream);
> +                        setProjectOnObject(instream);
> +                    }
>                 }
> -            }
> -            success = true;
> +                success = true;
>             } finally {
>                 if (!success && classLoadersToCleanUp.size() > 0) {
>                     cleanUpClassLoaders(classLoadersToCleanUp);
> @@ -221,8 +221,9 @@
>      *
>      * @since Ant 1.8.0
>      */
> -    private Reader expandReader(AntFilterReader filter, Reader ancestor,
> -                                List/*<AntClassLoader>*/
> classLoadersToCleanUp) {
> +    private Reader expandReader(final AntFilterReader filter,
> +                                final Reader ancestor,
> +                                final List/*<AntClassLoader>*/
> classLoadersToCleanUp) {
>         final String className = filter.getClassName();
>         final Path classpath = filter.getClasspath();
>         final Project pro = filter.getProject();
>
>
>

Re: svn commit: r810793 - /ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java

by Jeffrey E Care :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Gilles Scokart <gscokart@...> wrote on 09/03/2009 02:51:46 PM:

> Re: svn commit: r810793 - /ant/core/trunk/src/main/org/apache/tools/
> ant/filters/util/ChainReaderHelper.java
>
> What is the benefits of having the parameters final ?

It prevents you from inadvertently changing which object the parameter
name points to *within the method body*.

Re: svn commit: r810793 - /ant/core/trunk/src/main/org/apache/tools/ant/filters/util/ChainReaderHelper.java

by Stefan Bodewig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 2009-09-03, Gilles Scokart <gscokart@...> wrote:

> What is the benefits of having the parameters final ?

Apart from what Jeffrey said, the local variables that became parameters
when I extracted the method have been final in the first place - and I
wanted to stay true to the original code.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...