You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "n0rad (JIRA)" <ji...@apache.org> on 2012/09/03 19:23:07 UTC

[jira] [Created] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

n0rad created CXF-4496:
--------------------------

             Summary: find of ResponseExceptionMapper do not handle runtime exceptions
                 Key: CXF-4496
                 URL: https://issues.apache.org/jira/browse/CXF-4496
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
    Affects Versions: 2.6.2
            Reporter: n0rad
            Priority: Minor


In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)

The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :

@Path("/")
public interface RestMcuBoardResource {
    @GET
    public RestMcuBoard getBoard();
}

does not work where this one work

@Path("/")
public interface RestMcuBoardResource {
    @GET
    public RestMcuBoard getBoard() throws runtimeException;
}

a fix could be :

    private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
        ProviderFactory pf = ProviderFactory.getInstance(message);
        for (Class<?> exType : m.getExceptionTypes()) {
            ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
            if (mapper != null) {
                return mapper;
            }
        }
+        return pf.createResponseExceptionMapper(RuntimeException.class);
-        return null; 
    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464579#comment-13464579 ] 

Sergey Beryozkin commented on CXF-4496:
---------------------------------------

I meant ClientErrorException (in case of JAX-RS 2.0): http://jax-rs-spec.java.net/nonav/2.0-SNAPSHOT/apidocs/javax/ws/rs/ClientErrorException.html, it has a constructor which accepts a status code and Throwable - the latter will be available at the RuntimeException mapper

                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "n0rad (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13447601#comment-13447601 ] 

n0rad commented on CXF-4496:
----------------------------

Example that store any kind of runtime and rebuild it on client side : 

{code:java}
public class AjslRuntimeExceptionMapper implements ExceptionMapper<RuntimeException> {

    private Logger log = LoggerFactory.getLogger(this.getClass());

    @Override
    public Response toResponse(RuntimeException exception) {
        log.warn("Uncaught RuntimeException", exception);

        Error error = new Error();
        error.setMessage(exception.getMessage());
        error.setErrorClass(exception.getClass());
        return Response.status(500).entity(error).build();
    }
}

public class AjslResponseExceptionMapper implements ResponseExceptionMapper<Exception> {

    @Override
    public Exception fromResponse(Response r) {
        Error errorModel = findErrorModel(r);
        Exception exception;
        if (errorModel.getErrorClass() != null) {
            try {
                exception = errorModel.getErrorClass().getConstructor(String.class)
                        .newInstance(Strings.nullToEmpty(errorModel.getMessage()));
            } catch (Exception e) {
                throw new RuntimeException("Cannot Create Exception from Error model : " + errorModel, e);
            }
        } else {
            exception = new RuntimeException(errorModel.getMessage());
        }
        return exception;
    }
}

{code}
                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464579#comment-13464579 ] 

Sergey Beryozkin edited comment on CXF-4496 at 9/27/12 8:35 PM:
----------------------------------------------------------------

I meant ClientErrorException (in case of JAX-RS 2.0): http://jax-rs-spec.java.net/nonav/2.0-SNAPSHOT/apidocs/javax/ws/rs/ClientErrorException.html, it has a constructor which accepts a status code and Throwable - the latter will be available at the RuntimeException catch block

                
      was (Author: sergey_beryozkin):
    I meant ClientErrorException (in case of JAX-RS 2.0): http://jax-rs-spec.java.net/nonav/2.0-SNAPSHOT/apidocs/javax/ws/rs/ClientErrorException.html, it has a constructor which accepts a status code and Throwable - the latter will be available at the RuntimeException mapper

                  
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "n0rad (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13447601#comment-13447601 ] 

n0rad edited comment on CXF-4496 at 9/4/12 9:38 PM:
----------------------------------------------------

Example that store any kind of runtime and rebuild it on client side : 

{code:java}
public class AjslRuntimeExceptionMapper implements ExceptionMapper<RuntimeException> {

    private Logger log = LoggerFactory.getLogger(this.getClass());

    @Override
    public Response toResponse(RuntimeException exception) {
        log.warn("Uncaught RuntimeException", exception);

        Error error = new Error();
        error.setMessage(exception.getMessage());
        error.setErrorClass(exception.getClass());
        return Response.status(500).entity(error).build();
    }
}

public class AjslResponseExceptionMapper implements ResponseExceptionMapper<Exception> {

