You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Daniel Kulp (JIRA)" <ji...@apache.org> on 2010/06/01 17:24:37 UTC

[jira] Assigned: (CXF-2835) ConcurrentModificationException in ClientImpl caused by toString-method on requestContext

     [ https://issues.apache.org/jira/browse/CXF-2835?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp reassigned CXF-2835:
--------------------------------

    Assignee: Daniel Kulp

> ConcurrentModificationException in ClientImpl caused by toString-method on requestContext
> -----------------------------------------------------------------------------------------
>
>                 Key: CXF-2835
>                 URL: https://issues.apache.org/jira/browse/CXF-2835
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2.6
>            Reporter: Henning Jensen
>            Assignee: Daniel Kulp
>
> We have about 10 threads running at the same time against the same web service. Some of the requests fail with the following stacktrace:
> {code}
> javax.xml.ws.soap.SOAPFaultException: Fault string, and possibly fault code, not set
> 	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:146)
> 	at $Proxy218.getFlightData(Unknown Source)
> 	at com.example.FlightDataAction.run(FlightDataAction.java:94)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> 	at java.lang.Thread.run(Thread.java:619)
> Caused by: java.util.ConcurrentModificationException
> 	at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
> 	at java.util.HashMap$EntryIterator.next(HashMap.java:834)
> 	at java.util.HashMap$EntryIterator.next(HashMap.java:832)
> 	at java.util.AbstractMap.toString(AbstractMap.java:485)
> 	at java.lang.String.valueOf(String.java:2826)
> 	at java.lang.StringBuilder.append(StringBuilder.java:115)
> 	at java.util.AbstractMap.toString(AbstractMap.java:490)
> 	at java.util.Collections$SynchronizedMap.toString(Collections.java:2026)
> 	at java.lang.String.valueOf(String.java:2826)
> 	at java.lang.StringBuilder.append(StringBuilder.java:115)
> 	at org.apache.cxf.endpoint.ClientImpl.processResult(ClientImpl.java:535)
> 	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:486)
> 	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:310)
> 	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:262)
> 	at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
> 	at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
> 	... 5 more
> {code}
> From ClientImpl:
> {code}
>     protected Map<Thread, Map<String, Object>> responseContext 
>         = Collections.synchronizedMap(new WeakHashMap<Thread, Map<String, Object>>());
> ....
>     protected Object[] processResult(Message message,
>                                    Exchange exchange,
>                                    BindingOperationInfo oi,
>                                    Map<String, Object> resContext) throws Exception {
> ....
>         // Grab the response objects if there are any
>         List resList = null;
>         Message inMsg = exchange.getInMessage();
>         if (inMsg != null) {
>             if (null != resContext) {
>                 resContext.putAll(inMsg);
>                 if (LOG.isLoggable(Level.FINE)) {
>                     LOG.fine("set responseContext to be" + responseContext);
>                 }
>             }
>             resList = inMsg.getContent(List.class);
>         }
> ...
> {code}
> The use of toString on responseContext is causing a ConcurrentModificationException when there are many threads working at the same time on the same service. The LOG.fine -line is not optimal since the string is actually resolved no matter if the log line is going to be written to the log file or not. Using String.format() would fix the issue when log level is not FINE, but would not fix the actual problem caused by many threads at the same time. I'm not sure what the developer wish to log in this cause, but limiting the object traversal and not using toString should do the trick. 

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


Re: How can I retrieve the full request path (URL)?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On Wed, Jun 2, 2010 at 12:55 PM, Tamar Furman (tfurman)
<tf...@cisco.com>wrote:

>
>  Hi -
>
> For internal service logging needs, is there a way to retrieve the full
> REST request url on the service method?
>

You can have a JAXRS UriInfo context injected as a field :
@Context UriInfo ui;

and then do either

ui.getAbsolutePath()
or
ui.getRequestURI() - this one will include the query params

cheers, Sergey

[1] https://jsr311.dev.java.net/releases/1.0/javax/ws/rs/core/UriInfo.html


> Thanks,
> T.
>

How can I retrieve the full request path (URL)?

Posted by "Tamar Furman (tfurman)" <tf...@cisco.com>.
 Hi - 

For internal service logging needs, is there a way to retrieve the full
REST request url on the service method?

Thanks,
T.

How can I retrieve the full request path (URL)?

Posted by "Tamar Furman (tfurman)" <tf...@cisco.com>.
 Hi - 

For internal service logging needs, is there a way to retrieve the full
REST request url on the service method?

Thanks,
T.