Skip to content
Permalink
Browse files
[CXF-5559] Preventing the infinite loop in case of connection excepti…
…ons during the async calls, patch applied on behalf of Anthony Communier

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1568343 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Sergey Beryozkin committed Feb 14, 2014
1 parent 44de359 commit 4200019973e2b5445d85443baed00dc0eb98d30c
Showing 1 changed file with 46 additions and 43 deletions.
@@ -1153,54 +1153,57 @@ public void run() {
}
};
HTTPClientPolicy policy = getClient(outMessage);
try {
Executor ex = outMessage.getExchange().get(Executor.class);
if (forceWQ && ex != null) {
final Executor ex2 = ex;
final Runnable origRunnable = runnable;
runnable = new Runnable() {
public void run() {
outMessage.getExchange().put(Executor.class.getName()
+ ".USING_SPECIFIED", Boolean.TRUE);
ex2.execute(origRunnable);
boolean exceptionSet = outMessage.getContent(Exception.class) != null;
if (!exceptionSet) {
try {
Executor ex = outMessage.getExchange().get(Executor.class);
if (forceWQ && ex != null) {
final Executor ex2 = ex;
final Runnable origRunnable = runnable;
runnable = new Runnable() {
public void run() {
outMessage.getExchange().put(Executor.class.getName()
+ ".USING_SPECIFIED", Boolean.TRUE);
ex2.execute(origRunnable);
}
};
}
if (ex == null || forceWQ) {
WorkQueueManager mgr = outMessage.getExchange().get(Bus.class)
.getExtension(WorkQueueManager.class);
AutomaticWorkQueue qu = mgr.getNamedWorkQueue("http-conduit");
if (qu == null) {
qu = mgr.getAutomaticWorkQueue();
}
};
}
if (ex == null || forceWQ) {
WorkQueueManager mgr = outMessage.getExchange().get(Bus.class)
.getExtension(WorkQueueManager.class);
AutomaticWorkQueue qu = mgr.getNamedWorkQueue("http-conduit");
if (qu == null) {
qu = mgr.getAutomaticWorkQueue();
long timeout = 1000;
if (policy != null && policy.isSetAsyncExecuteTimeout()) {
timeout = policy.getAsyncExecuteTimeout();
}
if (timeout > 0) {
qu.execute(runnable, timeout);
} else {
qu.execute(runnable);
}
} else {
outMessage.getExchange().put(Executor.class.getName()
+ ".USING_SPECIFIED", Boolean.TRUE);
ex.execute(runnable);
}
long timeout = 1000;
if (policy != null && policy.isSetAsyncExecuteTimeout()) {
timeout = policy.getAsyncExecuteTimeout();
} catch (RejectedExecutionException rex) {
if (allowCurrentThread
&& policy != null
&& policy.isSetAsyncExecuteTimeoutRejection()
&& policy.isAsyncExecuteTimeoutRejection()) {
throw rex;
}
if (timeout > 0) {
qu.execute(runnable, timeout);
} else {
qu.execute(runnable);
if (!hasLoggedAsyncWarning) {
LOG.warning("EXECUTOR_FULL_WARNING");
hasLoggedAsyncWarning = true;
}
} else {
outMessage.getExchange().put(Executor.class.getName()
+ ".USING_SPECIFIED", Boolean.TRUE);
ex.execute(runnable);
}
} catch (RejectedExecutionException rex) {
if (allowCurrentThread
&& policy != null
&& policy.isSetAsyncExecuteTimeoutRejection()
&& policy.isAsyncExecuteTimeoutRejection()) {
throw rex;
LOG.fine("EXECUTOR_FULL");
handleResponseInternal();
}
if (!hasLoggedAsyncWarning) {
LOG.warning("EXECUTOR_FULL_WARNING");
hasLoggedAsyncWarning = true;
}
LOG.fine("EXECUTOR_FULL");
handleResponseInternal();
}
}
}


0 comments on commit 4200019

Please sign in to comment.