Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.10.1
-
None
-
Unknown
Description
Rest route returns Response with http Status code 500 Internal Server Error and expected response headers/body when response has Last-Modified or Header-expires in header as string.
I found the issue in below code it try to convert string Wed, 31 Dec 1969 18:00:00 CS to Date and it fails. Is it posible to convert String Date without knowing Date format?
DefaultRestletBinding
=======================
if (header.equalsIgnoreCase(HeaderConstants.HEADER_LAST_MODIFIED)) {
if (value instanceof Calendar)
else if (value instanceof Date)
{ message.getEntity().setModificationDate((Date) value); }else
{ Date date = exchange.getContext().getTypeConverter().mandatoryConvertTo(Date.class, value); // Here it try to convert String to Date it throws No type converter available to convert from type: java.lang.String to the required type: java.util.Date with value Wed, 31 Dec 1969 18:00:00 CS message.getEntity().setModificationDate(date); }}
Stack trace
===========
7 Oct 2012 08:28:06,010 WARN org.restlet.Component.StatusFilter - Exception or error caught in status service
org.apache.camel.RuntimeCamelException: Cannot process request
at org.apache.camel.component.restlet.RestletConsumer$1.handle(RestletConsumer.java:62)
at org.apache.camel.component.restlet.MethodBasedRouter.handle(MethodBasedRouter.java:54)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Router.doHandle(Router.java:500)
at org.restlet.routing.Router.handle(Router.java:740)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Router.doHandle(Router.java:500)
at org.restlet.routing.Router.handle(Router.java:740)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:154)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.engine.ChainHelper.handle(ChainHelper.java:114)
at org.restlet.Component.handle(Component.java:391)
at org.restlet.Server.handle(Server.java:491)
at org.restlet.engine.ServerHelper.handle(ServerHelper.java:75)
at org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:153)
at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1031)
at org.apache.shiro.grails.SavedRequestFilter.doFilter(SavedRequestFilter.java:56)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:360)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:276)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:344)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:272)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:909)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: java.lang.String to the required type: java.util.Date with value Wed, 31 Dec 1969 18:00:00 CST
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:169)