Skip to content

Commit

Permalink
Merge pull request #27740 from gsmet/2.12.1-backports-1
Browse files Browse the repository at this point in the history
2.12.1 backports 1
  • Loading branch information
gsmet committed Sep 6, 2022
2 parents 22d2a08 + 844e01e commit 4297ddd
Show file tree
Hide file tree
Showing 104 changed files with 1,805 additions and 222 deletions.
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Expand Up @@ -44,7 +44,7 @@
<smallrye-health.version>3.2.1</smallrye-health.version>
<smallrye-metrics.version>3.0.5</smallrye-metrics.version>
<smallrye-open-api.version>2.2.0</smallrye-open-api.version>
<smallrye-graphql.version>1.7.0</smallrye-graphql.version>
<smallrye-graphql.version>1.7.1</smallrye-graphql.version>
<smallrye-opentracing.version>2.1.1</smallrye-opentracing.version>
<smallrye-fault-tolerance.version>5.5.0</smallrye-fault-tolerance.version>
<smallrye-jwt.version>3.5.3</smallrye-jwt.version>
Expand Down Expand Up @@ -152,7 +152,7 @@
<kotlin.coroutine.version>1.6.4</kotlin.coroutine.version>
<kotlin-serialization.version>1.4.0</kotlin-serialization.version>
<kubernetes-client.version>5.12.3</kubernetes-client.version> <!-- Please check with Java Operator SDK team before updating -->
<dekorate.version>2.11.0</dekorate.version> <!-- Please check with Java Operator SDK team before updating -->
<dekorate.version>2.11.2</dekorate.version> <!-- Please check with Java Operator SDK team before updating -->
<maven-invoker.version>3.2.0</maven-invoker.version>
<awaitility.version>4.2.0</awaitility.version>
<jboss-logmanager.version>1.0.10</jboss-logmanager.version>
Expand Down
@@ -1,7 +1,9 @@
package io.quarkus.deployment.builditem;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import io.quarkus.builder.item.MultiBuildItem;

