Skip to content

Commit 41cbcc1

Browse files
author
Vincent Potucek
committed
Merge branch 'main' into pmd-UnnecessaryImport
2 parents 8cb424a + a2e30b6 commit 41cbcc1

File tree

16 files changed

+408
-96
lines changed

16 files changed

+408
-96
lines changed

bom/application/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
<log4j2-api.version>2.24.3</log4j2-api.version>
195195
<log4j-jboss-logmanager.version>1.3.1.Final</log4j-jboss-logmanager.version>
196196
<avro.version>1.12.0</avro.version>
197-
<apicurio-registry.version>2.6.11.Final</apicurio-registry.version>
197+
<apicurio-registry.version>2.6.12.Final</apicurio-registry.version>
198198
<apicurio-common-rest-client.version>0.1.18.Final</apicurio-common-rest-client.version> <!-- must be the version Apicurio Registry uses -->
199199
<testcontainers.version>1.21.1</testcontainers.version> <!-- Make sure to also update docker-java.version to match its needs -->
200200
<docker-java.version>3.4.2</docker-java.version> <!-- must be the version Testcontainers use: https://central.sonatype.com/artifact/org.testcontainers/testcontainers -->

bom/dev-ui/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<description>Dependency management for dev-ui. Importable by third party extension developers.</description>
1414

1515
<properties>
16-
<vaadin.version>24.7.8</vaadin.version>
16+
<vaadin.version>24.8.0</vaadin.version>
1717
<lit.version>3.2.1</lit.version>
1818
<lit-element.version>4.1.1</lit-element.version>
1919
<lit-html.version>3.2.1</lit-html.version>

core/deployment/src/main/java/io/quarkus/deployment/pkg/NativeConfig.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,25 @@ interface Debug {
538538

539539
@ConfigGroup
540540
interface Compression {
541+
/**
542+
* Whether compression should be enabled.
543+
*/
544+
@WithDefault("true")
545+
boolean enabled();
546+
547+
/**
548+
* Whether the compression should be executed within a container.
549+
*/
550+
Optional<Boolean> containerBuild();
551+
552+
/**
553+
* The image used for compression. Defaults to {@code quarkus.native.builder-image} if not
554+
* set.
555+
* <p>
556+
* Setting this variable will automatically activate
557+
*/
558+
Optional<String> containerImage();
559+
541560
/**
542561
* The compression level in [1, 10].
543562
* 10 means <em>best</em>.

core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/UpxCompressionBuildStep.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void compress(NativeConfig nativeConfig, NativeImageRunnerBuildItem nativ
4141
BuildProducer<UpxCompressedBuildItem> upxCompressedProducer,
4242
BuildProducer<ArtifactResultBuildItem> artifactResultProducer) {
4343

44-
if (nativeConfig.compression().level().isEmpty()) {
44+
if (nativeConfig.compression().level().isEmpty() || !nativeConfig.compression().enabled()) {
4545
log.debug("UPX compression disabled");
4646
return;
4747
}
@@ -52,7 +52,8 @@ public void compress(NativeConfig nativeConfig, NativeImageRunnerBuildItem nativ
5252

5353
String effectiveBuilderImage = nativeConfig.builderImage().getEffectiveImage();
5454
Optional<File> upxPathFromSystem = getUpxFromSystem();
55-
if (upxPathFromSystem.isPresent()) {
55+
if (upxPathFromSystem.isPresent() && !nativeConfig.compression().containerBuild().orElse(false)
56+
&& nativeConfig.compression().containerImage().isEmpty()) {
5657
log.debug("Running UPX from system path");
5758
if (!runUpxFromHost(upxPathFromSystem.get(), image.getPath().toFile(), nativeConfig)) {
5859
throw new IllegalStateException("Unable to compress the native executable");
@@ -61,9 +62,12 @@ public void compress(NativeConfig nativeConfig, NativeImageRunnerBuildItem nativ
6162
log.error("Compression of native executables is not yet implemented for remote container builds.");
6263
throw new IllegalStateException(
6364
"Unable to compress the native executable: Compression of native executables is not yet supported for remote container builds");
64-
} else if (nativeImageRunner.isContainerBuild()) {
65-
log.info("Running UPX from a container using the builder image: " + effectiveBuilderImage);
66-
if (!runUpxInContainer(image, nativeConfig, effectiveBuilderImage)) {
65+
} else if (nativeConfig.compression().containerBuild().orElse(true) &&
66+
(nativeImageRunner.isContainerBuild() ||
67+
nativeConfig.compression().containerImage().isPresent())) {
68+
String compressorImage = nativeConfig.compression().containerImage().orElse(effectiveBuilderImage);
69+
log.info("Running UPX from a container using the compressor image: " + compressorImage);
70+
if (!runUpxInContainer(image, nativeConfig, compressorImage)) {
6771
throw new IllegalStateException("Unable to compress the native executable");
6872
}
6973
} else {

docs/src/main/asciidoc/kafka-dev-services.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,14 @@ quarkus.kafka.devservices.image-name=quay.io/strimzi-test-container/test-contain
8989

9090
You can configure the Dev Services for Kafka to create topics once the broker is started.
9191
Topics are created with given number of partitions and 1 replica.
92+
The syntax is the following:
9293

93-
The following example creates a topic named `test` with 3 partitions, and a second topic named `messages` with 2 partitions.
94+
[source, properties]
95+
----
96+
quarkus.kafka.devservices.topic-partitions.<topic-name>=<number-of-partitions>
97+
----
98+
99+
The following example creates a topic named `test` with three partitions, and a second topic named `messages` with two partitions.
94100

95101
[source, properties]
96102
----

docs/src/main/asciidoc/upx.adoc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,30 @@ Note that UPX compression:
2525
The UPX compression requires:
2626

2727
* the `upx` command to be available in the system `PATH`;
28+
* an explicitly defined `quarkus.native.compression.container-image`;
2829
* or to have built the native executable using an in-container build.
2930

31+
If `quarkus.native.compression.container-image` is not set explicitly, it will implicitly default to `quarkus.native.builder-image`.
32+
3033
If you have the `upx` command available on your path, Quarkus uses it.
31-
Otherwise, if you built the native image using an in-container build (using `quarkus.native.container-build=true`) and if the builder image provides the `upx` command, Quarkus compresses the executable from inside the container.
34+
Otherwise, if you built the native image using an in-container build (using `quarkus.native.container-build=true`) and if the compression image provides the `upx` command, Quarkus compresses the executable from inside the container.
35+
36+
If you want to force compression to take place in a container, you can set `quarkus.native.compression.container-build` to `true` (or `false` to explicitly not run compression in a container).
3237

3338
If you are not in one of these cases, the compression fails.
3439

40+
Setting `quarkus.native.compression.container-image` results in the compression to run in a container.
41+
If you want to set the variable, but not run the compression in a container, set `quakrus.native.compression.container-build` explicitly to `false`.
42+
43+
[IMPORTANT]
44+
.`WORKDIR` for the image used for compression
45+
====
46+
The executable to compress is mounted in directory `/project`.
47+
Since the container runs `upx` in the current working directory, the `WORKDIR` of the image used for compression must be `/project`.
48+
====
49+
50+
Compression can be explicitly en-/disabled by setting `quarkus.native.compression.enabled`.
51+
3552
[IMPORTANT]
3653
.upx is cross-platform.
3754
====

extensions/devservices/deployment/src/main/java/io/quarkus/devservices/deployment/ContainerLogForwarder.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@
1313
import org.testcontainers.containers.output.FrameConsumerResultCallback;
1414
import org.testcontainers.containers.output.OutputFrame;
1515

16+
import io.quarkus.deployment.dev.devservices.ContainerInfo;
1617
import io.quarkus.deployment.dev.devservices.DevServiceDescriptionBuildItem;
1718

1819
public class ContainerLogForwarder implements Closeable {
1920

2021
private final DevServiceDescriptionBuildItem devService;
2122
private final AtomicLong timestamp = new AtomicLong(0L);
2223
private final Logger logger;
23-
private final String shortId;
2424
private FrameConsumerResultCallback resultCallback;
2525
private final AtomicBoolean running = new AtomicBoolean(false);
2626

2727
public ContainerLogForwarder(DevServiceDescriptionBuildItem devService) {
2828
this.devService = devService;
2929
this.logger = Logger.getLogger(devService.getName());
30-
this.shortId = devService.getContainerInfo().getShortId();
3130
}
3231

3332
public DevServiceDescriptionBuildItem getDevService() {
@@ -39,22 +38,28 @@ public boolean isRunning() {
3938
}
4039

4140
public void start() {
42-
if (running.compareAndSet(false, true)) {
43-
this.resultCallback = new FrameConsumerResultCallback();
44-
this.resultCallback.addConsumer(STDOUT, frame -> {
45-
if (running.get())
46-
logger.infof("[%s] %s", shortId, updateTimestamp(frame));
47-
});
48-
this.resultCallback.addConsumer(STDERR, frame -> {
49-
if (running.get())
50-
logger.errorf("[%s] %s", shortId, updateTimestamp(frame));
51-
});
52-
DockerClientFactory.lazyClient().logContainerCmd(devService.getContainerInfo().id())
53-
.withFollowStream(true)
54-
.withStdErr(true)
55-
.withStdOut(true)
56-
.withSince(timestamp.intValue())
57-
.exec(resultCallback);
41+
ContainerInfo containerInfo = devService.getContainerInfo();
42+
43+
if (containerInfo != null) {
44+
String shortId = containerInfo.getShortId();
45+
46+
if (running.compareAndSet(false, true)) {
47+
this.resultCallback = new FrameConsumerResultCallback();
48+
this.resultCallback.addConsumer(STDOUT, frame -> {
49+
if (running.get())
50+
logger.infof("[%s] %s", shortId, updateTimestamp(frame));
51+
});
52+
this.resultCallback.addConsumer(STDERR, frame -> {
53+
if (running.get())
54+
logger.errorf("[%s] %s", shortId, updateTimestamp(frame));
55+
});
56+
DockerClientFactory.lazyClient().logContainerCmd(containerInfo.id())
57+
.withFollowStream(true)
58+
.withStdErr(true)
59+
.withStdOut(true)
60+
.withSince(timestamp.intValue())
61+
.exec(resultCallback);
62+
}
5863
}
5964
}
6065

extensions/devservices/deployment/src/main/java/io/quarkus/devservices/deployment/DevServicesProcessor.java

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.util.Arrays;
1414
import java.util.Collections;
1515
import java.util.Comparator;
16-
import java.util.HashMap;
1716
import java.util.HashSet;
1817
import java.util.List;
1918
import java.util.Map;
@@ -62,7 +61,7 @@ public class DevServicesProcessor {
6261

6362
static volatile ConsoleStateManager.ConsoleContext context;
6463
static volatile boolean logForwardEnabled = false;
65-
static Map<String, ContainerLogForwarder> containerLogForwarders = new HashMap<>();
64+
static Set<ContainerLogForwarder> containerLogForwarders = new HashSet<>();
6665

6766
@BuildStep
6867
public DevServicesNetworkIdBuildItem networkId(
@@ -110,15 +109,14 @@ public List<DevServiceDescriptionBuildItem> config(
110109
LaunchModeBuildItem launchModeBuildItem,
111110
Optional<DevServicesLauncherConfigResultBuildItem> devServicesLauncherConfig,
112111
List<DevServicesResultBuildItem> devServicesResults) {
112+
containerLogForwarders.clear();
113113
List<DevServiceDescriptionBuildItem> serviceDescriptions = buildServiceDescriptions(
114114
dockerStatusBuildItem, devServicesResults, devServicesLauncherConfig);
115115

116116
for (DevServiceDescriptionBuildItem devService : serviceDescriptions) {
117-
if (devService.hasContainerInfo()) {
118-
containerLogForwarders.compute(devService.getContainerInfo().id(),
119-
(id, forwarder) -> Objects.requireNonNullElseGet(forwarder,
120-
() -> new ContainerLogForwarder(devService)));
121-
}
117+
118+
containerLogForwarders.add(new ContainerLogForwarder(devService));
119+
122120
}
123121

124122
// Build commands if we are in local dev mode
@@ -131,11 +129,11 @@ public List<DevServiceDescriptionBuildItem> config(
131129

132130
// Dev UI Log stream
133131
for (DevServiceDescriptionBuildItem service : serviceDescriptions) {
134-
if (service.getContainerInfo() != null) {
135-
footerLogProducer.produce(new FooterLogBuildItem(service.getName(), () -> {
136-
return createLogPublisher(service.getContainerInfo().id());
137-
}));
138-
}
132+
133+
footerLogProducer.produce(new FooterLogBuildItem(service.getName(), () -> {
134+
ContainerInfo containerInfo = service.getContainerInfo();
135+
return createLogPublisher(containerInfo);
136+
}));
139137
}
140138

141139
if (context == null) {
@@ -162,22 +160,28 @@ public List<DevServiceDescriptionBuildItem> config(
162160
return serviceDescriptions;
163161
}
164162

165-
private Flow.Publisher<String> createLogPublisher(String containerId) {
163+
private Flow.Publisher<String> createLogPublisher(ContainerInfo containerInfo) {
164+
166165
try (FrameConsumerResultCallback resultCallback = new FrameConsumerResultCallback()) {
167166
SubmissionPublisher<String> publisher = new SubmissionPublisher<>();
168167
resultCallback.addConsumer(OutputFrame.OutputType.STDERR,
169168
frame -> publisher.submit(frame.getUtf8String()));
170169
resultCallback.addConsumer(OutputFrame.OutputType.STDOUT,
171170
frame -> publisher.submit(frame.getUtf8String()));
172-
LogContainerCmd logCmd = DockerClientFactory.lazyClient()
173-
.logContainerCmd(containerId)
174-
.withFollowStream(true)
175-
.withTailAll()
176-
.withStdErr(true)
177-
.withStdOut(true);
178-
logCmd.exec(resultCallback);
171+
if (containerInfo != null) {
172+
String containerId = containerInfo.id();
173+
LogContainerCmd logCmd = DockerClientFactory.lazyClient()
174+
.logContainerCmd(containerId)
175+
.withFollowStream(true)
176+
.withTailAll()
177+
.withStdErr(true)
178+
.withStdOut(true);
179+
logCmd.exec(resultCallback);
180+
}
179181

180182
return publisher;
183+
} catch (RuntimeException re) {
184+
throw re;
181185
} catch (Exception e) {
182186
throw new RuntimeException(e);
183187
}
@@ -259,14 +263,14 @@ private ContainerInfo.ContainerPort[] getExposedPorts(Container container) {
259263

260264
private synchronized void toggleLogForwarders() {
261265
if (logForwardEnabled) {
262-
for (ContainerLogForwarder logForwarder : containerLogForwarders.values()) {
266+
for (ContainerLogForwarder logForwarder : containerLogForwarders) {
263267
if (logForwarder.isRunning()) {
264268
logForwarder.close();
265269
}
266270
}
267271
logForwardEnabled = false;
268272
} else {
269-
for (ContainerLogForwarder logForwarder : containerLogForwarders.values()) {
273+
for (ContainerLogForwarder logForwarder : containerLogForwarders) {
270274
logForwarder.start();
271275
}
272276
logForwardEnabled = true;

extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/blocking/BlockingServerInterceptor.java

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,62 @@
3737
public class BlockingServerInterceptor implements ServerInterceptor, Function<String, Boolean>, Prioritized {
3838
private static final Logger log = Logger.getLogger(BlockingServerInterceptor.class);
3939

40+
// Reserved keywords, based on the jls, see:
41+
// https://github.com/grpc/grpc-java/blob/master/compiler/src/java_plugin/cpp/java_generator.cpp#L90
42+
private static final Set<String> GRPC_JAVA_RESERVED_KEYWORDS = Set.of(
43+
"abstract",
44+
"assert",
45+
"boolean",
46+
"break",
47+
"byte",
48+
"case",
49+
"catch",
50+
"char",
51+
"class",
52+
"const",
53+
"continue",
54+
"default",
55+
"do",
56+
"double",
57+
"else",
58+
"enum",
59+
"extends",
60+
"final",
61+
"finally",
62+
"float",
63+
"for",
64+
"goto",
65+
"if",
66+
"implements",
67+
"import",
68+
"instanceof",
69+
"int",
70+
"interface",
71+
"long",
72+
"native",
73+
"new",
74+
"package",
75+
"private",
76+
"protected",
77+
"public",
78+
"return",
79+
"short",
80+
"static",
81+
"strictfp",
82+
"super",
83+
"switch",
84+
"synchronized",
85+
"this",
86+
"throw",
87+
"throws",
88+
"transient",
89+
"try",
90+
"void",
91+
"volatile",
92+
"while",
93+
"true",
94+
"false");
95+
4096
private final Vertx vertx;
4197
private final Set<String> blockingMethods;
4298
private final Set<String> virtualMethods;
@@ -68,12 +124,22 @@ public BlockingServerInterceptor(Vertx vertx, List<String> blockingMethods, List
68124
@Override
69125
public Boolean apply(String name) {
70126
String methodName = name.substring(name.lastIndexOf("/") + 1);
71-
return blockingMethods.contains(methodName.toLowerCase());
127+
return blockingMethods.contains(toLowerCaseBeanSpec(methodName));
72128
}
73129

74130
public Boolean applyVirtual(String name) {
75131
String methodName = name.substring(name.lastIndexOf("/") + 1);
76-
return virtualMethods.contains(methodName.toLowerCase());
132+
return virtualMethods.contains(toLowerCaseBeanSpec(methodName));
133+
}
134+
135+
private String toLowerCaseBeanSpec(String name) {
136+
137+
// Methods cannot always be lowercased for comparison.
138+
// - gRPC allows using method names which normally would not work in java because of reserved keywords.
139+
// - Underscores are removed.
140+
141+
String lowerBeanSpec = name.toLowerCase().replace("_", "");
142+
return GRPC_JAVA_RESERVED_KEYWORDS.contains(lowerBeanSpec) ? lowerBeanSpec + "_" : lowerBeanSpec;
77143
}
78144

79145
@Override

0 commit comments

Comments
 (0)