-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Change how JPAConfig cleans up its resources #46357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yrodiere
merged 1 commit into
quarkusio:main
from
marko-bekhta:fix/i34547-observe-shutdown-instead-of-ondestroy-v2
Jul 3, 2025
+543
−33
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...ch/orm/outboxpolling/test/configuration/devmode/HibernateSearchDevModeFailingOrmTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package io.quarkus.hibernate.search.orm.outboxpolling.test.configuration.devmode; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
|
||
@Tag("devmode") | ||
public class HibernateSearchDevModeFailingOrmTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HibernateSearchOutboxPollingTestResource.class, | ||
HibernateSearchOutboxPollingTestResource.Person.class, | ||
HibernateSearchOutboxPollingTestResource.OutboxPollingTestUtils.class) | ||
.addAsResource("application-dev-mode.properties", "application.properties")) | ||
.setLogRecordPredicate(r -> true); | ||
|
||
static String APPLICATION_PROPERTIES; | ||
|
||
@BeforeAll | ||
static void beforeAll() throws Exception { | ||
APPLICATION_PROPERTIES = Files | ||
.readString( | ||
Paths.get(HibernateSearchDevModeFailingOrmTest.class.getResource("/application-dev-mode.properties") | ||
.toURI())); | ||
} | ||
|
||
@Test | ||
public void smoke() { | ||
RestAssured.when().put("/test/hibernate-search-outbox-polling/check-agents-running").then() | ||
.statusCode(200); | ||
|
||
// now add a property that will fail the datasource: | ||
config.modifyResourceFile( | ||
"application.properties", | ||
s -> APPLICATION_PROPERTIES + """ | ||
quarkus.datasource.jdbc.min-size=20 | ||
"""); | ||
RestAssured.when().put("/test/hibernate-search-outbox-polling/check-agents-running").then() | ||
.statusCode(500); | ||
|
||
// add any change to get the shutdown of a failed app completed: | ||
config.modifyResourceFile("application.properties", s -> APPLICATION_PROPERTIES); | ||
|
||
RestAssured.when().put("/test/hibernate-search-outbox-polling/check-agents-running").then() | ||
.statusCode(200); | ||
|
||
// At this point we've tried starting the app 3 times: one initial, one failing, one successful live-reloads | ||
// Hence we expect the following things logged: | ||
// initial run: | ||
// - profile activated (after a successful startup) | ||
// - ORM message after a successful shutdown caused by a following live-reload (closing a PU) | ||
// first reload: | ||
// - ORM message telling us that the PU closing won't happen as the PU failed to start | ||
// second reload: | ||
// - profile activated (after a successful startup) | ||
// - no ORM shutdown message, as that will happen after the test body finishes. | ||
assertThat(config.getLogRecords()).satisfiesOnlyOnce( | ||
r -> { | ||
assertThat(r.getMessage()).contains("Closing Hibernate ORM persistence unit"); | ||
assertThat(r.getParameters()).containsExactly("<default>"); | ||
}); | ||
assertThat(config.getLogRecords()).satisfiesOnlyOnce( | ||
r -> { | ||
assertThat(r.getMessage()).contains("Skipping Hibernate ORM persistence unit, that failed to start"); | ||
assertThat(r.getParameters()).containsExactly("<default>"); | ||
}); | ||
assertThat(config.getLogRecords().stream() | ||
.filter(r -> r.getMessage().contains("Profile%s %s activated. %s"))) | ||
.hasSize(2); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...orm/outboxpolling/test/configuration/devmode/HibernateSearchDevModeFailingSearchTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package io.quarkus.hibernate.search.orm.outboxpolling.test.configuration.devmode; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
|
||
@Tag("devmode") | ||
public class HibernateSearchDevModeFailingSearchTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(HibernateSearchOutboxPollingTestResource.class, | ||
HibernateSearchOutboxPollingTestResource.Person.class, | ||
HibernateSearchOutboxPollingTestResource.OutboxPollingTestUtils.class) | ||
.addAsResource("application-dev-mode.properties", "application.properties")) | ||
.setLogRecordPredicate(r -> true); | ||
|
||
static String APPLICATION_PROPERTIES; | ||
|
||
@BeforeAll | ||
static void beforeAll() throws Exception { | ||
APPLICATION_PROPERTIES = Files | ||
.readString(Paths | ||
.get(HibernateSearchDevModeFailingSearchTest.class.getResource("/application-dev-mode.properties") | ||
.toURI())); | ||
} | ||
|
||
@Test | ||
public void smoke() { | ||
RestAssured.when().put("/test/hibernate-search-outbox-polling/check-agents-running").then() | ||
.statusCode(200); | ||
|
||
// now add a property that will fail the search, but since search is started through ORM integrator.. we are actually failing ORM startup: | ||
config.modifyResourceFile( | ||
"application.properties", | ||
s -> APPLICATION_PROPERTIES.replace( | ||
"quarkus.hibernate-search-orm.elasticsearch.hosts=${elasticsearch.hosts:localhost:9200}", | ||
"quarkus.hibernate-search-orm.elasticsearch.hosts=not-a-localhost:9211")); | ||
RestAssured.when().put("/test/hibernate-search-outbox-polling/check-agents-running").then() | ||
.statusCode(500); | ||
|
||
// and any change to get the shutdown of a failed app completed: | ||
config.modifyResourceFile("application.properties", s -> APPLICATION_PROPERTIES); | ||
|
||
RestAssured.when().put("/test/hibernate-search-outbox-polling/check-agents-running").then() | ||
.statusCode(200); | ||
|
||
// At this point we've tried starting the app 3 times: one initial, one failing, one successful live-reloads | ||
// Hence we expect the following things logged: | ||
// initial run: | ||
// - profile activated (after a successful startup) | ||
// - ORM message after a successful shutdown caused by a following live-reload (closing a PU) | ||
// first reload: | ||
// - ORM message telling us that the PU closing won't happen as the PU failed to start | ||
// second reload: | ||
// - profile activated (after a successful startup) | ||
// - no ORM shutdown message, as that will happen after the test body finishes. | ||
assertThat(config.getLogRecords()).satisfiesOnlyOnce( | ||
r -> { | ||
assertThat(r.getMessage()).contains("Closing Hibernate ORM persistence unit"); | ||
assertThat(r.getParameters()).containsExactly("<default>"); | ||
}); | ||
assertThat(config.getLogRecords()).satisfiesOnlyOnce( | ||
r -> { | ||
assertThat(r.getMessage()).contains("Skipping Hibernate ORM persistence unit, that failed to start"); | ||
assertThat(r.getParameters()).containsExactly("<default>"); | ||
}); | ||
assertThat(config.getLogRecords().stream() | ||
.filter(r -> r.getMessage().contains("Profile%s %s activated. %s"))) | ||
.hasSize(2); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.