Skip to content

Commit

Permalink
Merge pull request #28990 from gsmet/2.14.0-backports-2
Browse files Browse the repository at this point in the history
2.14.0 backports 2
  • Loading branch information
gsmet authored Nov 2, 2022
2 parents 49bb66c + be8659b commit 95ff839
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 20 deletions.
6 changes: 6 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4257,6 +4257,12 @@
<artifactId>jandex</artifactId>
<version>${jandex.version}</version>
</dependency>
<!-- this is a relocation to io.smallrye:jandex, for consumers who didn't move yet -->
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
<version>${jandex.version}</version>
</dependency>

<dependency>
<groupId>org.graalvm.nativeimage</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;

Expand Down Expand Up @@ -176,8 +177,23 @@ public void accept(Integer integer) {
Class<?> appClass = Class.forName(className, true, runtimeClassLoader);
Method start = appClass.getMethod("main", String[].class);
start.invoke(null, (Object) (args == null ? new String[0] : args));
Class<?> q = Class.forName(Quarkus.class.getName(), true, runtimeClassLoader);
q.getMethod("blockingExit").invoke(null);

CountDownLatch latch = new CountDownLatch(1);
new Thread(new Runnable() {
@Override
public void run() {
try {
Class<?> q = Class.forName(Quarkus.class.getName(), true, runtimeClassLoader);
q.getMethod("blockingExit").invoke(null);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
latch.countDown();
}
}
}).start();
latch.await();

Object newApplication = getCurrentApplication.invoke(null);
if (oldApplication == newApplication) {
//quarkus was not actually started by the main method
Expand Down
7 changes: 7 additions & 0 deletions core/runtime/src/main/java/io/quarkus/runtime/Quarkus.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.Closeable;
import java.io.IOException;
import java.util.Locale;
import java.util.function.BiConsumer;

import org.jboss.logging.Logger;
Expand Down Expand Up @@ -179,6 +180,12 @@ public static void waitForExit() {
* Must not be called by the main thread, or a deadlock will result.
*/
public static void blockingExit() {
if (Thread.currentThread().getThreadGroup().getName().equals("main") &&
Thread.currentThread().getName().toLowerCase(Locale.ROOT).contains("main")) {
Logger.getLogger(Quarkus.class).error(
"'Quarkus#blockingExit' was called on the main thread. This will result in deadlocking the application!");
}

Application app = Application.currentApplication();
asyncExit();
if (app != null) {
Expand Down
14 changes: 12 additions & 2 deletions devtools/cli/distribution/release-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ then
exit 1
fi

MAINTENANCE="$3"
if [ -z "$MAINTENANCE" ]
then
echo "Must specify maintenance mode"
exit 1
fi

DIST_DIR="$( dirname "${BASH_SOURCE[0]}" )"
pushd ${DIST_DIR}

Expand Down Expand Up @@ -43,9 +50,12 @@ popd

export JRELEASER_PROJECT_VERSION=${VERSION}
export JRELEASER_BRANCH=${BRANCH}
export JRELEASER_CHOCOLATEY_GITHUB_BRANCH=${BRANCH}
if [ "$MAINTENANCE" == "true" ]; then
export JRELEASER_CHOCOLATEY_GITHUB_BRANCH=${BRANCH}
export JRELEASER_HOMEBREW_GITHUB_BRANCH=${BRANCH}
fi

jbang org.jreleaser:jreleaser:1.1.0 full-release \
jbang org.jreleaser:jreleaser:1.3.0 full-release \
--git-root-search \
-od target

Expand Down
4 changes: 4 additions & 0 deletions docs/src/main/asciidoc/cdi-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@ In the development mode, two special endpoints are registered automatically to p

NOTE: These endpoints are only available in the development mode, i.e. when you run your application via `mvn quarkus:dev` (or `./gradlew quarkusDev`).

=== Monitoring Business Method Invocations and Events

In the development mode, it is also possible to enable monitoring of business method invocations and fired events.
Simply set the `quarkus.arc.dev-mode.monitoring-enabled` configuration property to `true` and explore the relevant Dev UI pages.

[[arc-configuration-reference]]
== ArC Configuration Reference
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/security.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Quarkus Security is a framework that provides the architecture, multiple authent
Before you start building security into your Quarkus applications, review the overview information to learn about the Quarkus Security architecture and the different authentication and authorization mechanisms that Quarkus supports.

To get started with security in Quarkus, we recommend that you first combine the Quarkus built-in xref:security-basic-auth-concept.adoc[Basic HTTP authentication] with the JPA identity provider to enable role-based access control (RBAC).
Complete the steps in the ref:security-getting-started.adoc[Secure a Quarkus application with Basic authentication] tutorial.
Complete the steps in the xref:security-getting-started.adoc[Secure a Quarkus application with Basic authentication] tutorial.
After you have successfully secured your Quarkus application with basic HTTP authentication, you can increase the security further by adding more advanced authentication mechanisms, for example, OpenID Connect (OIDC) authentication.

== Security architecture
Expand Down Expand Up @@ -439,4 +439,4 @@ You can adjust the expiry date if you need to.
== Quarkus Security testing

When testing Quarkus security, ensure that your `IdentityProvider` is already set with usernames, passwords, and roles in `application.properties`.
For more information about testing Quarkus Security, see xref:security-testing.adoc#configuring-user-information[Configuring user information].
For more information about testing Quarkus Security, see xref:security-testing.adoc#configuring-user-information[Configuring user information].
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ArcDevModeConfig {
/**
* If set to true then the container monitors business method invocations and fired events during the development mode.
*/
@ConfigItem(defaultValue = "true")
@ConfigItem(defaultValue = "false")
public boolean monitoringEnabled;

}
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private String runBuildpackBuild(BuildpackConfig buildpackConfig,
log.debug("Using source root of " + dirs.get(ProjectDirs.SOURCE));
log.debug("Using project root of " + dirs.get(ProjectDirs.ROOT));

String targetImageName = containerImage.getImage().toString();
String targetImageName = containerImage.getImage();
log.debug("Using Destination image of " + targetImageName);

Map<String, String> envMap = new HashMap<>(buildpackConfig.builderEnv);
Expand Down Expand Up @@ -204,11 +204,13 @@ private String runBuildpackBuild(BuildpackConfig buildpackConfig,

log.info("Buildpack build complete");
if (containerImageConfig.isPushExplicitlyEnabled() || pushRequest.isPresent()) {
if (!containerImageConfig.registry.isPresent()) {
log.info("No container image registry was set, so 'docker.io' will be used");
}
var registry = containerImage.getRegistry()
.orElseGet(() -> {
log.info("No container image registry was set, so 'docker.io' will be used");
return "docker.io";
});
AuthConfig authConfig = new AuthConfig();
authConfig.withRegistryAddress(containerImageConfig.registry.orElse("docker.io"));
authConfig.withRegistryAddress(registry);
containerImageConfig.username.ifPresent(u -> authConfig.withUsername(u));
containerImageConfig.password.ifPresent(p -> authConfig.withPassword(p));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,14 @@ private JibContainer containerize(ContainerImageConfig containerImageConfig,
}

private Containerizer createContainerizer(ContainerImageConfig containerImageConfig,
JibConfig jibConfig, ContainerImageInfoBuildItem containerImage,
JibConfig jibConfig, ContainerImageInfoBuildItem containerImageInfo,
boolean pushRequested) {
Containerizer containerizer;
ImageReference imageReference = ImageReference.of(containerImage.getRegistry().orElse(null),
containerImage.getRepository(), containerImage.getTag());
ImageReference imageReference = ImageReference.of(containerImageInfo.getRegistry().orElse(null),
containerImageInfo.getRepository(), containerImageInfo.getTag());

if (pushRequested || containerImageConfig.isPushExplicitlyEnabled()) {
if (!containerImageConfig.registry.isPresent()) {
if (imageReference.getRegistry() == null) {
log.info("No container image registry was set, so 'docker.io' will be used");
}
RegistryImage registryImage = toRegistryImage(imageReference, containerImageConfig.username,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public Supplier<HibernateSearchSupplier.IndexedPersistenceUnits> infoSupplier(
Map<String, HibernateSearchElasticsearchRuntimeConfigPersistenceUnit> puConfigs = runtimeConfig
.getAllPersistenceUnitConfigsAsMap();
Set<String> activePersistenceUnitNames = persistenceUnitNames.stream()
.filter(name -> puConfigs.get(name).active.orElse(true))
.filter(name -> {
var puConfig = puConfigs.get(name);
return puConfig == null || puConfig.active.orElse(true);
})
.collect(Collectors.toCollection(LinkedHashSet::new));
return new HibernateSearchSupplier(activePersistenceUnitNames);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,10 @@ void register(
if (value != null) {
// Add the type-id-resolver class
reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, value.asClass().name().toString()));
// Add the whole hierarchy of the annotated class
addReflectiveHierarchyClass(resolverInstance.target().asClass().name(), reflectiveHierarchyClass);
if (resolverInstance.target().kind() == CLASS) {
// Add the whole hierarchy of the annotated class
addReflectiveHierarchyClass(resolverInstance.target().asClass().name(), reflectiveHierarchyClass);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package io.quarkus.resteasy.reactive.server.test.resource.basic;

import static org.hamcrest.Matchers.equalTo;

import java.io.IOException;
import java.util.function.Supplier;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.ext.Provider;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;

public class ContainerRequestContextTest {

@RegisterExtension
static QuarkusUnitTest test = new QuarkusUnitTest()
.setArchiveProducer(new Supplier<>() {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class)
.addClass(HelloResource.class);
}
});

@Test
public void helloWorldTest() {
RestAssured.get("/hello")
.then()
.body(equalTo("hello foo"));
}

@Path("/hello")
public static class HelloResource {

private final ContainerRequestContext containerRequestContext;

public HelloResource(ContainerRequestContext containerRequestContext) {
this.containerRequestContext = containerRequestContext;
}

@GET
public String hello() {
return "hello " + containerRequestContext.getProperty("name");
}

}

@Provider
public static class TestFilter implements ContainerRequestFilter {

@Override
public void filter(ContainerRequestContext context) throws IOException {
context.setProperty("name", "foo");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public static List<ResolvedDependency> getReloadableModules(ApplicationModel app
final Map<ArtifactKey, WorkspaceDependencies> modules = new HashMap<>();
StringBuilder nonReloadable = null;
for (ResolvedDependency d : appModel.getDependencies()) {
if (!d.isJar()) {
continue;
}
if (d.isReloadable()) {
modules.put(d.getKey(), new WorkspaceDependencies(d));
} else if (d.isWorkspaceModule()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Singleton;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ResourceContext;
import javax.ws.rs.container.ResourceInfo;
import javax.ws.rs.core.Application;
Expand Down Expand Up @@ -51,6 +52,13 @@ HttpHeaders headers() {
return getContext().getHttpHeaders();
}

// this is added for compatibility reasons
@RequestScoped
@Produces
ContainerRequestContext containerRequestContext() {
return getContext().getContainerRequestContext();
}

@ApplicationScoped
@Produces
Sse sse() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.inject.Named;

import org.hamcrest.Matchers;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand All @@ -20,7 +21,8 @@ public class DevConsoleArcSmokeTest {
@RegisterExtension
static final QuarkusDevModeTest test = new QuarkusDevModeTest()
.withApplicationRoot((jar) -> jar
.addClasses(Foo.class));
.addClasses(Foo.class).addAsResource(new StringAsset("quarkus.arc.dev-mode.monitoring-enabled=true"),
"application.properties"));

@Test
public void testPages() {
Expand Down

0 comments on commit 95ff839

Please sign in to comment.