You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Radu Manolescu (JIRA)" <ji...@apache.org> on 2008/06/24 14:48:45 UTC

[jira] Created: (CXF-1665) org.apache.cxf.jaxws.interceptors.SwAOutInterceptor:197 | Unreachable Code

org.apache.cxf.jaxws.interceptors.SwAOutInterceptor:197 | Unreachable Code
--------------------------------------------------------------------------

                 Key: CXF-1665
                 URL: https://issues.apache.org/jira/browse/CXF-1665
             Project: CXF
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.1.1
         Environment: This is a coding error which will manifest itself on every platform.
            Reporter: Radu Manolescu
            Priority: Minor


Examine the code fragment below to see that line 197 is unreachable:
On line 148, dh=null.
Then we test the object o for its data type, in a series of if/elseif
clauses.
There are two possibilities for the object o:
1. o instanceof Source / Image / DataHandler
2. all other situations
 
In situation 1, execution will enter the blocks after lines 151, or 155,
or 182, then continue from line 202.
In situation 2, execution will not enter any of the blocks after lines
151, or 155, or 182. As a result, dh is still null when we reach line
194, and a Fault is thrown.
Either way, execution cannot reach line 197.
 
package org.apache.cxf.jaxws.interceptors;
public class SwAOutInterceptor extends AbstractSoapInterceptor {
            DataHandler dh = null; // LINE 148            
            if (o instanceof Source) { // LINE 151
                dh = new DataHandler(createDataSource((Source)o, ct));

            } else if (o instanceof Image) { // LINE 155
                dh = new DataHandler(new ByteArrayDataSource(bos.toByteArray(), ct));
            } else if (o instanceof DataHandler) { // LINE 182
                dh = (DataHandler) o;
            } else if (dh == null) { // LINE 194
                throw new Fault(...);
            } else if (dh.getDataSource() instanceof URLDataSource) { // <========== LINE 197: UNREACHABLE
                URLDataSource ds = (URLDataSource)dh.getDataSource();
                dh = new DataHandler(ds.getURL()); 
                ct = ds.getContentType();
            } // LINE 201


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


[jira] Resolved: (CXF-1665) org.apache.cxf.jaxws.interceptors.SwAOutInterceptor:197 | Unreachable Code

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-1665?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp resolved CXF-1665.
------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.8
                   2.1.2
         Assignee: Daniel Kulp

> org.apache.cxf.jaxws.interceptors.SwAOutInterceptor:197 | Unreachable Code
> --------------------------------------------------------------------------
>
>                 Key: CXF-1665
>                 URL: https://issues.apache.org/jira/browse/CXF-1665
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.1.1
>         Environment: This is a coding error which will manifest itself on every platform.
>            Reporter: Radu Manolescu
>            Assignee: Daniel Kulp
>            Priority: Minor
>             Fix For: 2.1.2, 2.0.8
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Examine the code fragment below to see that line 197 is unreachable:
> On line 148, dh=null.
> Then we test the object o for its data type, in a series of if/elseif
> clauses.
> There are two possibilities for the object o:
> 1. o instanceof Source / Image / DataHandler
> 2. all other situations
>  
> In situation 1, execution will enter the blocks after lines 151, or 155,
> or 182, then continue from line 202.
> In situation 2, execution will not enter any of the blocks after lines
> 151, or 155, or 182. As a result, dh is still null when we reach line
> 194, and a Fault is thrown.
> Either way, execution cannot reach line 197.
>  
> package org.apache.cxf.jaxws.interceptors;
> public class SwAOutInterceptor extends AbstractSoapInterceptor {
>             DataHandler dh = null; // LINE 148            
>             if (o instanceof Source) { // LINE 151
>                 dh = new DataHandler(createDataSource((Source)o, ct));
>             } else if (o instanceof Image) { // LINE 155
>                 dh = new DataHandler(new ByteArrayDataSource(bos.toByteArray(), ct));
>             } else if (o instanceof DataHandler) { // LINE 182
>                 dh = (DataHandler) o;
>             } else if (dh == null) { // LINE 194
>                 throw new Fault(...);
>             } else if (dh.getDataSource() instanceof URLDataSource) { // <========== LINE 197: UNREACHABLE
>                 URLDataSource ds = (URLDataSource)dh.getDataSource();
>                 dh = new DataHandler(ds.getURL()); 
>                 ct = ds.getContentType();
>             } // LINE 201

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