Skip to content

Commit

Permalink
Merge pull request #40746 from gsmet/3.10.2-backports-1
Browse files Browse the repository at this point in the history
[3.10] 3.10.2 backports 1
  • Loading branch information
gsmet authored May 22, 2024
2 parents a45c652 + a7b06d7 commit 8c0ae01
Show file tree
Hide file tree
Showing 20 changed files with 250 additions and 48 deletions.
8 changes: 4 additions & 4 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<properties>
<angus-activation.version>2.0.2</angus-activation.version>
<bouncycastle.version>1.78.1</bouncycastle.version>
<bouncycastle.fips.version>1.0.2.4</bouncycastle.fips.version>
<bouncycastle.tls.fips.version>1.0.18</bouncycastle.tls.fips.version>
<bouncycastle.fips.version>1.0.2.5</bouncycastle.fips.version>
<bouncycastle.tls.fips.version>1.0.19</bouncycastle.tls.fips.version>
<expressly.version>5.0.0</expressly.version>
<findbugs.version>3.0.2</findbugs.version>
<jandex.version>3.1.7</jandex.version>
Expand Down Expand Up @@ -205,8 +205,8 @@
<avro.version>1.11.3</avro.version>
<apicurio-registry.version>2.5.10.Final</apicurio-registry.version>
<apicurio-common-rest-client.version>0.1.18.Final</apicurio-common-rest-client.version> <!-- must be the version Apicurio Registry uses -->
<testcontainers.version>1.19.7</testcontainers.version> <!-- Make sure to also update docker-java.version to match its needs -->
<docker-java.version>3.3.5</docker-java.version> <!-- must be the version Testcontainers use -->
<testcontainers.version>1.19.8</testcontainers.version> <!-- Make sure to also update docker-java.version to match its needs -->
<docker-java.version>3.3.6</docker-java.version> <!-- must be the version Testcontainers use -->
<!-- Check the compatibility matrix (https://github.com/opensearch-project/opensearch-testcontainers) before upgrading: -->
<opensearch-testcontainers.version>2.0.0</opensearch-testcontainers.version>
<com.dajudge.kindcontainer>1.4.5</com.dajudge.kindcontainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public BuildCommandArgs prepareAction(String action, BuildOptions buildOptions,

if (buildOptions.buildNative) {
args.add("-Dquarkus.native.enabled=true");
args.add("-Dquarkus.jar.enabled=false");
args.add("-Dquarkus.package.jar.enabled=false");
}
if (buildOptions.skipTests()) {
setSkipTests(args);
Expand Down
6 changes: 3 additions & 3 deletions docs/sync-web-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ if [ -z $TARGET_DIR ]; then
GIT_OPTIONS="--depth=1"
fi
if [ -n "${RELEASE_GITHUB_TOKEN}" ]; then
git clone -b develop --single-branch $GIT_OPTIONS https://github.com/quarkusio/quarkusio.github.io.git ${TARGET_DIR}
git clone --single-branch $GIT_OPTIONS https://github.com/quarkusio/quarkusio.github.io.git ${TARGET_DIR}
else
git clone -b develop --single-branch $GIT_OPTIONS [email protected]:quarkusio/quarkusio.github.io.git ${TARGET_DIR}
git clone --single-branch $GIT_OPTIONS [email protected]:quarkusio/quarkusio.github.io.git ${TARGET_DIR}
fi
fi

Expand Down Expand Up @@ -148,7 +148,7 @@ then
cd target/web-site
git add -A
git commit -m "Sync web site with Quarkus documentation"
git push origin develop
git push origin main
echo "Web Site updated - wait for CI build"
else
echo "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.ByteArrayOutputStream;
import java.nio.channels.Channels;
import java.nio.channels.WritableByteChannel;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -62,7 +63,7 @@ protected HttpResponseMessage nettyDispatch(HttpRequestMessage<Optional<String>>

HttpContent requestContent = LastHttpContent.EMPTY_LAST_CONTENT;
if (request.getBody().isPresent()) {
ByteBuf body = Unpooled.wrappedBuffer(request.getBody().get().getBytes());
ByteBuf body = Unpooled.wrappedBuffer(request.getBody().get().getBytes(StandardCharsets.UTF_8));
requestContent = new DefaultLastHttpContent(body);
}

Expand Down
3 changes: 3 additions & 0 deletions extensions/jdbc/jdbc-h2/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<parentFirstArtifacts>
<parentFirstArtifact>com.h2database:h2</parentFirstArtifact>
</parentFirstArtifacts>
<capabilities>
<provides>io.quarkus.jdbc.h2</provides>
</capabilities>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@
import io.quarkus.deployment.builditem.LogCategoryBuildItem;
import io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem;
import io.quarkus.deployment.builditem.RuntimeConfigSetupCompleteBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageSecurityProviderBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassConditionBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import io.quarkus.deployment.logging.LogCleanupFilterBuildItem;
import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
Expand Down Expand Up @@ -477,15 +477,16 @@ UnremovableBeanBuildItem ensureJsonParserAvailable() {
}

@BuildStep
public void registerRuntimeInitializedClasses(BuildProducer<RuntimeInitializedClassBuildItem> producer) {
// Classes using java.util.Random, which need to be runtime initialized
producer.produce(
new RuntimeInitializedClassBuildItem("org.apache.kafka.common.security.authenticator.SaslClientAuthenticator"));
producer.produce(new RuntimeInitializedClassBuildItem(
"org.apache.kafka.common.security.oauthbearer.internals.expiring.ExpiringCredentialRefreshingLogin"));
// VerificationKeyResolver is value on static map in OAuthBearerValidatorCallbackHandler
producer.produce(new RuntimeInitializedClassBuildItem(
"org.apache.kafka.common.security.oauthbearer.OAuthBearerValidatorCallbackHandler"));
NativeImageConfigBuildItem nativeImageConfiguration() {
NativeImageConfigBuildItem.Builder builder = NativeImageConfigBuildItem.builder()
// Classes using java.util.Random, which need to be runtime initialized
.addRuntimeInitializedClass("org.apache.kafka.common.security.authenticator.SaslClientAuthenticator")
.addRuntimeInitializedClass(
"org.apache.kafka.common.security.oauthbearer.internals.expiring.ExpiringCredentialRefreshingLogin")
// VerificationKeyResolver is value on static map in OAuthBearerValidatorCallbackHandler
.addRuntimeInitializedClass("org.apache.kafka.common.security.oauthbearer.OAuthBearerValidatorCallbackHandler")
.addRuntimeReinitializedClass("org.apache.kafka.shaded.com.google.protobuf.UnsafeUtil");
return builder.build();
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package io.smallrye.reactive.kafka.graal;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

import sun.misc.Unsafe;

@TargetClass(className = "org.apache.kafka.common.network.SaslChannelBuilder")
final class Target_org_apache_kafka_common_network_SaslChannelBuilder {

Expand All @@ -17,6 +20,20 @@ private static String defaultKerberosRealm() throws ClassNotFoundException, NoSu

}

@TargetClass(className = "org.apache.kafka.shaded.com.google.protobuf.UnsafeUtil")
final class Target_org_apache_kafka_shaded_com_google_protobuf_UnsafeUtil {
@Substitute
static sun.misc.Unsafe getUnsafe() {
try {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
return (Unsafe) theUnsafe.get(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

class KafkaSubstitutions {

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -36,6 +37,7 @@
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.arc.processor.DotNames;
import io.quarkus.datasource.common.runtime.DataSourceUtil;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.Feature;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
Expand Down Expand Up @@ -101,6 +103,7 @@ void nativeImageConfiguration(
LiquibaseBuildTimeConfig liquibaseBuildConfig,
List<JdbcDataSourceBuildItem> jdbcDataSourceBuildItems,
CombinedIndexBuildItem combinedIndex,
Capabilities capabilities,
BuildProducer<ReflectiveClassBuildItem> reflective,
BuildProducer<NativeImageResourceBuildItem> resource,
BuildProducer<ServiceProviderBuildItem> services,
Expand Down Expand Up @@ -212,7 +215,7 @@ void nativeImageConfiguration(
// CommandStep implementations are needed
consumeService(liquibase.command.CommandStep.class, (serviceClass, implementations) -> {
var filteredImpls = implementations.stream()
.filter(not("liquibase.command.core.StartH2CommandStep"::equals))
.filter(commandStepPredicate(capabilities))
.toArray(String[]::new);
services.produce(new ServiceProviderBuildItem(serviceClass.getName(), filteredImpls));
reflective.produce(ReflectiveClassBuildItem.builder(filteredImpls).constructors().build());
Expand Down Expand Up @@ -250,6 +253,14 @@ void nativeImageConfiguration(
resourceBundle.produce(new NativeImageResourceBundleBuildItem("liquibase/i18n/liquibase-core"));
}

private static Predicate<String> commandStepPredicate(Capabilities capabilities) {
if (capabilities.isPresent("io.quarkus.jdbc.h2")) {
return (s) -> true;
} else {
return not("liquibase.command.core.StartH2CommandStep"::equals);
}
}

private void consumeService(Class<?> serviceClass, BiConsumer<Class<?>, Collection<String>> consumer) {
try {
String service = "META-INF/services/" + serviceClass.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,9 @@ public Throwable apply(Throwable tInner) {

private static void logAuthenticationError(RoutingContext context, Throwable t) {
final String errorMessage = errorMessage(t);
final boolean accessTokenFailure = context.get(OidcConstants.ACCESS_TOKEN_VALUE) != null
&& context.get(OidcUtils.CODE_ACCESS_TOKEN_RESULT) == null;
final boolean accessTokenFailure = context.get(OidcUtils.CODE_ACCESS_TOKEN_FAILURE) != null;
if (accessTokenFailure) {
LOG.errorf("Access token verification has failed: %s. ID token has not been verified yet", errorMessage);
LOG.errorf("Access token verification has failed: %s.", errorMessage);
} else {
LOG.errorf("ID token verification has failed: %s", errorMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private Uni<SecurityIdentity> validateTokenWithUserInfoAndCreateIdentity(Map<Str
@Override
public Uni<SecurityIdentity> apply(TokenVerificationResult codeAccessToken, Throwable t) {
if (t != null) {
requestData.put(OidcUtils.CODE_ACCESS_TOKEN_FAILURE, t);
return Uni.createFrom().failure(new AuthenticationFailedException(t));
}

Expand Down Expand Up @@ -217,6 +218,7 @@ public Uni<SecurityIdentity> apply(TokenVerificationResult result, Throwable t)
public Uni<SecurityIdentity> apply(TokenVerificationResult codeAccessTokenResult,
Throwable t) {
if (t != null) {
requestData.put(OidcUtils.CODE_ACCESS_TOKEN_FAILURE, t);
return Uni.createFrom().failure(t instanceof AuthenticationFailedException ? t
: new AuthenticationFailedException(t));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public final class OidcUtils {
public static final String ANNOTATION_BASED_TENANT_RESOLUTION_ENABLED = "io.quarkus.oidc.runtime.select-tenants-with-annotation";
static final String UNDERSCORE = "_";
static final String CODE_ACCESS_TOKEN_RESULT = "code_flow_access_token_result";
static final String CODE_ACCESS_TOKEN_FAILURE = "code_flow_access_token_failure";
static final String COMMA = ",";
static final Uni<Void> VOID_UNI = Uni.createFrom().voidItem();
static final BlockingTaskRunner<Void> deleteTokensRequestContext = new BlockingTaskRunner<Void>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.quarkus.resteasy.test;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.List;

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

import io.quarkus.builder.Version;
import io.quarkus.deployment.Capability;
import io.quarkus.maven.dependency.Dependency;
import io.quarkus.test.QuarkusUnitTest;

class UserFriendlyQuarkusRESTCapabilityCombinationTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.setForcedDependencies(List.of(Dependency.of("io.quarkus", "quarkus-rest-deployment", Version.getVersion())))
.assertException(t -> {
assertTrue(t.getMessage().contains("only one provider of the following capabilities"), t.getMessage());
assertTrue(t.getMessage().contains("capability %s is provided by".formatted(Capability.REST)), t.getMessage());
});

@Test
public void test() {
fail();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ A more full example of generated client (with sub-resource) can is at the bottom
// NOTE: don't use type here, because we're not going through the collection converters and stuff
Type parameterType = jandexMethod.parameterType(paramIdx);
addFormParam(methodCreator, param.name, methodCreator.getMethodParam(paramIdx),
parameterType, param.declaredType, param.signature, index,
parameterType, param.signature, index,
restClientInterface.getClassName(), methodCreator.getThis(), formParams,
getGenericTypeFromArray(methodCreator, methodGenericParametersField, paramIdx),
getAnnotationsFromArray(methodCreator, methodParamAnnotationsField, paramIdx),
Expand Down Expand Up @@ -2538,7 +2538,7 @@ private void addSubBeanParamData(MethodInfo jandexMethod, int paramIndex, Byteco
case FORM_PARAM:
FormParamItem formParam = (FormParamItem) item;
addFormParam(creator, formParam.getFormParamName(), formParam.extract(creator, param),
jandexMethod.parameterType(paramIndex), formParam.getParamType(), formParam.getParamSignature(),
formParam.getParamType(), formParam.getParamSignature(),
index,
restClientInterfaceClassName, client,
formParams,
Expand Down Expand Up @@ -2810,15 +2810,15 @@ private void addFormParam(BytecodeCreator methodCreator,
String paramName,
ResultHandle formParamHandle,
Type parameterType,
String parameterTypeStr,
String parameterSignature,
IndexView index,
String restClientInterfaceClassName, ResultHandle client, AssignableResultHandle formParams,
ResultHandle genericType,
ResultHandle parameterAnnotations, boolean multipart,
String partType, String partFilename, String errorLocation) {
if (multipart) {
handleMultipartField(paramName, partType, partFilename, parameterTypeStr, parameterSignature, formParamHandle,
handleMultipartField(paramName, partType, partFilename, parameterType.name().toString(), parameterSignature,
formParamHandle,
formParams, methodCreator,
client, restClientInterfaceClassName, parameterAnnotations, genericType,
errorLocation);
Expand Down Expand Up @@ -2846,7 +2846,8 @@ private void addFormParam(BytecodeCreator methodCreator,
creator.invokeInterfaceMethod(MULTIVALUED_MAP_ADD_ALL, formParams,
creator.load(paramName), convertedParamArray);
} else {
ResultHandle convertedFormParam = convertParamToString(creator, client, formParamHandle, parameterTypeStr,
ResultHandle convertedFormParam = convertParamToString(creator, client, formParamHandle,
parameterType.name().toString(),
genericType, parameterAnnotations);
BytecodeCreator parameterIsStringBranch = checkStringParam(creator, convertedFormParam,
restClientInterfaceClassName, errorLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.net.URI;
import java.util.List;

import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;

Expand All @@ -26,26 +27,33 @@ public class FormListTest {
URI baseUri;

@Test
void testHeadersWithSubresource() {
void test() {
Client client = RestClientBuilder.newBuilder().baseUri(baseUri).build(Client.class);

assertThat(client.call(List.of("first", "second", "third"))).isEqualTo("first-second-third");
assertThat(client.call(List.of("first"))).isEqualTo("first");
Holder holder = new Holder();
holder.input2 = List.of("1", "2");
assertThat(client.call(List.of("first", "second", "third"), holder)).isEqualTo("first-second-third/1-2");
assertThat(client.call(List.of("first"), holder)).isEqualTo("first/1-2");
}

@Path("/test")
public static class Resource {

@POST
public String response(@RestForm List<String> input) {
return String.join("-", input);
public String response(@RestForm List<String> input, @RestForm List<String> input2) {
return String.join("-", input) + "/" + String.join("-", input2);
}
}

@Path("/test")
public interface Client {

@POST
String call(@RestForm List<String> input);
String call(@RestForm List<String> input, @BeanParam Holder holder);
}

public static class Holder {
@RestForm
public List<String> input2;
}
}
Loading

0 comments on commit 8c0ae01

Please sign in to comment.