{"id":5464,"date":"2025-12-24T09:31:16","date_gmt":"2025-12-24T01:31:16","guid":{"rendered":"https:\/\/www.xttblog.com\/?p=5464"},"modified":"2025-12-24T09:31:16","modified_gmt":"2025-12-24T01:31:16","slug":"spring-7-%e7%8e%b0%e9%87%8d%e5%a4%a7%e6%ad%bb%e9%94%81-bug%ef%bc%8c%e5%ba%94%e7%94%a8%e5%81%87%e6%ad%bb%e6%97%a0%e6%97%a5%e5%bf%97%ef%bc%8c%e5%81%b6%e5%8f%91%e9%9a%be%e5%a4%8d%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=5464","title":{"rendered":"Spring 7 \u73b0\u91cd\u5927\u6b7b\u9501 bug\uff0c\u5e94\u7528\u5047\u6b7b\u65e0\u65e5\u5fd7\uff0c\u5076\u53d1\u96be\u590d\u73b0"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u8ddd\u79bb\u4e0a\u6b21\u6d4f\u89c8 Spring \u5b98\u7f51\u5dee\u4e0d\u591a\u6709\u4e24\u4e2a\u661f\u671f\u4e86\uff0c\u4e8e\u662f\u6211\u4eca\u5929\u518d\u6b21\u53bb\u5b98\u7f51\u627e\u627e\u770b\uff0c\u6709\u6ca1\u6709\u65b0\u7684\u6280\u672f\u6587\u7ae0\u503c\u5f97\u5b66\u4e60\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f60\u8fd8\u522b\u8bf4\uff0c\u7a81\u7136\u53d1\u73b0 Spring \u53d1\u5e03\u4e86 v7.0.2 \u7248\u672c\uff0c\u8fd9\u4e2a\u7248\u672c\u4e2d\u7adf\u7136\u6709\u4e00\u4e2a\u91cd\u5927 bug\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a bug \u5c31\u662f\u7531<code>ConcurrentReferenceHashMap#computeIfAbsent<\/code>\u5bfc\u81f4\u7684\u4e0a\u4e0b\u6587\u521d\u59cb\u5316\u6b7b\u9501\u95ee\u9898<code>Issue #35944<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8be5 Bug \u582a\u79f0\u201c\u81f4\u547d\u6740\u624b\u201d\uff0c\u5b83\u6f5c\u4f0f\u5728 Spring \u6838\u5fc3\u5e76\u53d1\u7ec4\u4ef6\u4e2d\uff0c\u53ef\u80fd\u5bfc\u81f4\u5e94\u7528\u542f\u52a8\u65f6\u5b8c\u5168\u5361\u6b7b\u3002\u6240\u4ee5\uff0c\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u5256\u6790\u8fd9\u4e2a Bug \u7684\u6765\u9f99\u53bb\u8109\uff0c\u6df1\u5165\u89e3\u6790\u81f4\u547d\u6b7b\u9501 Bug \u7684\u4fee\u590d\uff0c\u5e26\u4f60\u4e86\u89e3\u4ece\u95ee\u9898\u53d1\u73b0\u5230\u4fee\u590d\u7684\u5b8c\u6574\u6280\u672f\u7ec6\u8282\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Spring 7 \u4e2d\u7684\u6b7b\u9501\u9677\u9631<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Spring Framework \u53d1\u5e03\u4e86 7.0.2 \u7248\u672c\uff0c\u4f5c\u4e3a 7.x \u7cfb\u5217\u7684\u7b2c\u4e8c\u4e2a\u7ef4\u62a4\u7248\u672c\uff0c\u672c\u6b21\u66f4\u65b0\u5305\u542b\u4e86 20+ \u9879\u65b0\u7279\u6027\u300130+ \u4e2a Bug \u4fee\u590d\u4ee5\u53ca\u591a\u9879\u6587\u6863\u6539\u8fdb\u3002\u8fd9\u5176\u4e2d\u6700\u81f4\u547d\u7684 bug \u7adf\u7136\u662f\u9690\u85cf\u5728\u5e76\u53d1\u5de5\u5177\u7c7b\u4e2d\u7684\u6b7b\u9501\u9677\u9631\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u95ee\u9898\u73b0\u8c61<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u95ee\u9898\u7684\u73b0\u8c61\u662f\uff0c\u4f60\u7684 Spring Boot \u5e94\u7528\u5728\u542f\u52a8\u65f6\u53ef\u80fd\u4f1a\u7a81\u7136\u201c\u5361\u4f4f\u201d\uff0c\u5e76\u4e14\u6ca1\u6709\u4efb\u4f55\u9519\u8bef\u65e5\u5fd7\u663e\u793a\u3002\u4f60\u7b49\u5440\u7b49\uff0c\u4f46\u4f60\u7684\u5e94\u7528\u6c38\u8fdc\u4e0d\u4f1a\u542f\u52a8\u5b8c\u6210\uff0c\u53ea\u80fd\u5f3a\u884c\u7ec8\u6b62\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@SpringBootApplication\npublic class MyApplication {\n    public static void main(String[] args) {\n        SpringApplication.run(MyApplication.class, args); \/\/ \u2190 \u5361\u5728\u8fd9\u91cc\uff01\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6839\u636e\u793e\u533a\u7f51\u53cb\u7684\u53cd\u9988\uff0c\u8fd9\u4e2a Bug \u7684\u5178\u578b\u8868\u73b0\u662f\uff1a<code>\u5e94\u7528\u5728\u542f\u52a8\u9636\u6bb5\u65e0\u54cd\u5e94\uff0c\u65e2\u4e0d\u62a5\u9519\u4e5f\u4e0d\u7ee7\u7eed\u6267\u884c\uff0c\u7ebf\u7a0b DUMP \u663e\u793a\u5b58\u5728\u6b7b\u9501<\/code>\u3002\u66f4\u8be1\u5f02\u7684\u662f\uff0c\u5b83\u5e76\u975e\u6bcf\u6b21\u5fc5\u73b0\uff0c\u800c\u662f\u5728\u7279\u5b9a\u7684\u65f6\u5e8f\u548c\u54c8\u5e0c\u5206\u5e03\u4e0b\u201c\u5076\u5c14\u201d\u53d1\u751f\uff0c\u8fd9\u4f7f\u5f97\u6392\u67e5\u5de5\u4f5c\u5f02\u5e38\u56f0\u96be\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5f71\u54cd\u8303\u56f4<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u76ee\u524d\u786e\u5b9a\u7684\u5f71\u54cd\u8303\u56f4\u5982\u4e0b\u6240\u793a\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5f71\u54cd\u7248\u672c\uff1aSpring Framework 6.2.13 &#8211; 7.0.1<\/li><li>\u4e25\u91cd\u7ea7\u522b\uff1a\u4e25\u91cd\uff08Critical\uff09<\/li><li>\u5f71\u54cd\u7ec4\u4ef6\uff1a\u6240\u6709\u4f7f\u7528 <code>ConcurrentReferenceHashMap<\/code> \u7684 Spring \u5e94\u7528<\/li><li>\u89e6\u53d1\u6761\u4ef6\uff1a\u590d\u6742 Spring \u4e0a\u4e0b\u6587\u521d\u59cb\u5316\u65f6\uff0c\u7279\u5b9a\u7684 Bean \u52a0\u8f7d\u987a\u5e8f\u548c\u5e76\u53d1\u8bbf\u95ee\u6a21\u5f0f<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u6839\u56e0\u5206\u6790<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u4f17\u591a\u7f51\u53cb\u7684\u53cd\u9988\uff0c\u793e\u533a\u5927\u725b\u8fdb\u884c\u4e86\u6839\u56e0\u5206\u6790\uff0c\u5185\u9b3c\u7adf\u7136\u51fa\u5728<code>ConcurrentReferenceHashMap<\/code>\u8eab\u4e0a\uff0c\u5c24\u5176\u662f\u5728\u9501\u7684\u5d4c\u5957\u4e0e\u5faa\u73af\u7b49\u5f85\u4e0a\u66f4\u5bb9\u6613\u590d\u73b0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">ConcurrentReferenceHashMap \u662f\u4ec0\u4e48\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>ConcurrentReferenceHashMap<\/code> \u662f Spring \u6846\u67b6\u63d0\u4f9b\u7684<code>\u6838\u5fc3\u5e76\u53d1\u6570\u636e\u7ed3\u6784<\/code>\u3002\u5b83\u662f\u4e00\u4e2a\u7ec4\u5408\u602a\uff0c\u7ed3\u5408\u4e86\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>ConcurrentHashMap<\/code> \u7684\u5e76\u53d1\u5206\u6bb5\u9501\u673a\u5236<\/li><li>\u5f31\u5f15\u7528\/\u8f6f\u5f15\u7528\u652f\u6301\uff08\u7528\u4e8e\u5185\u5b58\u654f\u611f\u573a\u666f\uff09<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Spring \u9020\u8fd9\u4e2a\u7c7b\u7684\u8f6e\u5b50\uff0c\u662f\u56e0\u4e3a\u8fd9\u4e2a\u7c7b\u5728 Spring \u5185\u90e8\u88ab\u5e7f\u6cdb\u4f7f\u7528\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u6ce8\u89e3\u5143\u6570\u636e\u7f13\u5b58\uff08AnnotationTypeMappings\uff09<\/li><li>\u7c7b\u578b\u8f6c\u6362\u5668\u7f13\u5b58<\/li><li>Bean \u5b9a\u4e49\u7f13\u5b58<\/li><li>\u5404\u79cd\u5185\u90e8\u6ce8\u518c\u8868<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u6b7b\u9501\u4ea7\u751f\u7684\u6839\u672c\u539f\u56e0<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6839\u636e Issue #35944 \u7684\u8be6\u7ec6\u5206\u6790\uff0c\u95ee\u9898\u51fa\u5728 <code>ConcurrentReferenceHashMap.computeIfAbsent<\/code> \u65b9\u6cd5\u7684\u5b9e\u73b0\u4e0a\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u770b\u4e00\u4e0b\u95ee\u9898\u4ee3\u7801\u7684\u6f14\u53d8\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 commit <code>12dd758<\/code> \u4e2d\uff0c\u4e3a\u4e86\u4fee\u590d\u53e6\u4e00\u4e2a Bug\uff0c<code>ConcurrentReferenceHashMap<\/code> \u7684 <code>computeIfAbsent<\/code> \u5b9e\u73b0\u88ab\u4fee\u6539\uff0c<code>\u5bfc\u81f4 mapping \u51fd\u6570\u5728\u6301\u6709\u9501\u7684\u60c5\u51b5\u4e0b\u88ab\u6267\u884c<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b80\u5316\u540e\u7684\u95ee\u9898\u4ee3\u7801\u5982\u4e0b\u6240\u793a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u7b80\u5316\u540e\u7684\u95ee\u9898\u4ee3\u7801\u903b\u8f91\npublic V computeIfAbsent(K key, Function&lt;? super K, ? extends V&gt; mappingFunction) {\n    Segment segment = getSegment(hash); \/\/ \u83b7\u53d6\u6bb5\u9501\n    segment.lock(); \/\/\u52a0\u9501\n    try {\n        \/\/ \u5728\u9501\u5185\u6267\u884c\u7528\u6237\u63d0\u4f9b\u7684\u51fd\u6570\uff01\u5371\u9669\u64cd\u4f5c\n        V value = mappingFunction.apply(key); \n        return put(key, value);\n    } finally {\n        segment.unlock(); \/\/ \u89e3\u9501\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u8fdb\u884c\u6b7b\u9501\u573a\u666f\u5206\u6790\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u7528\u6237\u63d0\u4f9b\u7684 <code>mappingFunction<\/code> \u5185\u90e8<code>\u518d\u6b21\u8bbf\u95ee\u540c\u4e00\u4e2a Map<\/code>\u65f6\uff0c\u5c31\u53ef\u80fd\u53d1\u751f\u6b7b\u9501\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ConcurrentReferenceHashMap&lt;String, String&gt; map = new ConcurrentReferenceHashMap&lt;&gt;();\n\n\/\/ \u7ebf\u7a0b 1\uff1a\u5c1d\u8bd5\u83b7\u53d6 key1 \u2192 \u5728\u51fd\u6570\u4e2d\u518d\u83b7\u53d6 key2\nmap.computeIfAbsent(\"key1\", k -&gt; {\n    \/\/ \u7b49\u5f85 key2 \u7684\u9501\n    return map.computeIfAbsent(\"key2\", k2 -&gt; \"value2\"); \n});\n\n\/\/ \u7ebf\u7a0b 2\uff1a\u5c1d\u8bd5\u83b7\u53d6 key2 \u2192 \u5728\u51fd\u6570\u4e2d\u518d\u83b7\u53d6 key1\nmap.computeIfAbsent(\"key2\", k -&gt; {\n    \/\/ \u7b49\u5f85 key1 \u7684\u9501\n    return map.computeIfAbsent(\"key1\", k2 -&gt; \"value1\");\n});<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u5e94\u7684\u65f6\u5e8f\u5206\u6790\u5982\u4e0b\u6240\u793a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u65f6\u95f4\u7ebf    \u7ebf\u7a0b1                    \u7ebf\u7a0b2\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nt1       \u83b7\u53d6 segment A \u9501 (key1)    \nt2                               \u83b7\u53d6 segment B \u9501 (key2)\nt3       \u5c1d\u8bd5\u83b7\u53d6 segment B \u9501 (key2)  \u2190 \u963b\u585e\nt4                               \u5c1d\u8bd5\u83b7\u53d6 segment A \u9501 (key1) \u2190 \u963b\u585e\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u7ed3\u679c\uff1aAB-BA \u6b7b\u9501\uff01\u4e24\u4e2a\u7ebf\u7a0b\u6c38\u4e45\u7b49\u5f85<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u73b0\u5728\uff0c\u6211\u4eec\u6765\u770b\u770b Spring \u6846\u67b6\u4e2d\u7684\u5b9e\u9645\u89e6\u53d1\u70b9\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 Spring \u4e0a\u4e0b\u6587\u521d\u59cb\u5316\u671f\u95f4\uff0c\u4ee5\u4e0b\u4ee3\u7801\u8def\u5f84\u4f1a\u89e6\u53d1\u8fd9\u4e2a\u95ee\u9898\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>AnnotationTypeMappings.Cache.get()<\/code> \u5927\u7ea6\u5728 AnnotationTypeMappings.java \u6587\u4ef6\u4e2d\u7684 273 \u884c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Spring \u6846\u67b6\u5185\u90e8\u7684\u5b9e\u9645\u4ee3\u7801\npublic AnnotationTypeMappings get(Class&lt;? extends Annotation&gt; annotationType) {\n    return this.mappings.computeIfAbsent(annotationType, type -&gt; {\n        \/\/ \u5728\u8fd9\u91cc\u4f1a\u9012\u5f52\u8c03\u7528 computeIfAbsent \u521b\u5efa\u5b50\u6ce8\u89e3\u6620\u5c04\n        return createMappings(type); \/\/ \u2190 \u53ef\u80fd\u518d\u6b21\u8bbf\u95ee\u540c\u4e00\u4e2a map\n    });\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u5e94\u7528\u4e0a\u4e0b\u6587\u590d\u6742\u3001\u5b58\u5728\u591a\u7ea7\u6ce8\u89e3\u5d4c\u5957\uff0c\u5e76\u4e14\u591a\u4e2a\u7ebf\u7a0b\u5e76\u53d1\u521d\u59cb\u5316\u6216\u5e94\u7528\u542f\u52a8\u524d\u540e\u61d2\u52a0\u8f7d\u7b49\u5e76\u53d1\u521d\u59cb\u5316\u65f6\uff0c\u5c31\u6709\u53ef\u80fd\u547d\u4e2d\u8fd9\u4e2a\u6b7b\u9501\u9677\u9631\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4fee\u590d\u65b9\u6848<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e00\u822c\u6765\u8bf4\uff0c\u6709\u95ee\u9898\uff0c\u4e0d\u884c\u7684\u8bdd\uff0c\u5c31\u518d\u8bd5\u4e00\u6b21\uff0c\u4f46\u8fd9\u4e2a\u95ee\u9898\uff0c\u91c7\u7528\u91cd\u8bd5\u5c31\u8d8a\u6539\u8d8a\u9ebb\u70e6\u4e86\uff0c\u800c\u4e14\u6709\u70b9\u5934\u75bc\u533b\u811a\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u770b\u770b\u5b98\u65b9\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4fee\u590d\u7b56\u7565<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Spring \u56e2\u961f\u5728 v7.0.2 \u548c v6.2.15 \u4e2d\u91c7\u7528\u4e86<code>\u53cc\u91cd\u68c0\u67e5\u52a0\u9501\uff08Double-Checked Locking\uff09+ \u89e3\u9501\u91cd\u8bd5<\/code>\u7684\u65b9\u6848\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u4fee\u590d\u540e\u7684\u4ee3\u7801\u903b\u8f91\uff08\u7b80\u5316\u7248\uff09\npublic V computeIfAbsent(K key, Function&lt;? super K, ? extends V&gt; mappingFunction) {\n    int hash = getHash(key);\n    Segment segment = getSegment(hash);\n\n    \/\/ \u7b2c\u4e00\u6b21\u68c0\u67e5\uff1a\u65e0\u9501\u5feb\u901f\u8def\u5f84\n    V value = get(key);\n    if (value != null) {\n        return value;\n    }\n\n    \/\/ \u52a0\u9501\u5e76\u7b2c\u4e8c\u6b21\u68c0\u67e5\n    segment.lock();\n    try {\n        V currentValue = get(key);\n        if (currentValue != null) {\n            return currentValue; \/\/ \u5df2\u7ecf\u5b58\u5728\uff0c\u76f4\u63a5\u8fd4\u56de\n        }\n\n        \/\/ \u5173\u952e\u4fee\u590d\uff1a\u5728\u8c03\u7528\u7528\u6237\u51fd\u6570\u524d\u91ca\u653e\u9501\uff01\n        segment.unlock(); \n\n        \/\/ \u5728\u9501\u5916\u8ba1\u7b97\u65b0\u503c\n        V newValue = mappingFunction.apply(key);\n        if (newValue == null) {\n            return null;\n        }\n\n        \/\/ \u91cd\u65b0\u83b7\u53d6\u9501\u5e76\u68c0\u67e5\uff0c\u9632\u6b62\u7ade\u6001\u6761\u4ef6\n        segment.lock();\n        try {\n            V existingValue = get(key);\n            if (existingValue != null) {\n                \/\/ \u5176\u4ed6\u7ebf\u7a0b\u5df2\u7ecf\u63d2\u5165\u4e86\u503c\uff0c\u653e\u5f03\u6211\u4eec\u7684\u8ba1\u7b97\u7ed3\u679c\n                return existingValue;\n            }\n            return put(key, newValue);\n        } finally {\n            segment.unlock();\n        }\n    } finally {\n        if (segment.isHeldByCurrentThread()) {\n            segment.unlock(); \/\/ \u786e\u4fdd\u89e3\u9501\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u4fee\u590d\u8981\u70b9<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u603b\u7ed3\u4e00\u4e0b\u4fee\u590d\u8981\u70b9\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u5c06\u7528\u6237\u4ee3\u7801\u79fb\u51fa\u9501\u533a\uff1a\u6700\u5173\u952e\u7684\u6539\u53d8\u662f\u5728\u8c03\u7528 <code>mappingFunction.apply()<\/code>\u4e4b\u524d\u91ca\u653e\u9501\uff0c\u907f\u514d\u5728\u9501\u5185\u6267\u884c\u4e0d\u53ef\u63a7\u7684\u7528\u6237\u903b\u8f91\u3002<\/li><li>\u53cc\u91cd\u68c0\u67e5\u52a0\u9501\uff1a\u91c7\u7528\u7ecf\u5178\u7684 DCL \u6a21\u5f0f\uff0c\u65e2\u4fdd\u8bc1\u4e86\u6027\u80fd\uff0c\u53c8\u786e\u4fdd\u4e86\u7ebf\u7a0b\u5b89\u5168\u3002<\/li><li>\u4f18\u96c5\u5904\u7406\u7ade\u6001\uff1a\u5373\u4f7f\u91ca\u653e\u4e86\u9501\uff0c\u4e5f\u80fd\u6b63\u786e\u5904\u7406\u5176\u4ed6\u7ebf\u7a0b\u5e76\u53d1\u63d2\u5165\u7684\u60c5\u51b5\u3002<\/li><li>\u4fdd\u8bc1 happens-before\uff1a\u901a\u8fc7\u5408\u7406\u7684\u9501\u987a\u5e8f\u548c volatile \u53d8\u91cf\uff0c\u786e\u4fdd\u5185\u5b58\u53ef\u89c1\u6027\u3002<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a bug \u5e76\u4e0d\u662f\u5fc5\u73b0\u7684\uff0c\u53ea\u6709\u5728\u9ad8\u5e76\u53d1\u542f\u52a8\u7684\u5fae\u670d\u52a1\u7684\u573a\u666f\uff0c\u6bd4\u5982\uff1a\u4f7f\u7528 Spring Cloud \u7684\u5fae\u670d\u52a1\u96c6\u7fa4\u3001\u5b9e\u4f8b\u542f\u52a8\u65f6\uff0c\u6d89\u53ca\u5927\u91cf\u6ce8\u89e3\u626b\u63cf\u7684\u573a\u666f\u3002\u6216\u8005\u662f\u4f7f\u7528\u590d\u6742\u6ce8\u89e3\u4f53\u7cfb\u7684\u5e94\u7528\uff0c\u5927\u91cf\u4f7f\u7528\u81ea\u5b9a\u4e49\u6ce8\u89e3\u548c\u5143\u6ce8\u89e3\u3001\u6ce8\u89e3\u4e4b\u95f4\u5b58\u5728\u590d\u6742\u7684\u7ee7\u627f\u5173\u7cfb\u7684\u573a\u666f\u3002\u4e5f\u6709\u7f51\u53cb\u53cd\u9988\uff0c\u5728 AOT\/GraalVM \u539f\u751f\u955c\u50cf\uff0cAhead-of-Time \u7f16\u8bd1\u65f6\u5927\u91cf\u5e76\u53d1\u6784\u5efa\u5143\u6570\u636e\u3001Native Image \u6784\u5efa\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u89e6\u53d1\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5347\u7ea7\u5efa\u8bae<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u7ba1\u600e\u4e48\u8bf4\uff0c\u6211\u5efa\u8bae\u5927\u5bb6\u8fdb\u884c\u5347\u7ea7\u3002\u65e2\u7136\u4f7f\u7528\u4e86 Spring 7 \u4e86\uff0c\u5c0f\u7248\u672c\u5347\u7ea7\u5f71\u54cd\u4e0d\u5927\u7684\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\uff0c\u5982\u679c\u4f60\u6b63\u5728\u4f7f\u7528<code>Spring Framework 6.2.13 - 7.0.1<\/code>\uff0c\u6700\u4f73\u7684\u5b9e\u8df5\u662f\u8bf7\u7acb\u5373\u5347\u7ea7\u5230 7.0.2 \u6216 6.2.15\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u5e94\u7684 Maven \u914d\u7f6e\u53d8\u66f4\u5982\u4e0b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- \u5bf9\u4e8e Spring Boot 3.x \/ Spring Framework 7.x --&gt;\n&lt;properties&gt;\n    &lt;spring-framework.version&gt;7.0.2&lt;\/spring-framework.version&gt;\n&lt;\/properties&gt;\n\n&lt;!-- \u6216\u5bf9\u4e8e Spring Boot 2.7.x \/ Spring Framework 5.3.x --&gt;\n&lt;properties&gt;\n    &lt;spring-framework.version&gt;6.2.15&lt;\/spring-framework.version&gt;\n&lt;\/properties&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5347\u7ea7\u540e\uff0c\u53ef\u4ee5\u8fdb\u884c\u9a8c\u8bc1\u4fee\u590d\u3002\u793e\u533a\u63a8\u8350\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u9a8c\u8bc1\u95ee\u9898\u662f\u5426\u89e3\u51b3\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u8fdb\u884c\u7ebf\u7a0b DUMP \u5206\u6790\u542f\u52a8\u65f6\u751f\u6210\u7ebf\u7a0b dump\uff0c\u68c0\u67e5\u662f\u5426\u5b58\u5728 <code>ConcurrentReferenceHashMap<\/code> \u76f8\u5173\u7684\u6b7b\u9501\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u542f\u52a8\u5e94\u7528\u65f6\u83b7\u53d6\u7ebf\u7a0b dump\njstack &lt;pid&gt; &gt; threaddump.txt\n\n# \u68c0\u67e5\u662f\u5426\u5305\u542b \"deadlock\" \u5173\u952e\u5b57\ngrep -i \"deadlock\" threaddump.txt<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6216\u8005\u8fdb\u884c\u542f\u52a8\u65f6\u95f4\u76d1\u63a7\uff0c\u89c2\u5bdf\u5e94\u7528\u542f\u52a8\u65f6\u95f4\u662f\u5426\u6062\u590d\u6b63\u5e38\uff0c\u662f\u5426\u8fd8\u6709\u968f\u673a\u6302\u8d77\u73b0\u8c61\u3002\u8fd9\u4e2a\u5c31\u6bd4\u8f83\u96be\u590d\u73b0\uff0c\u4e00\u822c\u7248\u672c\u5347\u7ea7\u540e\u4e0d\u4f1a\u518d\u51fa\u73b0\u8fd9\u7c7b\u95ee\u9898\u3002\u4e5f\u6216\u8005\u8fdb\u884c\u65e5\u5fd7\u68c0\u67e5\uff0c\u542f\u7528 Spring \u8c03\u8bd5\u65e5\u5fd7\uff0c\u89c2\u5bdf\u6ce8\u89e3\u6620\u5c04\u52a0\u8f7d\u8fc7\u7a0b\uff0c\u8fd9\u4e2a\u4e5f\u4e0d\u592a\u63a8\u8350\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>logging.level.org.springframework.core.annotation=DEBUG<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u9884\u9632\u63aa\u65bd<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u793e\u533a\u8fd8\u5efa\u8bae\uff0c\u5373\u4f7f\u5347\u7ea7\u540e\uff0c\u4e5f\u5e94\u9075\u5faa\u4ee5\u4e0b\u6700\u4f73\u5b9e\u8df5\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u907f\u514d\u5728 computeIfAbsent \u4e2d\u9012\u5f52\u8c03\u7528\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u5371\u9669\u505a\u6cd5\nmap.computeIfAbsent(key1, k -&gt; {\n   return map.computeIfAbsent(key2, ...); \/\/ \u53ef\u80fd\u6b7b\u9501\n});\n\n\/\/ \u5b89\u5168\u505a\u6cd5\nValue value = map.get(key2);\nif (value == null) {\n   value = computeExpensiveValue();\n   map.putIfAbsent(key2, value);\n}\nmap.put(key1, value);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u6b21\u662f\u4fdd\u6301 mapping \u51fd\u6570\u7b80\u6d01\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u53ea\u505a\u7eaf\u7cb9\u7684\u8ba1\u7b97\uff0c\u4e0d\u8c03\u7528\u5916\u90e8\u670d\u52a1<\/li><li>\u4e0d\u8bbf\u95ee\u5171\u4eab\u8d44\u6e90<\/li><li>\u907f\u514d\u590d\u6742\u7684\u5bf9\u8c61\u56fe\u6784\u5efa<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e3a\u4ec0\u4e48\u8fd9\u4e2a Bug \u5982\u6b64\u9690\u853d\uff1f<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a bug \u4e4b\u6240\u4ee5\u96be\u4ee5\u590d\u73b0\uff0c\u662f\u56e0\u4e3a\u5b83\u7b26\u5408\u5e76\u53d1 Bug \u7684\u5178\u578b\u7279\u5f81\u3002\u5373\uff0c\u4f53\u73b0\u4e86\u5e76\u53d1\u7f16\u7a0b\u4e2d<code>\u65f6\u5e8f\u4f9d\u8d56\uff08Timing Dependency\uff09<\/code>\u7684\u5178\u578b\u7279\u5f81\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u4e0d\u53ef\u91cd\u73b0\u6027\uff1a\u540c\u6837\u7684\u4ee3\u7801\uff0c\u6709\u65f6\u8fd0\u884c\u6b63\u5e38\uff0c\u6709\u65f6\u6b7b\u9501<\/li><li>\u73af\u5883\u654f\u611f\u6027\uff1aCPU \u6838\u5fc3\u6570\u3001\u7ebf\u7a0b\u8c03\u5ea6\u7b56\u7565\u3001JVM \u7248\u672c\u90fd\u4f1a\u5f71\u54cd\u89e6\u53d1\u6982\u7387<\/li><li>\u8fde\u9501\u53cd\u5e94\uff1a\u6846\u67b6\u5c42\u7684\u6b7b\u9501\u4f1a\u5bfc\u81f4\u6574\u4e2a\u5e94\u7528\u5c42\u65e0\u6cd5\u8bca\u65ad<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u6700\u540e<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Spring Framework 7.0 \u4f5c\u4e3a\u65b0\u4e00\u4ee3\u6846\u67b6\uff0c\u5f15\u5165\u4e86\u591a\u9879\u91cd\u5927\u6539\u8fdb\u3002\u8fd9\u6b21\u53ca\u65f6\u7684 Bug \u4fee\u590d\u5c55\u73b0\u4e86 Spring \u56e2\u961f\u5bf9\u8d28\u91cf\u7684\u9ad8\u5ea6\u91cd\u89c6\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f60\u7684\u9879\u76ee\u4f7f\u7528\u4e86 Spring 7\uff0c\u5efa\u8bae\u7acb\u5373\u68c0\u67e5\u4f60\u7684\u9879\u76ee\u4f9d\u8d56\uff0c\u5347\u7ea7 Spring Framework \u7248\u672c\uff01\u5e76\u65f6\u523b\u7262\u8bb0\u8bb0<code>\u9884\u9632\u80dc\u4e8e\u6cbb\u7597\uff0c\u76d1\u63a7\u4f18\u4e8e\u6392\u67e5<\/code>\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=5464\">Spring 7 \u73b0\u91cd\u5927\u6b7b\u9501 bug\uff0c\u5e94\u7528\u5047\u6b7b\u65e0\u65e5\u5fd7\uff0c\u5076\u53d1\u96be\u590d\u73b0<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u8ddd\u79bb\u4e0a\u6b21\u6d4f\u89c8 Spring \u5b98\u7f51\u5dee\u4e0d\u591a\u6709\u4e24\u4e2a\u661f\u671f\u4e86\uff0c\u4e8e\u662f\u6211\u4eca\u5929\u518d\u6b21\u53bb\u5b98\u7f51\u627e\u627e\u770b\uff0c\u6709\u6ca1\u6709\u65b0\u7684\u6280\u672f\u6587\u7ae0\u503c\u5f97\u5b66\u4e60\u3002  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[713,551,587,1638,568],"class_list":["post-5464","post","type-post","status-publish","format-standard","hentry","category-java","tag-maven","tag-spring","tag-spring-boot","tag-springcloud","tag-568"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/5464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5464"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/5464\/revisions"}],"predecessor-version":[{"id":5465,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/5464\/revisions\/5465"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}