When fixing FindBugs issues, we need to make sure that we follow the
original design intent of the affected code.

In the present case, it is a bug if the canProcess method is called
while master is still null. Wrapping the code in a test effectively
hides the bug, making it more difficult to diagnose. Adding assert
statements both enforces the design decision and makes FindBugs happy.

Thanks,
Vincent


On 31/01/12 14:56, vhenneb...@apache.org wrote:
> Author: vhennebert
> Date: Tue Jan 31 14:56:55 2012
> New Revision: 1238642
> 
> URL: http://svn.apache.org/viewvc?rev=1238642&view=rev
> Log:
> master is not supposed to still be null when canProcess is called
> 
> Modified:
>     
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
>     
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
> 
> Modified: 
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
> URL: 
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java?rev=1238642&r1=1238641&r2=1238642&view=diff
> ==============================================================================
> --- 
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
>  (original)
> +++ 
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterReference.java
>  Tue Jan 31 14:56:55 2012
> @@ -172,12 +172,8 @@ public class RepeatablePageMasterReferen
>  
>      /** {@inheritDoc} */
>      public boolean canProcess(String flowName) {
> -        if (master != null) {
> -            return 
> master.getRegion(FO_REGION_BODY).getRegionName().equals(flowName);
> -        }
> -        else {
> -            return false;
> -        }
> +        assert master != null;
> +        return 
> master.getRegion(FO_REGION_BODY).getRegionName().equals(flowName);
>      }
>  
>      /** {@inheritDoc} */
> 
> Modified: 
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
> URL: 
> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java?rev=1238642&r1=1238641&r2=1238642&view=diff
> ==============================================================================
> --- 
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
>  (original)
> +++ 
> xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/SinglePageMasterReference.java
>  Tue Jan 31 14:56:55 2012
> @@ -150,12 +150,8 @@ public class SinglePageMasterReference e
>  
>      /** {@inheritDoc} */
>      public boolean canProcess(String flowName) {
> -        if (master != null) {
> -            return 
> master.getRegion(FO_REGION_BODY).getRegionName().equals(flowName);
> -        }
> -        else {
> -            return false;
> -        }
> +        assert master != null;
> +        return 
> master.getRegion(FO_REGION_BODY).getRegionName().equals(flowName);
>      }
>  
>      /** {@inheritDoc} */

Reply via email to