forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#40040 from mkouba/issue-39971
Qute: do not register TemplateInstance as non-blocking type by default
- Loading branch information
Showing
5 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...deployment/src/main/java/io/quarkus/resteasy/reactive/qute/deployment/RestQuteConfig.java
This file contains 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,22 @@ | ||
package io.quarkus.resteasy.reactive.qute.deployment; | ||
|
||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
import io.smallrye.config.ConfigMapping; | ||
import io.smallrye.config.WithDefault; | ||
|
||
@ConfigMapping(prefix = "quarkus.rest.qute") | ||
@ConfigRoot(phase = ConfigPhase.BUILD_TIME) | ||
public interface RestQuteConfig { | ||
|
||
/** | ||
* If set to {@code true} then the {@link io.quarkus.qute.TemplateInstance} is registered as a non-blocking return type for | ||
* JAX-RS resource methods. | ||
* | ||
* @deprecated This config item will be removed at some time after Quarkus 3.16 | ||
*/ | ||
@Deprecated(forRemoval = true, since = "3.10") | ||
@WithDefault("false") | ||
boolean templateInstanceNonBlockingType(); | ||
|
||
} |
This file contains 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
48 changes: 48 additions & 0 deletions
48
.../io/quarkus/resteasy/reactive/qute/deployment/TemplateInstanceNonBlockingEnabledTest.java
This file contains 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,48 @@ | ||
package io.quarkus.resteasy.reactive.qute.deployment; | ||
|
||
import static io.restassured.RestAssured.when; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.qute.Template; | ||
import io.quarkus.qute.TemplateInstance; | ||
import io.quarkus.runtime.BlockingOperationControl; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class TemplateInstanceNonBlockingEnabledTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(TestResource.class) | ||
.addAsResource(new StringAsset("quarkus.rest.qute.template-instance-non-blocking-type=true"), | ||
"application.properties") | ||
.addAsResource(new StringAsset("Blocking allowed: {blockingAllowed}"), "templates/item.txt")); | ||
|
||
@Test | ||
public void test() { | ||
when().get("/test").then().statusCode(200).body(Matchers.is("Blocking allowed: false")); | ||
} | ||
|
||
@Path("test") | ||
public static class TestResource { | ||
|
||
@Inject | ||
Template item; | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public TemplateInstance get() { | ||
return item.data("blockingAllowed", BlockingOperationControl.isBlockingAllowed()); | ||
} | ||
} | ||
} |
This file contains 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 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