Close deferred query sessions after getResultCount
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 58/100
調査の方向性
Start with SharedEntityManagerCreator.queryTerminatingMethods and inspect how shared EntityManager calls close temporary sessions outside a Spring transaction. Reproduce the lifecycle imbalance with a deferred query's getResultCount(), including the shared EntityManager and EntityAgent paths; verify session closure after success and failure. Done means regression tests cover both proxies and :spring-orm:check passes.
索引モデルが issue の本文から書いたものです。
説明
Calling getResultCount() on a deferred query obtained from a shared EntityManager outside a Spring transaction leaves the temporary EntityManager open. The same occurs through the shared JPA 4.0 EntityAgent proxy.
Versions reproduced: Spring Framework 7.1.0-RC1, Hibernate ORM 8.0.0.Beta3, Jakarta Persistence 4.0.0-M7, PostgreSQL 18.6. The relevant code is unchanged on main at 7bdf9c86f8657029567067051b7c6bd47b4ae67e.
With Hibernate statistics enabled and a populated test entity:
EntityManager shared = SharedEntityManagerCreator.createSharedEntityManager(emf);
Statistics statistics = emf.unwrap(SessionFactory.class).getStatistics();
long opened = statistics.getSessionOpenCount();
long closed = statistics.getSessionCloseCount();
long count = shared.createQuery("from TestEntity", TestEntity.class).getResultCount();
System.out.println(statistics.getSessionOpenCount() - opened); // 1
System.out.println(statistics.getSessionCloseCount() - closed); // 0
There is no active Spring transaction in this example. A getResultList() call instead produces one opened and one closed session. Replacing shared with the injected EntityAgent produces the same count-query result and lifecycle imbalance. Inside a Spring transaction, normal transaction cleanup closes the session.
SharedEntityManagerCreator.queryTerminatingMethods includes the list/single-result methods but does not include getResultCount(), now exposed by JPA 4.0 TypedQuery. The existing Hibernate SelectionQuery.getResultCount() entry point is affected as well.
I verified that recognizing getResultCount as a terminating method closes the temporary session for both the shared EntityManager and EntityAgent, including when the count operation throws. Two regression tests fail on the unmodified source because EntityManager.close() is never invoked, and pass with the change. The full :spring-orm:check passes with the change: 369 tests, zero failures, two skipped, including Checkstyle and architecture checks.
This was found while testing the optional Hibernate 8/JPA 4 integration described in #36025.
- 主要言語
- Java
- スター
- 60.3k
- フォーク
- 38.7k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 35
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
spring-projects/spring-framework のほかの issue
-
`YamlProcessor.getFlattenedMap` with `includeEmpty` returns a `null` key for an empty root mapping対応中かも @erfannvb が 6 日前に担当しました。 オープンstatus: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
spring-projects/spring-framework#37522 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`WebClient` with default codecs drops `ProblemDetail` extension members再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンstatus: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
spring-projects/spring-framework#37503 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
StandardApiVersionDeprecationHandler generates nonconforming Sunset HTTP dates再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンstatus: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
spring-projects/spring-framework#37486 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
FastByteArrayOutputStream input stream rejects valid skip(long) arguments再び着手できるかも @hickey-ai が 9 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンstatus: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
spring-projects/spring-framework#37471 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
-
LinkedCaseInsensitiveMap.keySet().remove returns false after removing a null-valued entry再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンstatus: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
spring-projects/spring-framework#37470 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
spring-projects/spring-framework の issue をすべて見る
似ている issue
-
staticAssetsPath follows symlinks outside the directory on Windows対応中かも @ybelMekk が今日担当しました。 オープンbug security findings
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
navikt/mock-oauth2-server#1132 ·
メンテナーはふだん 1 日以内に返信
-
agent:working follow-up
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Sanne/incus-spawn#1683 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
checkstyle/checkstyle#22210 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
google/error-prone#6239 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Failing Test]: BigqueryClient.queryUnflattened fails BigQuery ITs on a transient 503対応中かも @mxtymoshyk が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信