Skip to content

Commit

Permalink
Merge pull request quarkusio#44476 from gsmet/3.15.2-backports-3
Browse files Browse the repository at this point in the history
[3.15] 3.15.2 backports 3
  • Loading branch information
gsmet authored Nov 14, 2024
2 parents 69cdaa2 + 85900e9 commit 61eedcf
Show file tree
Hide file tree
Showing 107 changed files with 1,669 additions and 244 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<microprofile-context-propagation.version>1.3</microprofile-context-propagation.version>
<microprofile-opentracing-api.version>3.0</microprofile-opentracing-api.version>
<microprofile-fault-tolerance-api.version>4.0.2</microprofile-fault-tolerance-api.version>
<microprofile-reactive-streams-operators.version>3.0</microprofile-reactive-streams-operators.version>
<microprofile-reactive-streams-operators.version>3.0.1</microprofile-reactive-streams-operators.version>
<microprofile-rest-client.version>3.0.1</microprofile-rest-client.version>
<microprofile-jwt.version>2.1</microprofile-jwt.version>
<microprofile-lra.version>2.0</microprofile-lra.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public interface Capability {
String OPENSHIFT_CLIENT = OPENSHIFT + ".client";

String OIDC = QUARKUS_PREFIX + ".oidc";
String OIDC_CLIENT = OIDC + ".client";

String KEYCLOAK_AUTHORIZATION = QUARKUS_PREFIX + ".keycloak.authorization";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.launcher;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
Expand All @@ -18,20 +17,14 @@ public RuntimeLaunchClassLoader(ClassLoader parent) {

@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
String resourceName = name.replace(".", "/") + ".class";
String resourceName = "META-INF/ide-deps/" + name.replace(".", "/") + ".class.ide-launcher-res";
try {
try (InputStream is = getResourceAsStream(resourceName)) {
try (InputStream is = getParent().getResourceAsStream(resourceName)) {
if (is == null) {
throw new ClassNotFoundException(name);
}
definePackage(name);
byte[] buf = new byte[1024];
int r;
ByteArrayOutputStream out = new ByteArrayOutputStream();
while ((r = is.read(buf)) > 0) {
out.write(buf, 0, r);
}
byte[] bytes = out.toByteArray();
byte[] bytes = is.readAllBytes();

return defineClass(name, bytes, 0, bytes.length);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public TemplateHtmlBuilder(String baseUrl, String title, String subTitle, String
public TemplateHtmlBuilder(String title, String subTitle, String details, List<ErrorPageAction> actions,
String redirect,
List<CurrentConfig> config) {
this(true, null, title, subTitle, details, actions, null, Collections.emptyList());
this(true, null, title, subTitle, details, actions, redirect, config);
}

public TemplateHtmlBuilder(boolean showStack, String baseUrl, String title, String subTitle, String details,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion devtools/cli/src/main/java/io/quarkus/cli/QuarkusCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public int run(String... args) throws Exception {
boolean noCommand = args.length == 0 || args[0].startsWith("-");
boolean helpCommand = Arrays.stream(args).anyMatch(arg -> arg.equals("--help"));
boolean pluginCommand = args.length >= 1 && (args[0].equals("plug") || args[0].equals("plugin"));
boolean pluginSyncCommand = pluginCommand && args.length >= 2 && args[1].equals("sync");

try {
Optional<String> missingCommand = checkMissingCommand(cmd, args);
Expand All @@ -117,7 +118,9 @@ public int run(String... args) throws Exception {
}
PluginCommandFactory pluginCommandFactory = new PluginCommandFactory(output);
PluginManager pluginManager = pluginManager(output, testDir, interactiveMode);
pluginManager.syncIfNeeded();
if (!pluginSyncCommand) { // Let`s not sync before the actual command
pluginManager.syncIfNeeded();
}
Map<String, Plugin> plugins = new HashMap<>(pluginManager.getInstalledPlugins());
pluginCommandFactory.populateCommands(cmd, plugins);
missingCommand.filter(m -> !plugins.containsKey(m)).ifPresent(m -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ private Optional<PluginCommand> createPluginCommand(Plugin plugin) {
return plugin.getLocation().map(l -> new JBangCommand(l, output));
case executable:
return plugin.getLocation().map(l -> new ShellCommand(plugin.getName(), Paths.get(l), output));
case extension:
if (PluginUtil.checkGACTV(plugin.getLocation()).isPresent()) {
return plugin.getLocation().flatMap(PluginUtil::checkGACTV).map(g -> new JBangCommand(toGAVC(g), output));
} else if (plugin.getLocation().filter(l -> l.endsWith(".jar")).isPresent()) {
return plugin.getLocation().map(l -> new JBangCommand(l, output));
}
default:
throw new IllegalStateException("Unknown plugin type!");
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/dev-ui.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ import 'qui-ide-link';
<qui-ide-link title='Source full class name'
class='text-source'
fileName='${sourceClassNameFull}'
lineNumber=${sourceLineNumber}>[${sourceClassNameFull}]</qui-ide-link>;
lineNumber='${sourceLineNumber}'>[${sourceClassNameFull}]</qui-ide-link>;
----

https://github.com/quarkusio/quarkus/blob/582f1f78806d2268885faea7aa8f5a4d2b3f5b98/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-server-log.js#L315[Example code]
Expand Down
4 changes: 4 additions & 0 deletions docs/src/main/asciidoc/getting-started-reactive.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ Create the `src/main/java/org/acme/hibernate/orm/panache/FruitResource.java` fil
----
package org.acme.hibernate.orm.panache;
import java.util.List;
import io.quarkus.panache.common.Sort;
import io.smallrye.mutiny.Uni;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ export class QwcArcBeans extends LitElement {
${bean.nonDefaultQualifiers.map(qualifier =>
html`${this._qualifierRenderer(qualifier)}`
)}
<qui-ide-link fileName='${bean.providerType.name}'
lineNumber=0><code>${bean.providerType.name}</code></qui-ide-link>
<qui-ide-link fileName='${bean.providerType.name}'><code>${bean.providerType.name}</code></qui-ide-link>
</vaadin-vertical-layout>`;
}
Expand Down Expand Up @@ -193,4 +192,4 @@ export class QwcArcBeans extends LitElement {
});
}
}
customElements.define('qwc-arc-beans', QwcArcBeans);
customElements.define('qwc-arc-beans', QwcArcBeans);
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ export class QwcArcObservers extends LitElement {
}

_sourceRenderer(bean){
return html`<qui-ide-link fileName='${bean.declaringClass.name}'
lineNumber=0><code>${bean.declaringClass.name}</code><code class="method">#${bean.methodName}()</code></qui-ide-link>`;
return html`<qui-ide-link fileName='${bean.declaringClass.name}'><code>${bean.declaringClass.name}</code><code class="method">#${bean.methodName}()</code></qui-ide-link>`;
}

_typeRenderer(bean){
Expand Down Expand Up @@ -144,4 +143,4 @@ export class QwcArcObservers extends LitElement {
return s.replaceAll('_', ' ');
}
}
customElements.define('qwc-arc-observers', QwcArcObservers);
customElements.define('qwc-arc-observers', QwcArcObservers);
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ export class QwcArcRemovedComponents extends LitElement {
${bean.nonDefaultQualifiers.map(qualifier =>
html`${this._simpleNameRenderer(qualifier)}`
)}
<qui-ide-link fileName='${bean.providerType.name}'
lineNumber=0><code>${bean.providerType.name}</code></qui-ide-link>
<qui-ide-link fileName='${bean.providerType.name}'><code>${bean.providerType.name}</code></qui-ide-link>
</vaadin-vertical-layout>`;
}

Expand Down Expand Up @@ -203,4 +202,4 @@ export class QwcArcRemovedComponents extends LitElement {
});
}
}
customElements.define('qwc-arc-removed-components', QwcArcRemovedComponents);
customElements.define('qwc-arc-removed-components', QwcArcRemovedComponents);
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io.quarkus.maven.dependency.Dependency;
import io.quarkus.test.QuarkusUnitTest;

public class SynthBeanForExternalClass {
public class SynthBeanForExternalClassTest {
// the test includes an _application_ that declares a build compatible extension
// (in the Runtime CL), which creates a synthetic bean for a class that is _outside_
// of the application (in the Base Runtime CL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import io.quarkus.maven.dependency.Dependency;
import io.quarkus.test.QuarkusUnitTest;

public class SynthObserverAsIfInExternalClass {
public class SynthObserverAsIfInExternalClassTest {
// the test includes an _application_ that declares a build compatible extension
// (in the Runtime CL), which creates a synthetic observer which is "as if" declared
// in a class that is _outside_ of the application (in the Base Runtime CL)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.quarkus.arc.test.decorator;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;

import jakarta.decorator.Decorator;
import jakarta.decorator.Delegate;
import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.arc.test.supplement.SomeBeanInExternalLibrary;
import io.quarkus.arc.test.supplement.SomeInterfaceInExternalLibrary;
import io.quarkus.builder.Version;
import io.quarkus.maven.dependency.Dependency;
import io.quarkus.test.QuarkusUnitTest;

public class DecoratorOfExternalBeanTest {
// the test includes an _application_ decorator (in the Runtime CL) that applies
// to a bean that is _outside_ of the application (in the Base Runtime CL)

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot(jar -> jar.addClass(MyDecorator.class))
// we need a non-application archive, so cannot use `withAdditionalDependency()`
.setForcedDependencies(List.of(Dependency.of("io.quarkus", "quarkus-arc-test-supplement", Version.getVersion())));

@Inject
SomeBeanInExternalLibrary bean;

@Test
public void test() {
assertEquals("Delegated: Hello", bean.hello());
}

@Decorator
public static class MyDecorator implements SomeInterfaceInExternalLibrary {
@Inject
@Delegate
SomeInterfaceInExternalLibrary delegate;

@Override
public String hello() {
return "Delegated: " + delegate.hello();
}
}
}
7 changes: 7 additions & 0 deletions extensions/arc/test-supplement/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@
<name>Quarkus - ArC - Test Supplement</name>
<description>Supplement archive for ArC tests</description>

<dependencies>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.quarkus.arc.test.supplement;

import jakarta.enterprise.context.Dependent;

@Dependent
public class SomeBeanInExternalLibrary implements SomeInterfaceInExternalLibrary {
@Override
public String hello() {
return "Hello";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.quarkus.arc.test.supplement;

public interface SomeInterfaceInExternalLibrary {
String hello();
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ public CacheInterceptionContext<T> get() {
private <T> Optional<CacheInterceptionContext<T>> getArcCacheInterceptionContext(
InvocationContext invocationContext, Class<T> interceptorBindingClass) {
Set<AbstractAnnotationLiteral> bindings = InterceptorBindings.getInterceptorBindingLiterals(invocationContext);
if (bindings == null) {
LOGGER.trace("Interceptor bindings not found in ArC");
// This should only happen when the interception is not managed by Arc.
if (bindings == null || bindings.isEmpty() || !(bindings.iterator().next() instanceof AbstractAnnotationLiteral)) {
// this should only happen when the interception is not managed by ArC
// a non-`AbstractAnnotationLiteral` can come from RESTEasy Classic's `QuarkusInvocationContextImpl`
LOGGER.trace("Interceptor bindings not found in ArC or not created by ArC");
return Optional.empty();
}
List<T> interceptorBindings = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ export class QwcGrpcServices extends observeState(QwcHotReloadElement) {
}

_serviceClassRenderer(service){
return html`<qui-ide-link fileName='${service.serviceClass}'
lineNumber=0><code>${service.serviceClass}</code></qui-ide-link>`;
return html`<qui-ide-link fileName='${service.serviceClass}'><code>${service.serviceClass}</code></qui-ide-link>`;
}

_methodsRenderer(service){
Expand Down Expand Up @@ -368,4 +367,4 @@ export class QwcGrpcServices extends observeState(QwcHotReloadElement) {
return JSON.stringify(JSON.parse(content), null, 2);
}
}
customElements.define('qwc-grpc-services', QwcGrpcServices);
customElements.define('qwc-grpc-services', QwcGrpcServices);
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class DisableLoggingFeature implements Feature {
"org.hibernate.Version",
"org.hibernate.annotations.common.Version",
"SQL dialect",
"org.hibernate.cfg.Environment"
"org.hibernate.cfg.Environment",
"org.hibernate.orm.connections.pooling"
};

private final Map<String, Level> categoryMap = new HashMap<>(CATEGORIES.length);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.quarkus.mailer.deployment;

import java.io.File;
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand All @@ -11,8 +13,12 @@
import jakarta.inject.Singleton;

import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget.Kind;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.ClassType;
import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.MethodInfo;

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem;
Expand All @@ -35,6 +41,7 @@
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
import io.quarkus.mailer.MailTemplate;
import io.quarkus.mailer.MailTemplate.MailTemplateInstance;
import io.quarkus.mailer.Mailer;
import io.quarkus.mailer.MailerName;
import io.quarkus.mailer.MockMailbox;
Expand All @@ -56,6 +63,7 @@
public class MailerProcessor {

static final DotName MAIL_TEMPLATE = DotName.createSimple(MailTemplate.class.getName());
static final DotName MAIL_TEMPLATE_INSTANCE = DotName.createSimple(MailTemplateInstance.class.getName());

static final DotName MAILER_NAME = DotName.createSimple(MailerName.class);

Expand Down Expand Up @@ -105,7 +113,7 @@ MailersBuildItem generateMailerSupportBean(MailerRecorder recorder,
.anyMatch(i -> i.hasDefaultedQualifier() ||
// we inject a MailTemplate and it is not named
(MAIL_TEMPLATE.equals(i.getType().name()) && i.getRequiredQualifier(MAILER_NAME) == null))
|| !index.getIndex().getAnnotations(CheckedTemplate.class).isEmpty();
|| isTypeSafeMailTemplateFound(index.getIndex());

Set<String> namedMailers = mailerInjectionPoints.stream()
.map(i -> i.getRequiredQualifier(MAILER_NAME))
Expand All @@ -124,6 +132,35 @@ MailersBuildItem generateMailerSupportBean(MailerRecorder recorder,
return new MailersBuildItem(hasDefaultMailer, namedMailers);
}

private boolean isTypeSafeMailTemplateFound(IndexView index) {
// Find all occurences of @CheckedTemplate
Collection<AnnotationInstance> checkedTemplates = index.getAnnotations(CheckedTemplate.class);
for (AnnotationInstance annotation : checkedTemplates) {
if (annotation.target().kind() == Kind.CLASS) {
ClassInfo target = annotation.target().asClass();
if (target.isRecord()) {
// Java record that most likely implements MailTemplateInstance
return true;
}
for (MethodInfo method : target.methods()) {
if (Modifier.isStatic(method.flags()) && method.returnType().name().equals(MAIL_TEMPLATE_INSTANCE)) {
// Target declares a static method that returns MailTemplateInstance
return true;
}
}
}
}

Collection<ClassInfo> mailTemplateInstances = index.getAllKnownImplementors(MAIL_TEMPLATE_INSTANCE);
for (ClassInfo mailTemplateInstance : mailTemplateInstances) {
if (mailTemplateInstance.isRecord()) {
// Java record that implements MailTemplateInstance found
return true;
}
}
return false;
}

@Record(ExecutionTime.RUNTIME_INIT)
@BuildStep
void generateMailerBeans(MailerRecorder recorder,
Expand Down
Loading

0 comments on commit 61eedcf

Please sign in to comment.