    @Override
    public Exception fromResponse(Response r) {
        Error error = findError(r);
        Exception exception;
        if (error.getErrorClass() != null) {
            try {
                exception = error.getErrorClass().getConstructor(String.class)
                        .newInstance(Strings.nullToEmpty(error.getMessage()));
            } catch (Exception e) {
                throw new RuntimeException("Cannot Create Exception from Error : " + error, e);
            }
        } else {
            exception = new RuntimeException(error.getMessage());
        }
        return exception;
    }
}

{code}
                
      was (Author: n0rad):
    Example that store any kind of runtime and rebuild it on client side : 

{code:java}
public class AjslRuntimeExceptionMapper implements ExceptionMapper<RuntimeException> {

    private Logger log = LoggerFactory.getLogger(this.getClass());

    @Override
    public Response toResponse(RuntimeException exception) {
        log.warn("Uncaught RuntimeException", exception);

        Error error = new Error();
        error.setMessage(exception.getMessage());
        error.setErrorClass(exception.getClass());
        return Response.status(500).entity(error).build();
    }
}

public class AjslResponseExceptionMapper implements ResponseExceptionMapper<Exception> {

    @Override
    public Exception fromResponse(Response r) {
        Error errorModel = findErrorModel(r);
        Exception exception;
        if (errorModel.getErrorClass() != null) {
            try {
                exception = errorModel.getErrorClass().getConstructor(String.class)
                        .newInstance(Strings.nullToEmpty(errorModel.getMessage()));
            } catch (Exception e) {
                throw new RuntimeException("Cannot Create Exception from Error model : " + errorModel, e);
            }
        } else {
            exception = new RuntimeException(errorModel.getMessage());
        }
        return exception;
    }
}

{code}
                  
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "n0rad (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464248#comment-13464248 ] 

n0rad commented on CXF-4496:
----------------------------

Hum, I forget that you cannot know the specific RuntimeException so you can only handle RuntimeException globally (but still if the user has registered one).

                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464573#comment-13464573 ] 

Sergey Beryozkin commented on CXF-4496:
---------------------------------------

The client runtime guarantees (unless some bug is there) that it will throw ClientException (JAX-RS 2.0) or ServerWebApplicationExxception representing the remote service failure. To be honest I have doubts ResponseExceptionMapper has to be checked when proxies have no exception classes in the signature, however, at the same time, I guess proxies should be given a chance to 'pre-process' unchecked exceptions.

If you have a catch statement expecting RuntimeException, then with ResponseExceptionMapper<ClientException> (assuming it is CXF 2.7.0) the catch will work. However I also think that a catch expecting ClientException should also work, *irrespectively* of whether one has ResponseExceptionMapper or not. 

                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "Jonathan S Fisher (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464026#comment-13464026 ] 

Jonathan S Fisher commented on CXF-4496:
----------------------------------------

This is a fairly simple fix, any chance this could be included in the next release?
                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "n0rad (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464234#comment-13464234 ] 

n0rad commented on CXF-4496:
----------------------------

That's what I'm saying, maybe my example with RuntimeException is not a good one, it could be a responseExceptionMapper for SecurityException for example.

And if the user has not registered a ResponseExceptionMapper for SecurityException, it will throw the ServerWebApplicationException as expected. 
                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "n0rad (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13447600#comment-13447600 ] 

n0rad commented on CXF-4496:
----------------------------

but if the ExceptionMapper store the real class into the payload (for example SecurityException)

The client side should be able to reconstruct this Exception, and its working if you add throws RuntimeException into the signature.
                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "n0rad (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464222#comment-13464222 ] 

n0rad edited comment on CXF-4496 at 9/27/12 9:00 AM:
-----------------------------------------------------

If the user has registered a ResponseExceptionMapper for this RuntimeException class (or super), it will use it (exactly the same system as checked exception)

If the user has not registered a ResponseExceptionMapper for this class it will not found it, will return null and the caller function that is checkResponse() will build the ServerWebApplicationException.

It doesn't change the way its actually working until the user register an exceptionMapper for runtimes.


                
      was (Author: n0rad):
    If the user has registered a ResponseExceptionMapper for this RuntimeException class (or super), it will use it (exactly the same system as checked exception)

If the user has not registered a ResponseExceptionMapper for this class it will not found it, will return null and the caller function that is checkResponse() will build the ServerWebApplicationException.

It doesn't change the way its actually working until the user register an exceptionMapper for runtimes.