Expand All @@ -15,14 +17,15 @@
*/
public final class DevServicesAdditionalConfigBuildItem extends MultiBuildItem {

private final DevServicesAdditionalConfigProvider configProvider;
private final Collection<String> triggeringKeys;
private final String key;
private final String value;
private final Runnable callbackWhenEnabled;

/**
* @deprecated Call
* {@link DevServicesAdditionalConfigBuildItem#DevServicesAdditionalConfigBuildItem(Collection, String, String, Runnable)}
* {@link DevServicesAdditionalConfigBuildItem#DevServicesAdditionalConfigBuildItem(DevServicesAdditionalConfigProvider)}
* instead.
*/
@Deprecated
Expand All @@ -31,35 +34,85 @@ public DevServicesAdditionalConfigBuildItem(String triggeringKey,
this(List.of(triggeringKey), key, value, callbackWhenEnabled);
}

/**
* @deprecated Call
* {@link DevServicesAdditionalConfigBuildItem#DevServicesAdditionalConfigBuildItem(DevServicesAdditionalConfigProvider)}
* instead.
*/
@Deprecated
public DevServicesAdditionalConfigBuildItem(Collection<String> triggeringKeys,
String key, String value, Runnable callbackWhenEnabled) {
this.triggeringKeys = triggeringKeys;
this.key = key;
this.value = value;
this.callbackWhenEnabled = callbackWhenEnabled;
this.configProvider = devServicesConfig -> {
if (triggeringKeys.stream().anyMatch(devServicesConfig::containsKey)) {
if (callbackWhenEnabled != null) {
callbackWhenEnabled.run();
}
return Map.of(key, value);
} else {
return Map.of();
}
};
}

public DevServicesAdditionalConfigBuildItem(DevServicesAdditionalConfigProvider configProvider) {
this.triggeringKeys = Collections.emptyList();
this.key = null;
this.value = null;
this.callbackWhenEnabled = null;
this.configProvider = configProvider;
}

/**
* @deprecated Call {@link #getTriggeringKeys()} instead.
* @deprecated Don't call this method, use {@link #getConfigProvider()} instead.
*/
@Deprecated
public String getTriggeringKey() {
return getTriggeringKeys().iterator().next();
}

/**
* @deprecated Don't call this method, use {@link #getConfigProvider()} instead.
*/
@Deprecated
public Collection<String> getTriggeringKeys() {
return triggeringKeys;
}

/**
* @deprecated Don't call this method, use {@link #getConfigProvider()} instead.
*/
@Deprecated
public String getKey() {
return key;
}

/**
* @deprecated Don't call this method, use {@link #getConfigProvider()} instead.
*/
@Deprecated
public String getValue() {
return value;
}

/**
* @deprecated Don't call this method, use {@link #getConfigProvider()} instead.
*/
@Deprecated
public Runnable getCallbackWhenEnabled() {
return callbackWhenEnabled;
}

public DevServicesAdditionalConfigProvider getConfigProvider() {
return configProvider;
}

public interface DevServicesAdditionalConfigProvider {

Map<String, String> provide(Map<String, String> devServicesConfig);

}
}
Expand Up @@ -50,5 +50,9 @@ public int getJavaVersion() {
public String getDistribution() {
return distribution;
}

public static GraalVMVersion unknown() {
return new GraalVMVersion("unknown", "unknown", -1, "unknown");
}
}
}
Expand Up @@ -425,7 +425,7 @@ public boolean test(String path) {
*/
private static boolean includeAppDep(ResolvedDependency appDep, Optional<Set<ArtifactKey>> optionalDependencies,
Set<ArtifactKey> removedArtifacts) {
if (!"jar".equals(appDep.getType())) {
if (!appDep.isJar()) {
return false;
}
if (appDep.isOptional()) {
Expand Down Expand Up @@ -577,7 +577,6 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem,
} else {
IoUtils.createOrEmptyDir(quarkus);
}
Map<ArtifactKey, List<Path>> copiedArtifacts = new HashMap<>();

Path decompiledOutputDir = null;
boolean wasDecompiledSuccessfully = true;
Expand Down Expand Up @@ -672,14 +671,15 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem,
}
}
final Set<ArtifactKey> parentFirstKeys = getParentFirstKeys(curateOutcomeBuildItem, classLoadingConfig);
StringBuilder classPath = new StringBuilder();
final StringBuilder classPath = new StringBuilder();
final Set<ArtifactKey> removed = getRemovedKeys(classLoadingConfig);
final Map<ArtifactKey, List<Path>> copiedArtifacts = new HashMap<>();
for (ResolvedDependency appDep : curateOutcomeBuildItem.getApplicationModel().getRuntimeDependencies()) {
if (rebuild) {
appDep.getResolvedPaths().forEach(jars::add);
} else {
if (!rebuild) {
copyDependency(parentFirstKeys, outputTargetBuildItem, copiedArtifacts, mainLib, baseLib, jars, true,
classPath, appDep, transformedClasses, removed);
} else if (includeAppDep(appDep, outputTargetBuildItem.getIncludedOptionalDependencies(), removed)) {
appDep.getResolvedPaths().forEach(jars::add);
}
if (parentFirstKeys.contains(appDep.getKey())) {
appDep.getResolvedPaths().forEach(parentFirst::add);
Expand Down Expand Up @@ -745,15 +745,13 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem,

//now copy the deployment artifacts, if required
if (mutableJar) {

Path deploymentLib = libDir.resolve(DEPLOYMENT_LIB);
Files.createDirectories(deploymentLib);
for (ResolvedDependency appDep : curateOutcomeBuildItem.getApplicationModel().getDependencies()) {
copyDependency(parentFirstKeys, outputTargetBuildItem, copiedArtifacts, deploymentLib, baseLib, jars,
false, classPath,
appDep, new TransformedClassesBuildItem(Collections.emptyMap()), removed); //we don't care about transformation here, so just pass in an empty item
appDep, new TransformedClassesBuildItem(Map.of()), removed); //we don't care about transformation here, so just pass in an empty item
}

Map<ArtifactKey, List<String>> relativePaths = new HashMap<>();
for (Map.Entry<ArtifactKey, List<Path>> e : copiedArtifacts.entrySet()) {
relativePaths.put(e.getKey(),
Expand Down Expand Up @@ -804,7 +802,6 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem,
}
} else {
//if it is a rebuild we might have classes

}
try (Stream<Path> files = Files.walk(buildDir)) {
files.forEach(new Consumer<Path>() {
Expand Down
Expand Up @@ -202,6 +202,12 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, LocalesBuildTimeCon
String resultingExecutableName = getResultingExecutableName(nativeImageName, isContainerBuild);
Path generatedExecutablePath = outputDir.resolve(resultingExecutableName);
Path finalExecutablePath = outputTargetBuildItem.getOutputDirectory().resolve(resultingExecutableName);
if (nativeConfig.reuseExisting) {
if (Files.exists(finalExecutablePath)) {
return new NativeImageBuildItem(finalExecutablePath,
NativeImageBuildItem.GraalVMVersion.unknown());
}
}

NativeImageBuildRunner buildRunner = getNativeImageBuildRunner(nativeConfig, outputDir,
nativeImageName, resultingExecutableName);
Expand All @@ -213,15 +219,6 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, LocalesBuildTimeCon
} else {
log.error("Unable to get GraalVM version from the native-image binary.");
}
if (nativeConfig.reuseExisting) {
if (Files.exists(finalExecutablePath)) {
return new NativeImageBuildItem(finalExecutablePath,
new NativeImageBuildItem.GraalVMVersion(graalVMVersion.fullVersion,
graalVMVersion.version.toString(),
graalVMVersion.javaFeatureVersion,
graalVMVersion.distribution.name()));
}
}

try {
if (nativeConfig.cleanupServer) {
Expand Down Expand Up @@ -677,19 +674,21 @@ public NativeImageInvokerInfo build() {
}
nativeImageArgs.add("--features=" + String.join(",", featuresList));

/*
* Instruct GraalVM / Mandrel parse compiler graphs twice, once for the static analysis and once again
* for the AOT compilation.
*
* We do this because single parsing significantly increases memory usage at build time
* see https://github.com/oracle/graal/issues/3435 and
* https://github.com/graalvm/mandrel/issues/304#issuecomment-952070568 for more details.
*
* Note: This option must come before the invocation of
* {@code handleAdditionalProperties(nativeImageArgs)} to ensure that devs and advanced users can
* override it by passing -Dquarkus.native.additional-build-args=-H:+ParseOnce
*/
nativeImageArgs.add("-H:-ParseOnce");
if (graalVMVersion.isOlderThan(GraalVM.Version.VERSION_22_2_0)) {
/*
* Instruct GraalVM / Mandrel parse compiler graphs twice, once for the static analysis and once again
* for the AOT compilation.
*
* We do this because single parsing significantly increases memory usage at build time
* see https://github.com/oracle/graal/issues/3435 and
* https://github.com/graalvm/mandrel/issues/304#issuecomment-952070568 for more details.
*
* Note: This option must come before the invocation of
* {@code handleAdditionalProperties(nativeImageArgs)} to ensure that devs and advanced users can
* override it by passing -Dquarkus.native.additional-build-args=-H:+ParseOnce
*/
nativeImageArgs.add("-H:-ParseOnce");
}

/**
* This makes sure the Kerberos integration module is made available in case any library
Expand Down
Expand Up @@ -65,16 +65,11 @@ public void run() {
oldConfig = newProperties;

Map<String, String> newPropertiesWithAdditionalConfig = new HashMap<>(newProperties);
var unmodifiableNewProperties = Collections.unmodifiableMap(newProperties);
// On contrary to dev services config, "additional" config build items are
// produced on each restart, so we don't want to remember them from one restart to the next.
for (DevServicesAdditionalConfigBuildItem item : devServicesAdditionalConfigBuildItems) {
if (item.getTriggeringKeys().stream().anyMatch(newProperties::containsKey)) {
var callback = item.getCallbackWhenEnabled();
if (callback != null) {
callback.run(); // This generally involves logging
}
newPropertiesWithAdditionalConfig.put(item.getKey(), item.getValue());
}
newPropertiesWithAdditionalConfig.putAll(item.getConfigProvider().provide(unmodifiableNewProperties));
}

for (Map.Entry<String, String> entry : newPropertiesWithAdditionalConfig.entrySet()) {
Expand Down
@@ -1,16 +1,20 @@
package io.quarkus.runtime.configuration;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.eclipse.microprofile.config.ConfigValue;
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.jboss.logging.Logger;

import io.quarkus.runtime.annotations.Recorder;
import io.quarkus.runtime.configuration.ConfigurationRuntimeConfig.BuildTimeMismatchAtRuntime;
import io.smallrye.config.ConfigSourceInterceptorContext;
import io.smallrye.config.ExpressionConfigSourceInterceptor;
import io.smallrye.config.SmallRyeConfig;
import io.smallrye.config.SmallRyeConfigBuilder;

Expand All @@ -26,18 +30,51 @@ public ConfigRecorder(ConfigurationRuntimeConfig configurationConfig) {
}

public void handleConfigChange(Map<String, ConfigValue> buildTimeRuntimeValues) {
// Create a new Config without the "BuildTime RunTime Fixed" sources to check for different values
SmallRyeConfigBuilder configBuilder = ConfigUtils.emptyConfigBuilder();
// We need to disable the expression resolution, because we may be missing expressions from the "BuildTime RunTime Fixed" source
configBuilder.withDefaultValue(Config.PROPERTY_EXPRESSIONS_ENABLED, "false");
for (ConfigSource configSource : ConfigProvider.getConfig().getConfigSources()) {
if ("BuildTime RunTime Fixed".equals(configSource.getName())) {
continue;
}
configBuilder.withSources(configSource);
}
// Add a new expression resolution to fall back to the current Config if we cannot expand the expression
configBuilder.withInterceptors(new ExpressionConfigSourceInterceptor() {
@Override
public io.smallrye.config.ConfigValue getValue(final ConfigSourceInterceptorContext context, final String name) {
return super.getValue(new ConfigSourceInterceptorContext() {
@Override
public io.smallrye.config.ConfigValue proceed(final String name) {
io.smallrye.config.ConfigValue configValue = context.proceed(name);
if (configValue == null) {
configValue = (io.smallrye.config.ConfigValue) ConfigProvider.getConfig().getConfigValue(name);
if (configValue.getValue() == null) {
return null;
}
}
return configValue;
}

@Override
public Iterator<String> iterateNames() {
return context.iterateNames();
}

@Override
public Iterator<io.smallrye.config.ConfigValue> iterateValues() {
return context.iterateValues();
}
}, name);
}
});
SmallRyeConfig config = configBuilder.build();

List<String> mismatches = new ArrayList<>();
for (Map.Entry<String, ConfigValue> entry : buildTimeRuntimeValues.entrySet()) {
ConfigValue currentValue = config.getConfigValue(entry.getKey());
// Check for changes. Also, we only have a change if the source ordinal is higher
if (currentValue.getValue() != null && !entry.getValue().getValue().equals(currentValue.getValue())
&& entry.getValue().getSourceOrdinal() < currentValue.getSourceOrdinal()) {
mismatches.add(
Expand Down

0 comments on commit 4297ddd

Please sign in to comment.