xmlgraphics-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vincent Hennebert <vhenneb...@gmail.com>
Subject Re: svn commit: r911864 - /xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java
Date Mon, 22 Feb 2010 12:41:01 GMT
Hi Jeremias,

> Author: jeremias
> Date: Fri Feb 19 16:37:29 2010
> New Revision: 911864
> 
> URL: http://svn.apache.org/viewvc?rev=911864&view=rev
> Log:
> Bugfix: Use a List and a sort instead of a SortedSet to avoid problems with the equals()
semantics. The result really depended on the entry order into the set rather than the order
implied by the penalty value. This could lead to the wrong pipeline being used.
> 
> Modified:
>     xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java
> 
> Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java
> URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java?rev=911864&r1=911863&r2=911864&view=diff
> ==============================================================================
> --- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java
(original)
> +++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java
Fri Feb 19 16:37:29 2010
> @@ -20,10 +20,11 @@
> @@ -143,7 +144,8 @@
>              // --> List of resulting flavors, possibly multiple loaders
>              loaderFactories = registry.getImageLoaderFactories(originalMime);
>              if (loaderFactories != null) {
> -                SortedSet candidates = new java.util.TreeSet(new PipelineComparator());
> +                List candidates = new java.util.ArrayList();
> +
>                  //Find best pipeline -> best loader
>                  for (int i = 0, ci = loaderFactories.length; i < ci; i++) {
>                      ImageLoaderFactory loaderFactory = loaderFactories[i];
> @@ -158,9 +160,10 @@
>                      }
>                  }
>  
> +                Collections.sort(candidates, new PipelineComparator());
>                  //Build final pipeline
>                  if (candidates.size() > 0) {
> -                    pipeline = (ImageProviderPipeline)candidates.first();
> +                    pipeline = (ImageProviderPipeline)candidates.get(0);
>                  }
>              }
>          }

Why do you store all the pipelines in a collection if in the end you
need only the best one?

Also, do you have a test case to reproduce the issue? So that any
further change does not introduce a regression.

Thanks,
Vincent

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Mime
View raw message