I don't see the point.

                  
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464201#comment-13464201 ] 

Sergey Beryozkin commented on CXF-4496:
---------------------------------------

I'm not really sure this is the right thing to do though.

I guess what might be done is add a check for JAX-RS 2.0 ClientException mapper (CXF 2.7.0), or, on CXF 2.6.2: ServerWebApplicationException

                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

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

n0rad updated CXF-4496:
-----------------------

    Description: 
In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)

The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :

{code:java} 
@Path("/")
public interface RestMcuBoardResource {
    @GET
    public RestMcuBoard getBoard();
}
{code} 

does not work where this one work

{code:java} 
@Path("/")
public interface RestMcuBoardResource {
    @GET
    public RestMcuBoard getBoard() throws runtimeException;
}
{code}

a fix could be :

{code:java} 
    private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
        ProviderFactory pf = ProviderFactory.getInstance(message);
        for (Class<?> exType : m.getExceptionTypes()) {
            ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
            if (mapper != null) {
                return mapper;
            }
        }
+        return pf.createResponseExceptionMapper(RuntimeException.class);
-        return null; 
    }

{code} 


  was:
In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)

The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :

@Path("/")
public interface RestMcuBoardResource {
    @GET
    public RestMcuBoard getBoard();
}

does not work where this one work

@Path("/")
public interface RestMcuBoardResource {
    @GET
    public RestMcuBoard getBoard() throws runtimeException;
}

a fix could be :

    private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
        ProviderFactory pf = ProviderFactory.getInstance(message);
        for (Class<?> exType : m.getExceptionTypes()) {
            ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
            if (mapper != null) {
                return mapper;
            }
        }
+        return pf.createResponseExceptionMapper(RuntimeException.class);
-        return null; 
    }

    
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464226#comment-13464226 ] 

Sergey Beryozkin commented on CXF-4496:
---------------------------------------

The point is that bare RuntimeException is not what the client runtime returns if no exception mapper has been found
                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

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

Sergey Beryozkin resolved CXF-4496.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.7.0
                   2.6.3
         Assignee: Sergey Beryozkin

in CXF 2.6.3 it is ServerWebApplicationException and in 2.7.0: WebApplicationException. ResponseExceptionMapper<WebApplicationException> will work in 2.6.3 and 2.7.0, and similarly - RuntimeException catch block will be executed
                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Assignee: Sergey Beryozkin
>            Priority: Minor
>             Fix For: 2.6.3, 2.7.0
>
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "n0rad (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464222#comment-13464222 ] 

n0rad commented on CXF-4496:
----------------------------

If the user has registered a ResponseExceptionMapper for this RuntimeException class (or super), it will use it (exactly the same system as checked exception)

If the user has not registered a ResponseExceptionMapper for this class it will not found it, will return null and the caller function that is checkResponse() will build the ServerWebApplicationException.

It doesn't change the way its actually working until the user register an exceptionMapper for runtimes.

I don't see the point.

                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4496) find of ResponseExceptionMapper do not handle runtime exceptions

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13447596#comment-13447596 ] 

Sergey Beryozkin commented on CXF-4496:
---------------------------------------

If no mapper is available then ServerWebApplicationException mapper gets thrown which is an instance of RuntimeException
                
> find of ResponseExceptionMapper do not handle runtime exceptions
> ----------------------------------------------------------------
>
>                 Key: CXF-4496
>                 URL: https://issues.apache.org/jira/browse/CXF-4496
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.2
>            Reporter: n0rad
>            Priority: Minor
>
> In org.apache.cxf.jaxrs.client.ClientProxyImpl.findExceptionMapper(Method, Message)
> The responseExceptionMapper is selected based on exception defined in the resource method signature but this method may have thrown a RuntimeException :
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard();
> }
> {code} 
> does not work where this one work
> {code:java} 
> @Path("/")
> public interface RestMcuBoardResource {
>     @GET
>     public RestMcuBoard getBoard() throws runtimeException;
> }
> {code}
> a fix could be :
> {code:java} 
>     private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
>         ProviderFactory pf = ProviderFactory.getInstance(message);
>         for (Class<?> exType : m.getExceptionTypes()) {
>             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
>             if (mapper != null) {
>                 return mapper;
>             }
>         }
> +        return pf.createResponseExceptionMapper(RuntimeException.class);
> -        return null; 
>     }
> {code} 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira