Skip to content

Commit

Permalink
Merge pull request #35898 from gsmet/3.4.0-backports-1
Browse files Browse the repository at this point in the history
3.4.0 backports 1
  • Loading branch information
gsmet authored Sep 13, 2023
2 parents 61e8b29 + c285890 commit ff4033d
Show file tree
Hide file tree
Showing 44 changed files with 1,098 additions and 198 deletions.
2 changes: 0 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ updates:
- dependency-name: io.smallrye.common:*
- dependency-name: io.smallrye.config:*
- dependency-name: io.smallrye.reactive:*
# Swagger-UI
- dependency-name: org.webjars:swagger-ui
# RX Java 2
- dependency-name: io.reactivex.rxjava2:rxjava
# Test dependencies
Expand Down
4 changes: 0 additions & 4 deletions .mvn/gradle-enterprise.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
<enabled>false</enabled>
</local>
<remote>
<server>
<url>https://ge.quarkus.io/cache/main/</url>
<allowUntrusted>false</allowUntrusted>
</server>
<enabled>true</enabled>
<storeEnabled>#{env['CI'] != null}</storeEnabled>
</remote>
Expand Down
16 changes: 11 additions & 5 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<javax.annotation-api.version>1.3.2</javax.annotation-api.version>
<javax.inject.version>1</javax.inject.version>
<parsson.version>1.1.2</parsson.version>
<resteasy-microprofile.version>2.1.1.Final</resteasy-microprofile.version>
<resteasy-microprofile.version>2.1.4.Final</resteasy-microprofile.version>
<resteasy-spring-web.version>3.0.2.Final</resteasy-spring-web.version>
<resteasy.version>6.2.5.Final</resteasy.version>
<opentracing.version>0.33.0</opentracing.version>
Expand Down Expand Up @@ -54,7 +54,7 @@
<smallrye-config.version>3.3.4</smallrye-config.version>
<smallrye-health.version>4.0.4</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>3.5.1</smallrye-open-api.version>
<smallrye-open-api.version>3.5.2</smallrye-open-api.version>
<smallrye-graphql.version>2.4.0</smallrye-graphql.version>
<smallrye-opentracing.version>3.0.3</smallrye-opentracing.version>
<smallrye-fault-tolerance.version>6.2.6</smallrye-fault-tolerance.version>
Expand Down Expand Up @@ -139,7 +139,7 @@
<rest-assured.version>5.3.0</rest-assured.version>
<junit.jupiter.version>5.9.3</junit.jupiter.version>
<junit-pioneer.version>1.5.0</junit-pioneer.version>
<infinispan.version>14.0.16.Final</infinispan.version>
<infinispan.version>14.0.17.Final</infinispan.version>
<infinispan.protostream.version>4.6.5.Final</infinispan.protostream.version>
<caffeine.version>3.1.5</caffeine.version>
<netty.version>4.1.97.Final</netty.version>
Expand Down Expand Up @@ -168,7 +168,9 @@
<jboss-logmanager.version>3.0.2.Final</jboss-logmanager.version>
<flyway.version>9.21.2</flyway.version>
<yasson.version>3.0.3</yasson.version>
<liquibase.version>4.20.0</liquibase.version>
<!-- liquibase-mongodb is not released everytime with liquibase anymore, but the two versions need to be compatible -->
<liquibase.version>4.23.1</liquibase.version>
<liquibase-mongodb.version>4.23.0</liquibase-mongodb.version>
<snakeyaml.version>2.1</snakeyaml.version>
<osgi.version>6.0.0</osgi.version>
<mongo-client.version>4.10.2</mongo-client.version>
Expand Down Expand Up @@ -5893,6 +5895,10 @@
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- liquibase-core has a dependency on org.osgi:osgi.core -->
Expand All @@ -5904,7 +5910,7 @@
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-mongodb</artifactId>
<version>${liquibase.version}</version>
<version>${liquibase-mongodb.version}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ public final class RunTimeConfigurationGenerator {

static final MethodDescriptor PU_IS_PROPERTY_IN_ROOT = MethodDescriptor.ofMethod(PropertiesUtil.class,
"isPropertyInRoot", boolean.class, Set.class, NameIterator.class);
static final MethodDescriptor PU_FILTER_PROPERTIES_IN_ROOTS = MethodDescriptor.ofMethod(PropertiesUtil.class,
"filterPropertiesInRoots", Iterable.class, Iterable.class, Set.class);

static final MethodDescriptor PU_IS_PROPERTY_QUARKUS_COMPOUND_NAME = MethodDescriptor.ofMethod(PropertiesUtil.class,
"isPropertyQuarkusCompoundName", boolean.class, NameIterator.class);
static final MethodDescriptor PU_FILTER_UNKNOWN = MethodDescriptor.ofMethod(PropertiesUtil.class, "filterUnknown",
Expand Down Expand Up @@ -668,16 +671,10 @@ public void run() {

private void configSweepLoop(MethodDescriptor parserBody, MethodCreator method, ResultHandle config,
Set<String> registeredRoots, Type type) {
ResultHandle rootSet;
ResultHandle nameSet;
ResultHandle iterator;

rootSet = method.newInstance(HS_NEW);
for (String registeredRoot : registeredRoots) {
method.invokeVirtualMethod(HS_ADD, rootSet, method.load(registeredRoot));
}

nameSet = method.invokeVirtualMethod(SRC_GET_PROPERTY_NAMES, config);
nameSet = filterProperties(method, config, registeredRoots);
iterator = method.invokeInterfaceMethod(ITRA_ITERATOR, nameSet);

try (BytecodeCreator sweepLoop = method.createScope()) {
Expand All @@ -701,8 +698,6 @@ private void configSweepLoop(MethodDescriptor parserBody, MethodCreator method,
// if (! keyIter.hasNext()) continue sweepLoop;
hasNext.ifNonZero(hasNext.invokeVirtualMethod(NI_HAS_NEXT, keyIter)).falseBranch().continueScope(sweepLoop);
// if (! keyIter.nextSegmentEquals("quarkus")) continue sweepLoop;
hasNext.ifNonZero(hasNext.invokeStaticMethod(PU_IS_PROPERTY_IN_ROOT, rootSet, keyIter)).falseBranch()
.continueScope(sweepLoop);
// parse(config, keyIter);
hasNext.invokeStaticMethod(parserBody, config, keyIter);
// continue sweepLoop;
Expand All @@ -711,6 +706,21 @@ private void configSweepLoop(MethodDescriptor parserBody, MethodCreator method,
}
}

private ResultHandle filterProperties(MethodCreator method, ResultHandle config, Set<String> registeredRoots) {
// Roots
ResultHandle rootSet;
rootSet = method.newInstance(HS_NEW);
for (String registeredRoot : registeredRoots) {
method.invokeVirtualMethod(HS_ADD, rootSet, method.load(registeredRoot));
}

// PropertyNames
ResultHandle properties = method.invokeVirtualMethod(SRC_GET_PROPERTY_NAMES, config);

// Filtered Properties
return method.invokeStaticMethod(PU_FILTER_PROPERTIES_IN_ROOTS, properties, rootSet);
}

private Set<String> getRegisteredRoots(ConfigPhase configPhase) {
Set<String> registeredRoots = new HashSet<>();
for (RootDefinition root : roots) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ private void handleAdditionalProperties(List<String> command) {
+ CONTAINER_BUILD_VOLUME_PATH + "/" + MOVED_TRUST_STORE_NAME);
} catch (IOException e) {
throw new UncheckedIOException("Unable to copy trustStore file '" + configuredTrustStorePath
+ "' to volume root directory '" + outputDir.toAbsolutePath().toString() + "'", e);
+ "' to volume root directory '" + outputDir.toAbsolutePath() + "'", e);
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,20 @@ final public class Constants {
"\n[id='" + DURATION_NOTE_ANCHOR + "']\n" +
".About the Duration format\n" +
"====\n" +
"The format for durations uses the standard `java.time.Duration` format.\n" +
"You can learn more about it in the link:https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-[Duration#parse() javadoc].\n"
"To write duration values, use the standard `java.time.Duration` format.\n" +
"See the link:https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Duration.html#parse(java.lang.CharSequence)[Duration#parse() javadoc] for more information.\n"
+
"\n" +
"You can also provide duration values starting with a number.\n" +
"In this case, if the value consists only of a number, the converter treats the value as seconds.\n" +
"Otherwise, `PT` is implicitly prepended to the value to obtain a standard `java.time.Duration` format.\n" +
"You can also use a simplified format, starting with a number:\n" +
"\n" +
"* If the value is only a number, it represents time in seconds.\n" +
"* If the value is a number followed by `ms`, it represents time in milliseconds.\n" +
"\n" +
"In other cases, the simplified format is translated to the `java.time.Duration` format for parsing:\n" +
"\n" +
"* If the value is a number followed by `h`, `m`, or `s`, it is prefixed with `PT`.\n" +
"* If the value is a number followed by `d`, it is prefixed with `P`" +
".\n" +
"====\n" +
"endif::no-duration-note[]\n";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,43 @@ public DurationConverter() {
}

/**
* The converter accepts a value which start with a number by implicitly appending `PT` to it or `P` for days.
* If the value consists only of a number, it implicitly treats the value as seconds.
* Otherwise, tries to convert the value assuming that it is in the accepted ISO-8601 duration format.
* If the {@code value} starts with a number, then:
* <ul>
* <li>If the value is only a number, it is treated as a number of seconds.</li>
* <li>If the value is a number followed by {@code ms}, it is treated as a number of milliseconds.</li>
* <li>If the value is a number followed by {@code h}, {@code m}, or {@code s}, it is prefixed with {@code PT}
* and {@link Duration#parse(CharSequence)} is called.</li>
* <li>If the value is a number followed by {@code d}, it is prefixed with {@code P}
* and {@link Duration#parse(CharSequence)} is called.</li>
* </ul>
*
* @param value duration as String
* @return {@link Duration}
* Otherwise, {@link Duration#parse(CharSequence)} is called.
*
* @param value a string duration
* @return the parsed {@link Duration}
* @throws IllegalArgumentException in case of parse failure
*/
@Override
public Duration convert(String value) {
return parseDuration(value);
}

/**
* Converts a value which start with a number by implicitly appending `PT` to it or `P` for days.
* If the value consists only of a number, it implicitly treats the value as seconds.
* Otherwise, tries to convert the value assuming that it is in the accepted ISO-8601 duration format.
* If the {@code value} starts with a number, then:
* <ul>
* <li>If the value is only a number, it is treated as a number of seconds.</li>
* <li>If the value is a number followed by {@code ms}, it is treated as a number of milliseconds.</li>
* <li>If the value is a number followed by {@code h}, {@code m}, or {@code s}, it is prefixed with {@code PT}
* and {@link Duration#parse(CharSequence)} is called.</li>
* <li>If the value is a number followed by {@code d}, it is prefixed with {@code P}
* and {@link Duration#parse(CharSequence)} is called.</li>
* </ul>
*
* Otherwise, {@link Duration#parse(CharSequence)} is called.
*
* @param value duration as String
* @return {@link Duration}
* @param value a string duration
* @return the parsed {@link Duration}
* @throws IllegalArgumentException in case of parse failure
*/
public static Duration parseDuration(String value) {
value = value.trim();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.quarkus.runtime.configuration;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import io.smallrye.config.KeyMap;
Expand Down Expand Up @@ -51,11 +53,55 @@ public static boolean isPropertyInRoot(Set<String> roots, NameIterator propertyN
return false;
}

public static boolean isPropertyQuarkusCompoundName(NameIterator propertyName) {
if (propertyName.hasNext()) {
return propertyName.getNextSegment().startsWith("quarkus.");
public static Iterable<String> filterPropertiesInRoots(final Iterable<String> properties, final Set<String> roots) {
if (roots.isEmpty()) {
return properties;
}
return false;

// Will match everything, so no point in filtering
if (roots.contains("")) {
return properties;
}

List<String> matchedProperties = new ArrayList<>();
for (String property : properties) {
// This is a Quarkus compound name, usually by setting something like `quarkus.foo.bar` in the YAML source
// TODO - We let it through to match it later again to place it in the right unknown reporting (static or runtime). We can improve this too.
if (property.startsWith("\"quarkus.")) {
matchedProperties.add(property);
continue;
}

for (String root : roots) {
// if property is less than the root no way to match
if (property.length() < root.length()) {
continue;
}

// if it is the same, then it can still map with parent name
if (property.equals(root)) {
matchedProperties.add(property);
break;
} else if (property.length() == root.length()) {
continue;
}

// foo.bar
// foo.bar."baz"
// foo.bar[0]
char c = property.charAt(root.length());
if ((c == '.') || c == '[') {
if (property.startsWith(root)) {
matchedProperties.add(property);
}
}
}
}
return matchedProperties;
}

public static boolean isPropertyQuarkusCompoundName(NameIterator propertyName) {
return propertyName.getName().startsWith("\"quarkus.");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ public static class RotationConfig {
/**
* The file handler rotation file suffix.
* When used, the file will be rotated based on its suffix.
*
* <p>
* Example fileSuffix: .yyyy-MM-dd
* <p>
* Note: If the suffix ends with .zip or .gz, the rotation file will also be compressed.
*/
@ConfigItem
Optional<String> fileSuffix;
Expand Down
29 changes: 26 additions & 3 deletions devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ private void executeGoal(PluginExec pluginExec, String goal, Map<String, String>
version(pluginExec.plugin.getVersion()),
pluginExec.plugin.getDependencies()),
goal(goal),
getPluginConfig(pluginExec.plugin, goal, params),
getPluginConfig(pluginExec.plugin, pluginExec.getExecutionId(), goal, params),
executionEnvironment(
project,
session,
Expand All @@ -720,11 +720,13 @@ private boolean isGoalConfigured(Plugin plugin, String goal) {
return false;
}

private Xpp3Dom getPluginConfig(Plugin plugin, String goal, Map<String, String> params) throws MojoExecutionException {
private Xpp3Dom getPluginConfig(Plugin plugin, String executionId, String goal, Map<String, String> params)
throws MojoExecutionException {
Xpp3Dom mergedConfig = null;
if (!plugin.getExecutions().isEmpty()) {
for (PluginExecution exec : plugin.getExecutions()) {
if (exec.getConfiguration() != null && exec.getGoals().contains(goal)) {
if (exec.getConfiguration() != null && exec.getGoals().contains(goal)
&& matchesExecution(executionId, exec.getId())) {
mergedConfig = mergedConfig == null ? (Xpp3Dom) exec.getConfiguration()
: Xpp3Dom.mergeXpp3Dom(mergedConfig, (Xpp3Dom) exec.getConfiguration(), true);
}
Expand Down Expand Up @@ -762,6 +764,27 @@ private Xpp3Dom getPluginConfig(Plugin plugin, String goal, Map<String, String>
return configuration;
}

/**
* Check if the <code>currentExecutionId</code> matches the provided <code>executionId</code>.
* <p>
* This method will return <code>true</code> if
* <ul>
* <li>current execution id is undefined</li>
* <li>execution id is undefined</li>
* <li>both equals (ignoring case)</li>
* </ul>
*
* @param currentExecutionId current execution id (if defined)
* @param executionId execution id to test matching (if defined)
* @return <code>true</code> if executions ids do match.
*/
private static boolean matchesExecution(String currentExecutionId, String executionId) {
if (currentExecutionId == null) {
return true;
}
return executionId == null || currentExecutionId.equalsIgnoreCase(executionId);
}

private MojoDescriptor getMojoDescriptor(Plugin plugin, String goal) throws MojoExecutionException {
try {
return pluginManager.getMojoDescriptor(plugin, goal, pluginRepos, repoSession);
Expand Down
17 changes: 11 additions & 6 deletions docs/src/main/asciidoc/_includes/duration-format-note.adoc
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
[NOTE]
====
The format for durations uses the standard `java.time.Duration` format.
You can learn more about it in the link:https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-[Duration#parse() javadoc].
To write duration values, use the standard `java.time.Duration` format.
See the link:https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Duration.html#parse(java.lang.CharSequence)[Duration#parse() javadoc] for more information.
You can also provide duration values starting with a number.
In this case, if the value consists only of a number, the converter treats the value as seconds.
Otherwise, `PT` for seconds, minute and hours or `P` for days are implicitly prepended to the value to obtain a standard `java.time.Duration` format.
Milliseconds are also supported by implicitly using `Duration.ofMillis()`
You can also use a simplified format, starting with a number:
* If the value is only a number, it represents time in seconds.
* If the value is a number followed by `ms`, it represents time in milliseconds.
In other cases, the simplified format is translated to the `java.time.Duration` format for parsing:
* If the value is a number followed by `h`, `m`, or `s`, it is prefixed with `PT`.
* If the value is a number followed by `d`, it is prefixed with `P`.
====
Loading

0 comments on commit ff4033d

Please sign in to comment.