{"id":10006078,"date":"2022-08-01T18:18:19","date_gmt":"2022-08-01T10:18:19","guid":{"rendered":"https:\/\/ityet.com\/?p=10006078"},"modified":"2022-08-01T18:18:19","modified_gmt":"2022-08-01T10:18:19","slug":"%e5%85%b3%e4%ba%8erequest%e5%a4%8d%e7%94%a8%e7%9a%84%e9%82%a3%e7%82%b9%e7%a0%b4%e4%ba%8b%e5%84%bf%e3%80%82","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006078","title":{"rendered":"\u5173\u4e8eRequest\u590d\u7528\u7684\u90a3\u70b9\u7834\u4e8b\u513f\u3002"},"content":{"rendered":"<p>\u4f60\u597d\u5440\uff0c \u6211\u662f\u6b6a\u6b6a\u3002<\/p>\n<p>\u4e4b\u524d\u4e0d\u662f\u53d1\u5e03\u4e86\u8fd9\u7bc7\u6587\u7ae0\u561b:<a href=\"https:\/\/link.segmentfault.com\/?enc=IwmUW1d5xbHzrA%2BQ4hTdWw%3D%3D.7B7p0apYeV9rHKnh4dohD37lSiOgMTACfLIA3xrKEy16KnTi6V9mK9%2F6te3qjCcGQUOC74msj8wdY3uMWekw5g%3D%3D\" rel=\"nofollow\">\u300a\u5343\u4e07\u4e0d\u8981\u628aRequest\u4f20\u9012\u5230\u5f02\u6b65\u7ebf\u7a0b\u91cc\u9762\uff01\u6709\u5751\uff01\u300b<\/a><\/p>\n<p>\u8bf4\u7684\u662f\u7531\u4e8e Request \u5728 tomcat \u91cc\u9762\u662f\u590d\u7528\u7684\uff0c\u6240\u4ee5\u5982\u679c\u5728\u4e00\u4e2a Request \u7684\u751f\u547d\u5468\u671f\u5b8c\u6210\u4e4b\u540e\uff0c\u5728\u5f02\u6b65\u7ebf\u7a0b\u91cc\u9762\u8c03\u7528\u4e86\u76f8\u5173\u7684\u65b9\u6cd5\uff0c\u4f1a\u5bfc\u81f4\u8fd9\u4e2a Request \u88ab\u6c61\u67d3\uff0c\u7136\u540e\u5728\u4e0b\u4e00\u4e2a\u8bf7\u6c42\u4e2d\u89c2\u5bdf\u5230\u4e00\u4e9b\u532a\u5937\u6240\u601d\u7684\u573a\u666f\u3002<\/p>\n<p>\u4f46\u662f\u6587\u7ae0\u7684\u8bc4\u8bba\u533a\u91cc\u9762\u51fa\u73b0\u4e86\u4e2a\u95ee\u9898\uff0c\u8fd8\u4e00\u4e0b\u628a\u6211\u95ee\u4f4f\u4e86\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252278\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u7531\u4e8e\u6211\u90a3\u7bc7\u6587\u7ae0\u5173\u6ce8\u7684\u91cd\u70b9\u662f\u628a Request \u4f20\u9012\u5230\u5f02\u6b65\u7ebf\u7a0b\u8fd9\u4e2a\u9a9a\u64cd\u4f5c\uff0c\u5e76\u6ca1\u6709\u7279\u522b\u7684\u5173\u6ce8 Request \u5230\u5e95\u662f\u600e\u4e48\u590d\u7528\u7684\u3002<\/p>\n<p>\u6211\u53ea\u662f\u901a\u8fc7\u6253\u5370\u65e5\u5fd7\u7684\u65b9\u5f0f\u53bb\u89c2\u5bdf\u5230\u4e86\u590d\u7528\u7684\u8fd9\u4e2a\u73b0\u8c61\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252279\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u628a\u9879\u76ee\u542f\u52a8\u8d77\u6765\u4e4b\u540e\uff0c\u5206\u522b\u8bbf\u95ee testRequest \u548c testRequest1\uff0c\u4ece\u63a7\u5236\u53f0\u7684\u8f93\u51fa\u6765\u770b\uff0cRequest \u5bf9\u8c61\u786e\u5b9e\u662f\u4e00\u4e2a\u5bf9\u8c61\u3002<\/p>\n<p>\u4f46\u662f\u4ece\u524d\u9762\u7684\u7ebf\u7a0b\u540d\u79f0\u6765\u770b\uff0c\u8fd9\u662f\u7ebf\u7a0b\u6c60\u91cc\u9762\u4e24\u4e2a\u5b8c\u5168\u4e0d\u540c\u7684\u7ebf\u7a0b\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u867d\u7136\u6211\u8fd8\u5565\u90fd\u6ca1\u5206\u6790\u5462\uff0c\u57fa\u4e8e\u65e5\u5fd7\u5c31\u81f3\u5c11\u80fd\u770b\u51fa\u8fd9\u4e2a\u95ee\u9898\u7684\u7b54\u6848\uff1a<\/p>\n<blockquote><p>\u590d\u7528\u7684request\u662f\u548c\u7ebf\u7a0b\u7ed1\u5b9a\u7684\u5417\uff1f<\/p><\/blockquote>\n<p>\u4e0d\u662f\uff0c\u6ca1\u6709\u7ed1\u5b9a\u5173\u7cfb\u3002<\/p>\n<p>\u5982\u679c\u4e0d\u662f\u548c\u7ebf\u7a0b\u7ed1\u5b9a\uff0c\u90a3\u4e48\u95ee\u9898\u5c31\u968f\u4e4b\u800c\u6765\u4e86\uff1a<\/p>\n<blockquote><p>\u5982\u4f55\u51b3\u5b9a\u54ea\u4e2a\u7ebf\u7a0b\u6bcf\u6b21\u590d\u7528\u54ea\u4e2arequest\u5462\uff1f<\/p><\/blockquote>\n<p>\u8fd9\u662f\u4e2a\u597d\u95ee\u9898\uff0c\u6211\u4e5f\u4e0d\u77e5\u9053\u7b54\u6848\uff0c\u6240\u4ee5\u6211\u51b3\u5b9a\u6765\u76d8\u4e00\u76d8\u5b83\u3002<\/p>\n<p>\u4f46\u662f\u5728\u76d8\u5b83\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u60f3\u4e2a\u95ee\u9898\uff1a\u5047\u8bbe Request \u548c\u8bf7\u6c42\u7ebf\u7a0b\u7ed1\u5b9a\u5728\u4e00\u8d77\u4e86\uff0c\u8fd9\u662f\u4e00\u4e2a\u5408\u7406\u7684\u8bbe\u8ba1\u5417\uff1f<\/p>\n<p>\u80af\u5b9a\u4e0d\u662f\u7684\u3002<\/p>\n<p>\u7ebf\u7a0b\u5c31\u5e94\u8be5\u662f\u5355\u7eaf\u7684\u7ebf\u7a0b\uff0c\u4e0d\u5e94\u8be5\u7ed9\u5b83\u201c\u7ed1\u5b9a\u201d\u4e00\u4e2a Request\u3002\u8fd9\u79cd\u7ed1\u5b9a\u8ba9\u7ebf\u7a0b\u4e0d\u5355\u7eaf\u4e86\uff0c\u7ebf\u7a0b\u548c\u8bf7\u6c42\u8026\u5408\u5728\u4e00\u8d77\u4e86\u3002<\/p>\n<p>\u597d\u4e00\u70b9\u7684\u8bbe\u8ba1\u5e94\u8be5\u662f Request \u653e\u5728\u4e00\u4e2a\u201c\u6c60\u5b50\u201d\u91cc\u9762\uff0c\u6765\u4e00\u4e2a\u7ebf\u7a0b\u5c31\u4ece\u6c60\u5b50\u91cc\u9762\u53bb\u53d6\u53ef\u4ee5\u7528\u7684 Request\u3002<\/p>\n<p>\u8fd9\u6837\u53ef\u4ee5\u5b9e\u73b0\u7ebf\u7a0b\u548c\u8bf7\u6c42\u4e4b\u95f4\u89e3\u8026\u7684\u6548\u679c\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u8fd9\u4e5f\u53ea\u662f\u6211\u5728\u8fdb\u884c\u63a2\u7d22\u4e4b\u524d\u7684\u4e00\u4e2a\u5047\u8bbe\u800c\u5df2\uff0c\u5148\u653e\u5728\u8fd9\u91cc\uff0c\u6700\u540e\u770b\u770b\u8fd9\u4e2a\u731c\u60f3\u662f\u5426\u6b63\u786e\u3002<\/p>\n<p>\u770b\u8fd9\u7bc7\u6587\u7ae0\u4e0d\u9700\u8981\u4f60\u5bf9 Tomcat \u6709\u591a\u5c11\u4e86\u89e3\uff0c\u4f1a\u7528\u5b83\u5c31\u884c\uff0c\u5f88\u591a\u4e1c\u897f\u90fd\u662f\u53ef\u4ee5\u57fa\u4e8e\u6e90\u7801\u63a8\u7406\u51fa\u6765\u7684\u3002<\/p>\n<p>\u5bf9\u4e86\uff0c\u8bf4\u4e00\u4e0b Tomcat \u6e90\u7801\u7248\u672c\uff1a9.0.58\u3002<\/p>\n<h2>\u7b2c\u4e00\u4e2a\u65ad\u70b9<\/h2>\n<p>\u8981\u627e\u5230\u95ee\u9898\u7684\u7b54\u6848\u80af\u5b9a\u5f97\u53bb\u7ffb\u6e90\u7801\uff0c\u4f46\u662f\u4ece\u54ea\u91cc\u5f00\u59cb\u7ffb\u5462\uff1f<\/p>\n<p>\u6216\u8005\u6362\u4e2a\u95ee\u9898\uff1a\u7b2c\u4e00\u4e2a\u65ad\u70b9\u6253\u5728\u54ea\u5462\uff1f<\/p>\n<p>\u9047\u5230\u8fd9\u4e2a\u95ee\u9898\u6211\u7684\u7b2c\u4e00\u53cd\u5e94\u8fd8\u662f\u4ece\u65e5\u5fd7\u91cc\u9762\u770b\u770b\u80fd\u4e0d\u80fd\u627e\u5230\u76f8\u5173\u7684\u7ebf\u7d22\uff0c\u4ece\u800c\u627e\u5230\u6253\u7b2c\u4e00\u4e2a\u65ad\u70b9\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u4f46\u662f\u6211\u5206\u522b\u628a\u65e5\u5fd7\u8c03\u6574\u5230 DEBUG \u7ea7\u522b\u548c TRACE \u7ea7\u522b\uff0c\u5747\u6ca1\u6709\u53d1\u73b0\u6709\u4ef7\u503c\u7684\u4fe1\u606f\uff0c\u6240\u4ee5\u65e5\u5fd7\u8fd9\u6761\u8def\u611f\u89c9\u8d70\u4e0d\u901a\u4e86\uff0c\u600e\u4e48\u529e\uff1f<\/p>\n<p>\u4e0d\u614c\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u8981\u51b7\u9759\u5206\u6790\u4e00\u4e0b\u4e86\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252280\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6084\u6084\u7684\u95ee\u81ea\u5df1\u4e00\u53e5\uff1a\u6211\u53ef\u4ee5\u628a\u65ad\u70b9\u6253\u5728\u65b9\u6cd5\u5165\u53e3\u5904\u5417\uff1f<\/p>\n<p>\u5f53\u7136\u53ef\u4ee5\u4e86\uff0c\u8fd9\u4e5f\u662f\u80fd\u60f3\u5230\u7684\u4e00\u4e2a\u975e\u5e38\u5e38\u89c4\u7684\u624b\u6bb5\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252281\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4f46\u662f\u5982\u679c\u628a\u65ad\u70b9\u6253\u5728\u8fd9\u91cc\uff0c\u76f8\u5f53\u4e8e\u4ece\u4e1a\u52a1\u4ee3\u7801\u7684\u7b2c\u4e00\u884c\u53cd\u5411\u53bb\u63a8\u6e90\u7801\uff0c\u628a\u8def\u7ed5\u7684\u7a0d\u5fae\u8fdc\u4e86\u4e00\u70b9\u3002<\/p>\n<p>\u90a3\u4e48\u8fd8\u53ef\u4ee5\u628a\u65ad\u70b9\u6253\u5728\u54ea\u91cc\u5462\uff1f<\/p>\n<p>\u6211\u8fd9\u91cc\u4e0d\u662f\u8f93\u51fa\u4e86 Request \u8fd9\u4e2a\u5bf9\u8c61\u7684\u5168\u7c7b\u540d\u5417\uff1a<\/p>\n<blockquote><p>http-nio-8080-exec-2\uff1atestRequest1 = org.apache.catalina.connector.RequestFacade@5db48dd3<\/p><\/blockquote>\n<p>RequestFacade\uff0c\u8fd9\u4e2a\u7c7b\u80fd\u7528\uff0c\u5fc5\u7136\u6709\u4e00\u4e2a new \u5b83\u7684\u5730\u65b9\uff0c\u800c\u8981 new \u5b83\uff0c\u5fc5\u5b9a\u8981\u8c03\u7528\u5b83\u7684\u6784\u9020\u65b9\u6cd5\u3002<\/p>\n<p>\u90a3\u6211\u662f\u4e0d\u662f\u53ea\u8981\u5728\u5176\u5bf9\u5e94\u7684\u6784\u9020\u65b9\u6cd5\u4e0a\u6253\u4e2a\u65ad\u70b9\uff0c\u5f53\u7a0b\u5e8f\u521b\u5efa\u8fd9\u4e2a\u7c7b\u7684\u65f6\u5019\uff0c\u4e0d\u5c31\u662f\u6211\u8981\u627e\u7684\u6e90\u5934\u5417\uff1f<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252282\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u628a\u7b2c\u4e00\u4e2a\u65ad\u70b9\u6253\u5728\u4e86 RequestFacade \u7684\u6784\u9020\u65b9\u6cd5\u4e0a\u3002<\/p>\n<p>\u4ece\u6784\u9020\u65b9\u6cd5\u5165\u624b\uff0c\u8fd9\u4e5f\u662f\u6211\u7684\u4e00\u4e2a\u8c03\u8bd5\u5c0f\u6280\u5de7\uff0c\u9001\u7ed9\u4f60\uff0c\u4e0d\u5ba2\u6c14\u3002<\/p>\n<p>\u6709\u7684\u5c0f\u4f19\u4f34\u5c31\u8981\u95ee\u4e86\uff1a\u5982\u679c\u4e00\u4e2a\u7c7b\u6709\u591a\u4e2a\u6784\u9020\u65b9\u6cd5\u600e\u4e48\u529e\u5462\uff1f<\/p>\n<p>\u5f88\u7b80\u5355\uff0c\u5927\u529b\u51fa\u5947\u8ff9\uff0c\u6bcf\u4e2a\u6784\u9020\u65b9\u6cd5\u90fd\u6253\u4e0a\u65ad\u70b9\uff0c\u4e00\u5b9a\u4f1a\u6709\u4e00\u4e2a\u5730\u65b9\u89e6\u53d1\u7684\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252283\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h2>\u8c03\u8bd5\u6e90\u7801<\/h2>\n<p>\u627e\u5230\u7b2c\u4e00\u4e2a\u65ad\u70b9\u7684\u4f4d\u7f6e\u4e86\uff0c\u63a5\u4e0b\u6765\u5c31\u662f\u628a\u9879\u76ee\u91cd\u542f\uff0c\u53d1\u8d77\u8c03\u7528\u4e86\u3002<\/p>\n<p>\u6211\u8fde\u7eed\u53d1\u8d77\u4e86\u4e24\u6b21\u8c03\u7528\uff0c\u4ece\u7a0b\u5e8f\u7684\u8868\u73b0\u4e0a\u6211\u5c31\u77e5\u9053\u8fd9\u4e2a\u65ad\u70b9\u6253\u5bf9\u4e86\u3002<\/p>\n<p>\u6211\u5148\u7ed9\u4f60\u4e0a\u4e2a\u52a8\u56fe\uff0c\u4f60\u5c31\u77e5\u9053\u6211\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u8bf4\u4e86\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252284\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u9879\u76ee\u542f\u52a8\u4e4b\u540e\uff0c\u7b2c\u4e00\u6b21\u8c03\u7528\u5728\u65ad\u70b9\u7684\u5730\u65b9\u505c\u4e0b\u6765\u4e86\uff0c\u63a5\u7740\u7b2c\u4e8c\u6b21\u8c03\u7528\u5e76\u6ca1\u6709\u5728\u65ad\u70b9\u7684\u5730\u65b9\u505c\u4e0b\u6765\u3002<\/p>\n<p>\u8bf4\u660e\u7b2c\u4e8c\u6b21\u786e\u5b9e\u6ca1\u6709\u65b0\u5efa RequestFacade \u5bf9\u8c61\uff0c\u800c\u662f\u590d\u7528\u4e86\u7b2c\u4e00\u6b21\u8c03\u7528\u65f6\u4ea7\u751f\u7684 RequestFacade \u5bf9\u8c61\u3002<\/p>\n<p>\u9a8c\u8bc1\u4e86\u65ad\u70b9\u6253\u7684\u4f4d\u7f6e\u6ca1\u6bdb\u75c5\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u5f00\u59cb\u6162\u6162\u7684\u8c03\u8bd5\u4e86\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u5173\u6ce8\u4e00\u4e0b\u8fd9\u4e2a RequestFacade \u5bf9\u8c61\u521b\u5efa\u7684\u5730\u65b9\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252285\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6709\u4e24\u4e2a if \u5224\u65ad\u3002<\/p>\n<p>\u7b2c\u4e00\u4e2a\u662f\u5224\u65ad facade \u662f\u5426\u4e3a null\uff0c\u4e0d\u4e3a null \u5c31 new\u3002<\/p>\n<p>\u7b2c\u4e8c\u4e2a\u662f\u628a facade \u8d4b\u503c\u7ed9 applicationRequest \u5bf9\u8c61\uff0c\u63a5\u7740\u8fd4\u56de applicationRequest \u5bf9\u8c61\u3002<\/p>\n<p>\u7b2c\u4e8c\u4e2a if \u5176\u5b9e\u5f88\u6709\u610f\u601d\uff0c\u4f60\u60f3\u554a\uff0c\u8fd9\u91cc\u76f4\u63a5\u8fd4\u56de facade \u4e5f\u53ef\u4ee5\u5440\uff0c\u4e3a\u4ec0\u4e48\u8981\u7528 applicationRequest \u6765\u627f\u63a5\u4e00\u4e0b\u5462\uff1f<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u597d\u95ee\u9898\u3002<\/p>\n<p>\u8fd9\u4e24\u4e2a if \u7684\u5173\u952e\u5728\u4e8e facade \u548c applicationRequest \u662f\u5426\u4e3a\u7a7a\u3002<\/p>\n<p>\u7b2c\u4e00\u6b21\u8bbf\u95ee\u7684\u65f6\u5019\u80af\u5b9a\u662f\u7a7a\u3002\u90a3\u4e48\u540e\u7eed\u4ec0\u4e48\u65f6\u5019\u53c8\u4f1a\u53d8\u4e3a\u7a7a\u5462\uff1f<\/p>\n<p>\u5c31\u662f\u5728\u4e00\u6b21\u8bf7\u6c42\u7ed3\u675f\uff0c\u6267\u884c recycle \u65b9\u6cd5\u7684\u65f6\u5019\uff1a<\/p>\n<blockquote><p>org.apache.catalina.connector.Request#recycle<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252286\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4ece\u6e90\u7801\u4e2d\u53ef\u4ee5\u770b\u5230 applicationRequest \u662f\u76f4\u63a5\u8bbe\u7f6e\u4e3a null \u7684\u3002<\/p>\n<p>\u4f46\u662f\u8fd9\u4e2a facade \u8bbe\u7f6e\u4e3a null \u6709\u4e2a\u524d\u63d0\uff0cgetDiscardFacades \u65b9\u6cd5\u8fd4\u56de\u4e3a true\u3002<\/p>\n<p>\u8fd9\u662f\u4e2a\u4ec0\u4e48\u73a9\u610f\uff1f<\/p>\n<p>\u770b\u4e00\u773c\u5c31\u77e5\u9053\u4e86\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252287\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u610f\u601d\u662f RECYCLE_FACADES \u8fd9\u4e2a\u53c2\u6570\u63a7\u5236\u7740\u662f\u5426\u5faa\u73af\u4f7f\u7528 facade \u8fd9\u4e2a\u5bf9\u8c61\uff0c\u5982\u679c\u8bbe\u7f6e\u4e3a  true \u4f1a\u63d0\u9ad8\u5b89\u5168\u6027\uff0c\u800c\u8fd9\u4e2a\u53c2\u6570\u9ed8\u8ba4\u662f false\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252288\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252289\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\u6211\u8fd9\u4e2a\u5730\u65b9\u5982\u679c\u628a\u8fd9\u4e2a\u53c2\u6570\u4fee\u6539\u4e3a true\uff0cfacade \u5bf9\u8c61\u5c31\u4f1a\u5728\u6bcf\u6b21\u8c03\u7528\u5b8c\u6210\u4e4b\u540e\u8fdb\u884c\u56de\u6536\u3002<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u542f\u52a8\u53c2\u6570JAVA_OPTS\u6765\u914d\u7f6e:<\/p>\n<blockquote><p>-Dorg.apache.catalina.connector.RECYCLE_FACADES=true<\/p><\/blockquote>\n<p>\u4ece\u524d\u9762\u7684\u6e90\u7801\u4e2d\u53ef\u4ee5\u77e5\u9053\uff0c\u5728\u9ed8\u8ba4\u7684\u60c5\u51b5\u4e0b\uff0capplicationRequest \u4f1a\u5728\u6bcf\u6b21\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u8bbe\u7f6e\u4e3a null\uff0c\u800c facade \u4f1a\u4fdd\u7559\u4e0b\u6765\u3002<\/p>\n<p>\u56e0\u6b64\u4e0b\u4e00\u6b21\u8bf7\u6c42\u8fc7\u6765\u7684\u65f6\u5019\uff0cfacede \u5e76\u4e0d\u4e3a\u7a7a\uff0c\u76f4\u63a5\u590d\u7528 facade\u3002\u628a facade \u8d4b\u503c\u7ed9 applicationRequest<strong>\u3002<\/strong><\/p>\n<p>\u6240\u4ee5\u6211\u4eec\u5728\u65e5\u5fd7\u91cc\u9762\u89c2\u5bdf\u5230\u7684\u73b0\u8c61\u662f\u4e24\u6b21\u8bf7\u6c42\u8f93\u51fa\u7684 facade \u5bf9\u8c61\u662f\u4e00\u6837\u7684\u3002<\/p>\n<p>\u63a5\u7740\uff0c\u6211\u4eec\u7ee7\u7eed\u770b\u8c03\u7528\u5806\u6808\u3002<\/p>\n<p>\u770b\u521b\u5efa facade \u7684\u8fd9\u4e2a getRequest \u8bf7\u6c42\u5230\u5e95\u662f\u8c01\u5728\u8c03\u7528\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252290\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u53d1\u73b0\u662f\u4e00\u4e2a Request \u5bf9\u8c61\u5728\u8c03\u7528 getRequest \u65b9\u6cd5\u3002<\/p>\n<p><strong>\u6240\u4ee5\u63a5\u4e0b\u6765\u8981\u627e\u7684\u5c31\u662f Request \u5bf9\u8c61\u6700\u5f00\u59cb\u662f\u4ece\u54ea\u4e2a\u65b9\u6cd5\u5f00\u59cb\u4f5c\u4e3a\u5165\u53c2\u4f20\u9012\u7684\u3002<\/strong><\/p>\n<p>\u987a\u7740\u8c03\u7528\u5806\u6808\uff0c\u53ef\u4ee5\u627e\u5230\u4e0b\u9762\u8fd9\u4e2a\u5730\u65b9\uff1a<\/p>\n<blockquote><p>org.apache.coyote.http11.Http11Processor#service<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252291\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u5c31\u662f Request \u5bf9\u8c61\u6700\u5f00\u59cb\u4f5c\u4e3a\u5165\u53c2\u4f20\u9012\u7684\u5730\u65b9\u3002<\/p>\n<p>\u90a3\u4e48\u8fd9\u4e2a Request \u5bf9\u8c61\u662f\u600e\u4e48\u4ea7\u751f\u7684\u5462\uff1f<\/p>\n<p>\u6211\u4e5f\u4e0d\u77e5\u9053\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u8981\u77e5\u9053\u8fd9\u4e2a\u95ee\u9898\u7684\u7b54\u6848\uff0c\u7b2c\u4e8c\u4e2a\u65ad\u70b9\u6253\u7684\u4f4d\u7f6e\u4e5f\u5c31\u547c\u4e4b\u6b32\u51fa\u4e86\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252292\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u91cd\u542f\u9879\u76ee\uff0c\u53d1\u8d77\u8bf7\u6c42\uff0c\u53d1\u73b0 Debug \u505c\u5728\u4e86 AbstractProcessor \u7c7b\u7684\u6784\u9020\u65b9\u6cd5\uff0c\u8fd9\u5c31\u662f request \u6700\u5f00\u59cb\u4ea7\u751f\u7684\u5730\u65b9\uff0c\u540c\u65f6\u6211\u4eec\u53c8\u6536\u83b7\u4e86\u4e00\u4e2a\u8c03\u7528\u5806\u6808\uff1a<\/p>\n<blockquote><p>org.apache.coyote.AbstractProcessor#AbstractProcessor(org.apache.coyote.Adapter, org.apache.coyote.Request, org.apache.coyote.Response)<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252293\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u4e2a Request \u662f\u600e\u4e48\u6765\u7684\u5462\uff1f<\/p>\n<p>new \u51fa\u6765\u7684\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252294\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981\u6267\u884c\u8fd9\u4e2a new \u65b9\u6cd5\u5462\uff1f<\/p>\n<p>\u56e0\u4e3a\u8fd9\u4e2a\u5730\u65b9\u5728 createProcessor\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252295\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u800c\u6211\u4eec\u8981\u5bfb\u627e\u7684\u95ee\u9898\u7684\u7b54\u6848\uff0c\u5c31\u85cf\u5728\u4e0a\u9762\u8fd9\u4e2a\u622a\u56fe\u4e2d\u3002<\/p>\n<p>\u51c6\u786e\u7684\u8bf4\uff0c\u5c31\u85cf\u5728\u4e0a\u9762\u622a\u56fe\u4e2d\uff0c\u6807\u8bb0\u4e86\u4e94\u89d2\u661f\u7684\u5730\u65b9\uff1a<\/p>\n<blockquote><p>processor = recycledProcessors.pop();<\/p><\/blockquote>\n<p>\u4ece\u4ee3\u7801\u7684\u7247\u6bb5\u770b\uff0c\u5982\u679c\u4ece recycledProcessors \u91cc\u9762 pop \u51fa\u7684 processor \u5bf9\u8c61\u4e0d\u4e3a\u7a7a\uff0c\u5219\u4e0d\u4f1a\u8c03\u7528 createProcessor \u65b9\u6cd5\u3002<\/p>\n<p>\u800c\u4ece\u8c03\u8bd5\u7684\u89d2\u5ea6\u770b\uff0c\u4e0d\u8c03\u7528 createProcessor \u65b9\u6cd5\uff0c\u4e5f\u5c31\u4e0d\u4f1a\u521b\u5efa RequestFacade \u5bf9\u8c61\u3002<\/p>\n<p>\u6240\u4ee5\uff0crecycledProcessors\uff0c\u8fd9\u4e2a\u73a9\u610f\u662f\u534e\u70b9\u3001\u662f\u771f\u6b63\u7684\u7a81\u7834\u53e3\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252296\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u4e00\u5c0f\u8282\uff0c\u4e3b\u8981\u662f\u5206\u4eab\u4e00\u4e0b\u6211\u627e\u5230\u8fd9\u4e2a\u7a81\u7834\u53e3\u7684\u4e00\u4e2a\u8fc7\u7a0b\uff0c\u4e24\u4e2a\u5173\u952e\u7684\u65ad\u70b9\u662f\u57fa\u4e8e\u4e0a\u9762\u8003\u8651\u8bbe\u7f6e\u7684\u3002<\/p>\n<p>\u5176\u5b9e\u4f60\u56de\u60f3\u4e00\u4e0b\uff0c\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u987a\u5176\u81ea\u7136\u7684\u4e8b\u60c5\uff0c\u5e26\u7740\u95ee\u9898\u53bb\u8c03\u8bd5\u6e90\u7801\u662f\u4e00\u4ef6\u6bd4\u8f83\u7b80\u5355\u7684\u4e8b\u60c5\u3002<\/p>\n<p>\u4e0d\u8981\u6002\uff0c\u5c31\u662f\u7ffb\u3002<\/p>\n<h2>recycledProcessors<\/h2>\n<p>\u4f60\u770b\u8fd9\u4e2a\u5bf9\u8c61\u7684\u540d\u79f0\uff0crecycled + Processors\uff0c\u4e00\u770b\u5c31\u77e5\u9053\u91cc\u9762\u6709\u6545\u4e8b\uff0c\u6709\u5173\u4e8e\u5bf9\u8c61\u590d\u7528\u7684\u6545\u4e8b\u3002<\/p>\n<blockquote><p>org.apache.coyote.AbstractProtocol.RecycledProcessors<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252297\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u4e2a\u7c7b\u7684\u65b9\u6cd5\u4e5f\u7279\u522b\u7b80\u5355\uff0c\u5c31\u4e09\u4e2a\u65b9\u6cd5\uff1apush\u3001pop\u3001clear\u3002<\/p>\n<p>\u7ee7\u627f\u81f3 SynchronizedStack \u5bf9\u8c61\uff0c\u5c31\u662f\u4e00\u4e2a\u6807\u6807\u51c6\u51c6\u7684\u6808\u7ed3\u6784\uff0c\u53ea\u4e0d\u8fc7\u662f\u7528 Synchronized \u4fee\u6539\u4e86\u5bf9\u5e94\u7684\u65b9\u6cd5\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252298\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5728 SynchronizedStack \u7c7b\u7684\u6ce8\u91ca\u4e0a\u63d0\u5230\u4e86\u8fd9\u662f\u4e00\u4e2a\u5bf9\u8c61\u6c60\u3001\u8fd9\u4e2a\u5bf9\u8c61\u6c60\u4e0d\u9700\u8981\u7f29\u5bb9\u3001\u76ee\u7684\u662f\u4e3a\u4e86\u51cf\u5c11\u5783\u573e\u5bf9\u8c61\uff0c\u91ca\u653e GC \u538b\u529b\u3002<\/p>\n<p>\u73b0\u5728\u6211\u4eec\u627e\u5230\u4e86\u8fd9\u4e2a\u5bf9\u8c61\u6c60\uff0c\u4e5f\u627e\u5230\u4e86\u8c03\u7528\u8fd9\u4e2a\u5bf9\u8c61\u6c60 pop \u7684\u5730\u65b9\u3002<\/p>\n<p>\u90a3\u4e48\u4ec0\u4e48\u65f6\u5019\u5f80\u8fd9\u4e2a\u5bf9\u8c61\u6c60 push \u5462\uff1f<\/p>\n<p>\u6211\u4e5f\u4e0d\u77e5\u9053\u3002<\/p>\n<p>\u6240\u4ee5\u7b2c\u4e09\u4e2a\u65ad\u70b9\u5c31\u6765\u4e86\uff0c\u53ef\u4ee5\u6253\u5728 push \u65b9\u6cd5\u4e0a\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252299\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u7136\u540e\u53d1\u8d77\u8c03\u7528\uff0c\u53d1\u73b0\u662f\u5728\u8bf7\u6c42\u5904\u7406\u5b8c\u6210\uff0crelease \u5f53\u524d processor \u7684\u65f6\u5019\uff0c\u5c31\u628a\u8fd9\u4e2a processor \u653e\u5230 recycledProcessors \u91cc\u9762\u53bb\uff0c\u7b49\u7740\u4e0b\u4e00\u6b21\u8bf7\u6c42\u4f7f\u7528\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252300\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6b64\u65f6\u6211\u4eec\u5df2\u7ecf\u638c\u63e1\u4e86\u8fd9\u6837\u7684\u4e00\u4e2a\u95ed\u73af\uff1a<\/p>\n<p>\u5f53\u8bf7\u6c42\u6765\u4e86\u4e4b\u540e\uff0c\u5148\u770b recycledProcessors \u8fd9\u4e2a\u6808\u7ed3\u6784\u91cc\u9762\u6709\u6ca1\u6709\u53ef\u7528\u7684 processor\uff0c\u6ca1\u6709\u5219\u8c03\u7528 createProcessor \u65b9\u6cd5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\uff0c\u63a5\u7740\u5728\u8bf7\u6c42\u7ed3\u675f\u4e4b\u540e\uff0c\u5c06\u5176\u653e\u5165\u5230\u6808\u7ed3\u6784\u91cc\u9762\u3002<\/p>\n<p>\u800c\u5728\u8c03\u7528 createProcessor \u65b9\u6cd5\u7684\u65f6\u5019\uff0c\u4f1a\u6784\u5efa\u4e00\u4e2a\u65b0\u7684 Request \u5bf9\u8c61\uff0c\u6700\u7ec8\u8fd9\u4e2a Request \u5bf9\u8c61\u4f1a\u5c01\u88c5\u4e3a RequestFacade \u5bf9\u8c61\u3002<\/p>\n<p>\u6240\u4ee5\u6211\u73b0\u5728\u60f3\u8981\u9a8c\u8bc1 Processor\u3001Request \u548c RequestFacade \u4e09\u8005\u4e4b\u95f4\u6709\u8fd9\u6837\u7684\u4e00\u4e2a\u5bf9\u5e94\u5173\u7cfb\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252301\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u600e\u4e48\u9a8c\u8bc1\u5462\uff1f<\/p>\n<p>\u6253\u5370\u65e5\u5fd7\u3002<\/p>\n<p>\u6ce8\u610f\uff0c\u63a5\u4e0b\u6765\u53c8\u662f\u4e00\u4e2a\u8c03\u8bd5\u5c0f\u6280\u5de7\u4e86\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252302\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6211\u60f3\u8981\u5728\u9009\u5b9a processor \u4e4b\u540e\uff0c\u52a0\u5165\u4e00\u884c\u8f93\u51fa\u8bed\u53e5\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252303\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u600e\u4e48\u52a0\u5462\uff1f<\/p>\n<p>\u5728\u81ea\u5df1\u7684\u9879\u76ee\u91cc\u9762\u521b\u5efa\u4e00\u4e2a\u548c\u6e90\u7801\u4e00\u6837\u7684\u5305\u8def\u5f84\uff0c\u7136\u540e\u628a\u5bf9\u5e94\u7684\u7c7b\u76f4\u63a5\u7c98\u8d34\u8fc7\u6765\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252304\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u56e0\u4e3a\u662f\u5728\u81ea\u5df1\u7684\u9879\u76ee\u91cc\u9762\uff0c\u4f60\u60f3\u600e\u4e48\u6539\u90fd\u884c\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252305\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6bd4\u5982\u6211\u52a0\u5165\u8fd9\u4e2a\u8f93\u51fa\u8bed\u53e5\uff0c\u6253\u5370\u51fa processor \u548c\u91cc\u9762\u7684 request\u3002<\/p>\n<p>\u53d1\u8d77\u8bf7\u6c42\u4e4b\u540e\u4f60\u4f1a\u53d1\u73b0\u786e\u5b9e\u751f\u6548\u4e86\uff0c\u4f46\u662f reuqest \u7684\u8f93\u51fa\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252306\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e3a\u4ec0\u4e48\u5462\uff1f<\/p>\n<p>\u56e0\u4e3a\u5728\u6e90\u7801\u91cc\u9762\uff0c\u8fd9\u4e2a\u7c7b\u7684 toString \u65b9\u6cd5\u88ab\u91cd\u5199\u4e86\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252307\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u600e\u4e48\u529e\uff1f<\/p>\n<p>\u6539\u6e90\u7801\u554a\uff0c\u521a\u521a\u624d\u6559\u4f60\u4e86\u7684\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252308\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4fee\u6539\u4e4b\u540e\u53d1\u8d77\u8c03\u7528\uff0c\u5c31\u53ef\u4ee5\u5728\u63a7\u5236\u53f0\u770b\u5230\u5bf9\u5e94\u7684\u9884\u671f\u7684\u8f93\u51fa\u4e86\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252309\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4f60\u770b\uff0cprocessor \u91cc\u9762\u6709\u4e2a request\u3002\u73b0\u5728\u6211\u8981\u627e\u7684\u662f request \u548c RequestFacade \u4e4b\u95f4\u7684\u5173\u7cfb\u3002<\/p>\n<p>\u5f88\u7b80\u5355\uff0c\u5728 getRequest \u65b9\u6cd5\u8fd9\u91cc\u4e5f\u8f93\u51fa\u4e00\u884c\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252310\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u53d1\u8d77\u8c03\u7528\u4e4b\u540e\uff0c\u53d1\u73b0\uff0c\u5b8c\u728a\u5b50\u4e86\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252311\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u4e24\u4e2a Request \u6839\u672c\u5c31\u4e0d\u662f\u540c\u4e00\u4e2a\u73a9\u610f\u554a\uff1a<\/p>\n<blockquote><p>org.apache.coyote.Request@667cbb30<br \/>org.apache.catalina.connector.Request@9ffc697<\/p><\/blockquote>\n<p>\u4e0d\u8981\u614c\uff0c\u51b7\u9759\u4e0b\u6765\u7ec6\u55e6\u4e00\u4e0b\uff0c\u867d\u7136\u8fd9\u662f\u4e24\u4e2a\u4e0d\u540c\u7684 Request\uff0c\u4f46\u662f\u5b83\u4eec\u4e4b\u95f4\u4e00\u5b9a\u6709\u7740\u5343\u4e1d\u4e07\u7f15\u7684\u8054\u7cfb\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252312\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5148\u770b\u4e00\u4e0b org.apache.catalina.connector.Request \u662f\u600e\u4e48\u6765\u7684\uff0c\u8001\u89c4\u77e9\uff0c\u6784\u9020\u65b9\u6cd5\u4e0a\u6253\u65ad\u70b9\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252313\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u57fa\u4e8e\u8fd9\u4e2a\u8c03\u7528\u5806\u6808\uff0c\u5f80\u524d\u627e\u4e00\u70b9\u70b9\uff0c\u5c31\u80fd\u770b\u5230\u4e00\u4e2a\u503c\u5f97\u6ce8\u610f\u7684\u5730\u65b9\uff1a<\/p>\n<blockquote><p>org.apache.catalina.connector.CoyoteAdapter#service<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252314\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5728\u4e0a\u9762\u622a\u56fe\u7684\u8fd9\u4e2a\u65b9\u6cd5\u4e2d\uff0c\u6709\u4e00\u884c\u8fd9\u6837\u7684\u4ee3\u7801\uff1a<\/p>\n<blockquote><p>request.setCoyoteRequest(req);<\/p><\/blockquote>\n<p>\u5176\u4e2d request \u662f org.apache.catalina.connector.Request \u5bf9\u8c61\u3002<\/p>\n<p>\u800c req \u662f org.apache.coyote.Request \u5bf9\u8c61\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252315\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u8fd9\u91cc\u7684\u8fd9\u4e2a\u8f93\u51fa\u8bed\u53e5\u5e94\u8be5\u662f\u8fd9\u6837\u7684\u624d\u5bf9\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252316\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4fee\u6539\u4e4b\u540e\uff0c\u518d\u6b21\u53d1\u8d77\u8c03\u7528\uff0c\u8f93\u51fa\u65e5\u5fd7\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252317\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5982\u679c\u4f60\u8fd8\u6ca1\u770b\u51fa\u70b9\u4ec0\u4e48\u7684\u8bdd\uff0c\u6211\u7ed9\u4f60\u52a0\u5de5\u4e00\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252318\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u610f\u601d\u5c31\u662f Processor \u548c RequestFacade \u786e\u5b9e\u662f\u4e00\u4e00\u5bf9\u5e94\u7684\u3002<\/p>\n<p>\u56de\u5230\u6587\u7ae0\u6700\u5f00\u59cb\u7684\u8fd9\u4e2a\u622a\u56fe\uff0c\u4e3a\u4ec0\u4e48\u6211\u53d1\u8d77\u4e24\u6b21\u8bf7\u6c42\uff0cRequestFacade \u5bf9\u8c61\u662f\u540c\u4e00\u4e2a\u5462\uff1f<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252279\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u56e0\u4e3a\u4e24\u6b21\u8bf7\u6c42\u7528\u7684\u662f\u540c\u4e00\u4e2a Processor \u5440\u3002<\/p>\n<p>\u4f60\u770b\u6211\u518d\u53d1\u8d77\u4e24\u6b21\u8bf7\u6c42\uff0c\u90fd\u662f Http11Processor@26807016 \u5728\u5904\u7406\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252319\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6240\u4ee5\uff0c\u8868\u9762\u4e0a\u770b\u662f\u540c\u4e00\u4e2a RequestFacade\uff0c\u5b9e\u8d28\u4e0a\u662f\u7528\u7684\u540c\u4e00\u4e2a Processor\u3002<\/p>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff1a<strong>\u8981\u662f\u4e24\u4e2a\u8bf7\u6c42\u7528\u7684\u662f\u4e0d\u540c\u7684 Processor\uff0c\u5c31\u4e0d\u4f1a\u5b58\u5728\u590d\u7528\u7684\u60c5\u51b5\u3002<\/strong><\/p>\n<p>\u600e\u4e48\u9a8c\u8bc1\u4e00\u4e0b\u5462\uff1f<\/p>\n<p>\u6211\u60f3\u5230\u4e86\u4e0b\u9762\u7684\u8fd9\u4e2a\u9a8c\u8bc1\u65b9\u5f0f\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252320\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6211\u53ef\u4ee5\u5148\u8bf7\u6c42 sleepTenSeconds\uff0c\u7136\u540e\u5728 10s \u5185\u8bf7\u6c42 testRequest\u3002\u8fd9\u6837\uff0c\u6211\u5c31\u80fd\u89c2\u5bdf\u5230\u4e24\u4e2a\u4e0d\u540c\u7684 Processor\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252321\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e3a\u4e86\u66f4\u52a0\u76f4\u89c2\u7684\u770b\u5230\u8fd9\u4e2a\u73b0\u8c61\u3002<\/p>\n<p>\u6211\u51b3\u5b9a\u5728\u64cd\u4f5c recycledProcessors \u7684 pop \u65b9\u6cd5\u4e4b\u524d\u548c push \u65b9\u6cd5\u4e4b\u540e\uff0c\u8f93\u51fa\u4e00\u4e0b recycledProcessors \u91cc\u9762\u7684\u5185\u5bb9\uff1a<\/p>\n<blockquote><p>org.apache.coyote.AbstractProtocol.RecycledProcessors<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252322\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4f46\u662f\u4f60\u6309\u7167\u6211\u8fd9\u6837\u5199\u7684\u65f6\u5019\u4f1a\u53d1\u73b0\uff1a RecycledProcessors \u7684\u7236\u7c7b\uff0c\u4e5f\u5c31\u662f SynchronizedStack \u7c7b\u5e76\u6ca1\u6709\u63d0\u4f9b print \u65b9\u6cd5\uff0c\u600e\u4e48\u529e\u5462\uff1f<\/p>\n<p>\u5f88\u7b80\u5355\u561b\uff0c\u6e90\u7801\u6211\u90fd\u53ef\u4ee5\u62ff\u5230\uff0c\u52a0\u4e00\u4e2a\u65b9\u6cd5\uff0c\u8fd8\u4e0d\u662f\u624b\u5230\u64d2\u6765\u7684\u4e8b\u60c5\uff1f<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252323\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u63a5\u7740\uff0c\u6211\u8fd8\u662f\u6309\u7167\u5148\u8bbf\u95ee sleepTenSeconds \u518d\u8bbf\u95ee testRequest \u65b9\u6cd5\u7684\u987a\u5e8f\u53d1\u8d77\u8bf7\u6c42\uff0c\u65e5\u5fd7\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252324\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5355\u72ec\u62ff\u51fa\u6765\uff0ctestRequest \u6574\u4e2a\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\uff0c\u5bf9\u5e94\u7684\u65e5\u5fd7\u662f\u8fd9\u6837\u7684\uff0c<\/p>\n<pre><code>========pop\u4e4b\u524d\u3010\u5f00\u59cb\u3011\u6253\u5370\u5f53\u524d\u6240\u6709Processor========\n========pop\u4e4b\u524d\u3010\u7ed3\u675f\u3011\u6253\u5370\u5f53\u524d\u6240\u6709Processor========\n1.processor=org.apache.coyote.http11.Http11Processor@6720055f,request=org.apache.coyote.Request@69e7f7cb\n2.coyoteRequest=org.apache.coyote.Request@69e7f7cb,facade=org.apache.catalina.connector.RequestFacade@6dd86e2f\n3.http-nio-8080-exec-1\uff1atestRequest = org.apache.catalina.connector.RequestFacade@6dd86e2f\n========push\u4e4b\u540e\u3010\u5f00\u59cb\u3011\u6253\u5370\u5f53\u524d\u6240\u6709Processor========\norg.apache.coyote.http11.Http11Processor@6720055f\n========push\u4e4b\u540e\u3010\u7ed3\u675f\u3011\u6253\u5370\u5f53\u524d\u6240\u6709Processor========<\/code><\/pre>\n<p>\u800c sleepTenSeconds \u6574\u4e2a\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\uff0c\u5bf9\u5e94\u7684\u65e5\u5fd7\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<pre><code>========pop\u4e4b\u524d\u3010\u5f00\u59cb\u3011\u6253\u5370\u5f53\u524d\u6240\u6709Processor========\n========pop\u4e4b\u524d\u3010\u7ed3\u675f\u3011\u6253\u5370\u5f53\u524d\u6240\u6709Processor========\n1.processor=org.apache.coyote.http11.Http11Processor@7ba33829,request=org.apache.coyote.Request@1334fe58\n2.coyoteRequest=org.apache.coyote.Request@1334fe58,facade=org.apache.catalina.connector.RequestFacade@2a0231eb\n3.http-nio-8080-exec-2\uff1asleepTenSeconds = org.apache.catalina.connector.RequestFacade@2a0231eb\n========push\u4e4b\u540e\u3010\u5f00\u59cb\u3011\u6253\u5370\u5f53\u524d\u6240\u6709Processor========\norg.apache.coyote.http11.Http11Processor@6720055f\norg.apache.coyote.http11.Http11Processor@7ba33829\n========push\u4e4b\u540e\u3010\u7ed3\u675f\u3011\u6253\u5370\u5f53\u524d\u6240\u6709Processor========<\/code><\/pre>\n<p>\u4e5f\u5c31\u662f\u8bf4\uff0c\u6b64\u65f6 recycledProcessors \u91cc\u9762\u6709\u4e24\u4e2a Processor\uff1a<\/p>\n<pre><code>========push\u4e4b\u540e\u3010\u5f00\u59cb\u3011\u6253\u5370\u5f53\u524d\u6240\u6709Processor========\norg.apache.coyote.http11.Http11Processor@6720055f\norg.apache.coyote.http11.Http11Processor@7ba33829\n========push\u4e4b\u540e\u3010\u7ed3\u675f\u3011\u6253\u5370\u5f53\u524d\u6240\u6709Processor========<\/code><\/pre>\n<p>\u90a3\u4e48\u95ee\u9898\u5c31\u6765\u4e86\uff1a\u4f60\u8bf4\u6211\u63a5\u4e0b\u6765\u518d\u6b21\u53d1\u8d77\u4e00\u4e2a\u8bf7\u6c42\uff0c\u54ea\u4e2a Processor \u4f1a\u6765\u627f\u63a5\u8fd9\u4e2a\u8bf7\u6c42\u5462\uff1f<\/p>\n<p>\u867d\u7136\u6211\u8fd8\u6ca1\u6709\u53d1\u8d77\u8bf7\u6c42\uff0c\u4f46\u662f\u6211\u77e5\u9053\uff0c\u4e00\u5b9a\u662f Http11Processor@7ba33829 \u6765\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<p>\u56e0\u4e3a\u6211\u77e5\u9053\u5b83\u5c06\u662f\u4e0b\u4e00\u4e2a\u88ab pop \u51fa\u6765\u7684 Processor \u5bf9\u8c61\u3002<\/p>\n<p>\u4e0d\u4fe1\uff0c\u4f60\u5c31\u770b\u8fd9\u4e2a\u52a8\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252325\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5728\u4e0a\u9762\u7684\u52a8\u56fe\u4e2d\uff0c\u6211\u5148\u662f testRequest \u8fd9\u4e2a\u8bf7\u6c42\u3002<\/p>\n<p>\u5982\u679c\u6211\u5148\u8bbf\u95ee sleepTenSeconds\uff0c\u518d\u8bbf\u95ee testRequest \u5462\uff1f<\/p>\n<p>\u867d\u7136\u6211\u8fd8\u6ca1\u6709\u53d1\u8d77\u8bf7\u6c42\uff0c\u4f46\u662f\u6211\u77e5\u9053\uff0c\u4e00\u5b9a\u662f\u8fd9\u6837\u7684\u5bf9\u5e94\u5173\u7cfb\u6765\u5904\u7406\u8fd9\u4e24\u6b21\u8bf7\u6c42\uff1a<\/p>\n<blockquote><p>sleepTenSeconds-&gt;Http11Processor@7ba33829<br \/>testRequest-&gt;Http11Processor@6720055f<\/p><\/blockquote>\n<p>\u56e0\u4e3a sleepTenSeconds \u8bf7\u6c42\u6765\u7684\u65f6\u5019\uff0crecycledProcessors \u91cc\u9762\u4f1a pop \u51fa Processor@7ba33829 \u8fd9\u4e2a\u5bf9\u8c61\uff0c\u6765\u5904\u7406\u8fd9\u4e2a\u8bf7\u6c42\u3002<\/p>\n<p>\u6240\u4ee5\u5728 10 \u79d2\u5185\uff0c\u4e5f\u5c31\u662f sleepTenSeconds \u8bf7\u6c42\u672a\u5b8c\u6210\u7684\u65f6\u5019\uff0c\u8bbf\u95ee testRequest \u8bf7\u6c42\uff0crecycledProcessors \u91cc\u9762\u63a5\u7740 pop \u51fa\u6765\u7684 \u5c31\u662f Http11Processor@6720055f \u8fd9\u4e2a\u5bf9\u8c61\u3002<\/p>\n<p>\u4e0d\u4fe1\u7684\u8bdd\uff0c\u4f60\u518d\u770b\u8fd9\u4e2a\u52a8\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252326\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6240\u4ee5\uff0c\u73b0\u5728\u6211\u4eec\u662f\u4e0d\u662f\u627e\u5230\u8fd9\u4e2a\u95ee\u9898\u7684\u7b54\u6848\u4e86\uff1a<\/p>\n<blockquote><p>\u5982\u4f55\u51b3\u5b9a\u54ea\u4e2a\u7ebf\u7a0b\u6bcf\u6b21\u590d\u7528\u90a3\u4e2arequest\u5462\uff1f<\/p><\/blockquote>\n<p><strong>\u8bf7\u6c42\u7ebf\u7a0b\u548c request \u4e4b\u95f4\u6ca1\u6709\u5173\u8054\u5173\u7cfb\u3002\u6bcf\u6b21\u8bf7\u6c42\u4f7f\u7528\u54ea\u4e2a request \u53d6\u51b3\u4e8e\u4f7f\u7528\u54ea\u4e2a Processor\u3002\u800c\u6bcf\u6b21\u8bf7\u6c42\u4f7f\u7528\u54ea\u4e2a Processor\uff0c\u53d6\u51b3\u4e8e recycledProcessors \u7c7b\u91cc\u9762\u7f13\u5b58\u4e86\u54ea\u4e9b Processor\u3002\u8bf7\u6c42\u8fc7\u6765\u7684\u65f6\u5019\uff0cpop \u51fa\u6765\u54ea\u4e2a\uff0c\u5c31\u662f\u54ea\u4e2a\u3002<\/strong><\/p>\n<p>recycledProcessors \u65e2\u7136\u662f\u4e00\u4e2a\u7f13\u5b58\uff0c\u5b83\u7684\u5927\u5c0f\uff0c\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u51b3\u5b9a\u4e86\u9879\u76ee\u7684\u6027\u80fd\u3002<\/p>\n<p>\u800c\u5b83\u7684\u9ed8\u8ba4\u503c\u662f 200\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252327\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e3a\u4ec0\u4e48\u662f 200 \u5462\uff1f<\/p>\n<p>\u56e0\u4e3a tomcat \u7ebf\u7a0b\u6c60\u7684\u6700\u5927\u7ebf\u7a0b\u6570\u9ed8\u8ba4\u5c31\u662f 200\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252328\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u4e2a\u80fd\u60f3\u660e\u767d\u5427\uff1f<\/p>\n<p>\u867d\u7136\u7ebf\u7a0b\u548c Processor \u4e4b\u95f4\u6ca1\u6709\u7ed1\u5b9a\u5173\u7cfb\uff0c\u4f46\u662f\u4ece\u903b\u8f91\u4e0a\u8bb2\u4e00\u4e2a\u7ebf\u7a0b\u5bf9\u5e94\u4e00\u4e2a Processor\u3002\u56e0\u6b64\uff0c\u597d\u4e00\u70b9\u7684\u505a\u6cd5\u662f\u8ba9\u7ebf\u7a0b\u6570\u548c Processor \u7684\u6570\u91cf\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<p>\u5982\u679c\u6211\u628a processorCache \u8fd9\u4e2a\u53c2\u6570\u4fee\u6539\u4e3a 1\uff1a<\/p>\n<blockquote><p>server.tomcat.processor-cache=1<\/p><\/blockquote>\n<p>\u4f60\u8bf4\u9ad8\u5e76\u53d1\u7684\u65f6\u5019\u4f1a\u53d1\u751f\u4ec0\u4e48\u4e8b\u60c5\u5462\uff1f<\/p>\n<p>\u5f88\u591a\u8bf7\u6c42 push \u7684\u65f6\u5019\u4f1a push \u4e0d\u8fdb\u53bb\uff0c\u4ece\u800c\u8d70\u5230 handler.unregister(processor) \u7684\u903b\u8f91\u91cc\u9762\u53bb\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252329\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u800c\u8fd9\u4e2a unregister \u65b9\u6cd5\uff0c\u5bf9\u5e94\u7684\u8fd8\u6709\u4e00\u4e2a register \u65b9\u6cd5\uff0c\u6211\u4e00\u8d77\u7ed9\u4f60\u770b\u770b\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252330\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5b83\u4eec\u6301\u6709\u7684\u662f\u540c\u4e00\u7b14 synchronized \u9501\uff0c\u8bf4\u660e\u5b83\u4eec\u4e4b\u95f4\u6709\u7ade\u4e89\u3002<\/p>\n<p>\u6211\u4eec\u77e5\u9053\uff0c\u4e00\u4e2a\u8bf7\u6c42\u7ed3\u675f\u4e4b\u540e\u4f1a\u8c03\u7528 RecycledProcessors \u7684 push \u65b9\u6cd5\uff0c\u800c push \u7684\u65f6\u5019\u4f1a\u8c03\u7528 unregister \u65b9\u6cd5\u3002<\/p>\n<p>\u90a3\u4e48\u95ee\u9898\u5c31\u6765\u4e86\uff1aregister \u4ec0\u4e48\u65f6\u5019\u8c03\u7528\u5462\uff1f<\/p>\n<p>\u5176\u5b9e\u524d\u9762\u5df2\u7ecf\u51fa\u73b0\u8fc7\u4e86\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252331\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e00\u4e2a\u8bf7\u6c42\u6765\u4e86\uff0c\u521b\u5efa\u5b8c processor \u4e4b\u540e\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u5f53\u6211\u628a processorCache \u8bbe\u7f6e\u4e3a 1\uff0c\u9ad8\u5e76\u53d1\u7684\u60c5\u51b5\u4e0b\uff0c\u5728\u4e0d\u505c\u7684\u8c03\u7528 register \u548c unregister\uff0c\u9501\u7ade\u4e89\u9891\u7e41\uff0c\u6027\u80fd\u4e0b\u964d\u3002<\/p>\n<p>\u8fd9\u4e2a\u7ed3\u8bba\uff0c\u5c31\u662f\u6211\u901a\u8fc7\u7ffb\u9605\u6e90\u7801\u5f97\u51fa\u6765\u7684\u7ed3\u8bba\uff0c\u800c\u4e0d\u662f\u5728\u5176\u4ed6\u7684\u67d0\u4e2a\u4e66\u4e0a\u6216\u8005\u89c6\u9891\u91cc\u9762\u5f97\u5230\u7684\u4e00\u4e2a\u73b0\u6210\u7684\u7ed3\u8bba\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u7ffb\u9605\u6e90\u7801\u7684\u5feb\u4e50\u548c\u610f\u4e49\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252332\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h2>\u56de\u624b\u638f<\/h2>\n<p>\u5199\u5230\u8fd9\u91cc\u7684\u65f6\u5019\uff0c\u6211\u4e0d\u7531\u7684\u60f3\u8d77\u4e86\u6211\u5728<a href=\"https:\/\/link.segmentfault.com\/?enc=Tz%2BcvnvRMVz3lp4TkIOxzw%3D%3D.j5XEym8oJcB2Y6fY3TvNtUb89kcGqsaoG7YYO9htpsSaNh8eSElDd%2FeDLAaQJeqraRijDOxhKpSrXOtN8fosiw%3D%3D\" rel=\"nofollow\">\u300a\u5343\u4e07\u4e0d\u8981\u628aRequest\u4f20\u9012\u5230\u5f02\u6b65\u7ebf\u7a0b\u91cc\u9762\uff01\u6709\u5751\uff01\u300b<\/a>\u8fd9\u7bc7\u6587\u7ae0\u4e2d\u8e29\u5230\u7684\u5751\u3002<\/p>\n<p>\u518d\u770b\u4e00\u4e0b\u8fd9\u4e2a\u52a8\u56fe\uff0c\u4e3b\u8981\u5173\u6ce8\u4e24\u6b21\u8c03\u7528\u7684\u65f6\u5019\u63a7\u5236\u53f0\u5bf9\u5e94\u7684\u8f93\u51fa\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252333\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5c31\u662f\u56e0\u4e3a\u5728 Request \u7684\u751f\u547d\u5468\u671f\u4e4b\u5916\u4f7f\u7528\u4e86\u5b83\uff0c\u5bfc\u81f4\u590d\u7528\u7684\u65f6\u5019\u51fa\u73b0\u4e86\u95ee\u9898\u3002<\/p>\n<p>\u5f53\u65f6\u6211\u7ed9\u51fa\u7684\u6b63\u786e\u65b9\u6848\u662f\u4f7f\u7528 Request \u7684\u5f02\u6b65\u7f16\u7a0b\uff0c\u4e5f\u5c31\u662f startAsync \u548c AsyncContext.complete \u65b9\u6cd5\u90a3\u4e00\u5957\u3002<\/p>\n<p>\u4f46\u662f\u8fd9\u7bc7\u6587\u7ae0\u5199\u5b8c\u4e4b\u540e\uff0c\u6211\u53c8\u60f3\u5230\u4e86\u4e24\u4e2a\u9a9a\u64cd\u4f5c\u3002<\/p>\n<p>\u7b2c\u4e00\u4e2a\u65b9\u6cd5\uff0c\u5c31\u85cf\u5728\u6211\u524d\u9762\u8bf4\u7684 RECYCLE_FACADES \u8fd9\u4e2a\u914d\u7f6e\u4e2d\u3002<\/p>\n<p>\u4ece\u5b98\u65b9\u6587\u6863\u4e0a\u7684\u63cf\u8ff0\u6765\u770b\u8fd9\u4e2a\u53c2\u6570\u5982\u679c\u8bbe\u7f6e\u4e3a true \u4f1a\u63d0\u9ad8\u5b89\u5168\u6027\uff0c\u4f46\u662f\u5b83\u9ed8\u8ba4\u662f false\u3002<\/p>\n<p>\u5b83\u600e\u4e48\u63d0\u9ad8\u5b89\u5168\u6027\u5462\uff1f<\/p>\n<p>\u5c31\u662f\u6bcf\u6b21\u628a RequestFacade \u4e5f\u7ed9\u56de\u6536\u4e86\u3002<\/p>\n<p>\u90a3\u6211\u628a\u5b83\u6539\u6210 true \u8bd5\u4e00\u8bd5\uff0c\u770b\u770b\u5565\u6548\u679c\uff1a<\/p>\n<blockquote><p>-Dorg.apache.catalina.connector.RECYCLE_FACADES=true<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252334\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u542f\u52a8\u9879\u76ee\uff0c\u53d1\u8d77\u8c03\u7528\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252335\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u629b\u51fa\u4e86\u4e00\u4e2a\u5f02\u5e38\u3002<\/p>\n<p>\u770b\u5230\u8fd9\u4e2a\u5f02\u5e38\u7684\u65f6\u5019\uff0c\u6211\u4e00\u4e0b\u5c31\u660e\u767d\u4e86\u5b98\u65b9\u6587\u6863\u91cc\u9762\u8bf4\u7684\u201c\u5b89\u5168\u6027\u201d\u662f\u4ec0\u4e48\u610f\u601d\u4e86\uff1a\u4f60\u7684\u7528\u6cd5\u9519\u8bef\u4e86\uff0c\u6211\u7ed9\u4f60\u629b\u4e2a\u5f02\u5e38\uff0c\u7ed9\u4f60\u63d0\u9192\u4e00\u4e0b\uff0c\u8fd9\u91cc\u9700\u8981\u8fdb\u884c\u4fee\u6539\uff0c\u63d0\u5347\u5b89\u5168\u6027\u3002<\/p>\n<p>\u800c\u7b2c\u4e8c\u4e2a\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<blockquote><p>server.tomcat.processor-cache=0<\/p><\/blockquote>\n<p>\u4f60\u660e\u767d\u6211\u610f\u601d\u5427\uff1f<\/p>\n<p>\u6211\u76f4\u63a5\u4e0d\u8ba9\u4f60\u590d\u7528\u4e86\uff0c\u6bcf\u6b21\u90fd\u7528\u65b0\u7684\uff0c\u7ed5\u8fc7\u590d\u7528\u8fd9\u4e2a\u201c\u5751\u201d\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252336\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5148\u522b\u7ba1\u5b83\u597d\u4e0d\u597d\u7528\uff0c\u6709\u6ca1\u6709\u6027\u80fd\u95ee\u9898\uff0c\u4f60\u5c31\u8bf4\u5728\u5f7b\u5e95\u7406\u89e3\u4e86\u5e95\u5c42\u903b\u8f91\u4e4b\u540e\uff0c\u8fd9\u4e2a\u64cd\u4f5c\u9a9a\u4e0d\u9a9a\u5427\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042252337\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042252276\">https:\/\/segmentfault.com\/a\/1190000042252276<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u597d\u5440\uff0c \u6211\u662f\u6b6a\u6b6a\u3002 \u4e4b\u524d\u4e0d\u662f\u53d1\u5e03\u4e86\u8fd9\u7bc7\u6587\u7ae0\u561b:\u300a\u5343\u4e07\u4e0d\u8981\u628aRequest\u4f20\u9012\u5230\u5f02\u6b65\u7ebf\u7a0b\u91cc\u9762\uff01\u6709\u5751\uff01\u300b \u8bf4\u7684\u662f [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-10006078","post","type-post","status-publish","format-standard","hentry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006078"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006078\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}