Repository: thrift Updated Branches: refs/heads/master 72268b78a -> 80a44f84f
THRIFT-2551 OutOfMemoryError "unable to create new native thread" kills serve thread Github Pull Request: This closes #112 Patch: Fuud Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/80a44f84 Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/80a44f84 Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/80a44f84 Branch: refs/heads/master Commit: 80a44f84fb161d77bf53261d024489df0aa7589c Parents: 72268b7 Author: Roger Meier <[email protected]> Authored: Thu May 29 16:25:22 2014 +0200 Committer: Roger Meier <[email protected]> Committed: Thu May 29 16:25:22 2014 +0200 ---------------------------------------------------------------------- .../src/org/apache/thrift/server/TThreadPoolServer.java | 10 ++++++++++ 1 file changed, 10 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/80a44f84/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java ---------------------------------------------------------------------- diff --git a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java old mode 100644 new mode 100755 index 7229d89..488d17f --- a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java +++ b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java @@ -139,6 +139,16 @@ public class TThreadPoolServer extends TServer { Thread.currentThread().interrupt(); break; } + } catch(OutOfMemoryError ex) { + LOGGER.warn("ExecutorService throws OutOfMemoryError "+ ex.getMessage() + (++rejections) + + " times(s)", ex); + try { + TimeUnit.SECONDS.sleep(1); + } catch (InterruptedException e) { + LOGGER.warn("Interrupted while waiting to place client on executor queue."); + Thread.currentThread().interrupt(); + break; + } } } } catch (TTransportException ttx) {
