Skip to content

Commit

Permalink
Merge pull request #12982 from gsmet/1.9.1-backports-1
Browse files Browse the repository at this point in the history
1.9.1 backports 1
  • Loading branch information
gsmet authored Oct 27, 2020
2 parents dc4f95f + eb113e1 commit a13cf9c
Show file tree
Hide file tree
Showing 115 changed files with 1,175 additions and 329 deletions.
10 changes: 5 additions & 5 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
<smallrye-graphql.version>1.0.12</smallrye-graphql.version>
<smallrye-opentracing.version>1.3.4</smallrye-opentracing.version>
<smallrye-fault-tolerance.version>4.3.1</smallrye-fault-tolerance.version>
<smallrye-jwt.version>2.3.0</smallrye-jwt.version>
<smallrye-jwt.version>2.3.1</smallrye-jwt.version>
<smallrye-context-propagation.version>1.0.13</smallrye-context-propagation.version>
<smallrye-reactive-streams-operators.version>1.0.13</smallrye-reactive-streams-operators.version>
<smallrye-converter-api.version>1.1.0</smallrye-converter-api.version>
<smallrye-converter-api.version>1.2.2</smallrye-converter-api.version>
<smallrye-reactive-messaging.version>2.4.0</smallrye-reactive-messaging.version>
<swagger-ui.version>3.35.1</swagger-ui.version>
<jakarta.activation.version>1.2.1</jakarta.activation.version>
Expand Down Expand Up @@ -105,7 +105,7 @@
<wildfly-elytron.version>1.13.0.Final</wildfly-elytron.version>
<jboss-modules.version>1.8.7.Final</jboss-modules.version>
<jboss-threads.version>3.1.1.Final</jboss-threads.version>
<vertx.version>3.9.3</vertx.version>
<vertx.version>3.9.4</vertx.version>
<httpclient.version>4.5.13</httpclient.version>
<httpcore.version>4.4.13</httpcore.version>
<httpasync.version>4.1.4</httpasync.version>
Expand All @@ -131,8 +131,8 @@
<reactive-streams.version>1.0.3</reactive-streams.version>
<jboss-logging.version>3.4.1.Final</jboss-logging.version>
<mutiny.version>0.9.0</mutiny.version>
<axle-client.version>1.2.1</axle-client.version>
<mutiny-client.version>1.2.1</mutiny-client.version>
<axle-client.version>1.2.2</axle-client.version>
<mutiny-client.version>1.2.2</mutiny-client.version>
<kafka2.version>2.5.0</kafka2.version>
<zookeeper.version>3.5.7</zookeeper.version>
<!-- Scala is used by Kafka so we need to choose a compatible version -->
Expand Down
2 changes: 1 addition & 1 deletion bom/test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<description>Dependency management for integration tests. Importable by third party extension developers.</description>

<properties>
<debezium.version>1.2.5.Final</debezium.version>
<debezium.version>1.3.0.Final</debezium.version>
<testcontainers.version>1.14.3</testcontainers.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.quarkus.deployment;

import java.util.Arrays;
import java.util.List;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
import io.quarkus.deployment.pkg.steps.NativeBuild;

public class ImageIOProcessor {

@BuildStep(onlyIf = NativeBuild.class)
List<RuntimeInitializedClassBuildItem> runtimeInitImageIOClasses() {
// The following classes hold instances of java.awt.color.ICC_ColorSpace that are not allowed in the image
// heap as this class should be initialized at image runtime
// (See https://github.com/quarkusio/quarkus/issues/12535)
return Arrays.asList(
new RuntimeInitializedClassBuildItem("javax.imageio.ImageTypeSpecifier"),
new RuntimeInitializedClassBuildItem("com.sun.imageio.plugins.jpeg.JPEG$JCS"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.BindException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand Down Expand Up @@ -108,35 +109,40 @@ public void accept(Integer integer) {
runner = start.runMainClass(context.getArgs());
firstStartCompleted = true;
} catch (Throwable t) {
deploymentProblem = t;
if (!augmentDone) {
log.error("Failed to start quarkus", t);
Throwable rootCause = t;
while (rootCause.getCause() != null) {
rootCause = rootCause.getCause();
}
if (!context.isAbortOnFailedStart()) {
//we need to set this here, while we still have the correct TCCL
//this is so the config is still valid, and we can read HTTP config from application.properties
log.info("Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure");
if (RuntimeUpdatesProcessor.INSTANCE != null) {
Thread.currentThread().setContextClassLoader(curatedApplication.getBaseRuntimeClassLoader());

try {
if (!InitialConfigurator.DELAYED_HANDLER.isActivated()) {
Class<?> cl = Thread.currentThread().getContextClassLoader()
.loadClass(LoggingSetupRecorder.class.getName());
cl.getMethod("handleFailedStart").invoke(null);
if (!(rootCause instanceof BindException)) {
deploymentProblem = t;
if (!augmentDone) {
log.error("Failed to start quarkus", t);
}
if (!context.isAbortOnFailedStart()) {
//we need to set this here, while we still have the correct TCCL
//this is so the config is still valid, and we can read HTTP config from application.properties
log.info(
"Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure");
if (RuntimeUpdatesProcessor.INSTANCE != null) {
Thread.currentThread().setContextClassLoader(curatedApplication.getBaseRuntimeClassLoader());
try {
if (!InitialConfigurator.DELAYED_HANDLER.isActivated()) {
Class<?> cl = Thread.currentThread().getContextClassLoader()
.loadClass(LoggingSetupRecorder.class.getName());
cl.getMethod("handleFailedStart").invoke(null);
}
RuntimeUpdatesProcessor.INSTANCE.startupFailed();
} catch (Exception e) {
close();
log.error("Failed to recover after failed start", e);
//this is the end of the road, we just exit
//generally we only hit this if something is already listening on the HTTP port
//or the system config is so broken we can't start HTTP
System.exit(1);
}
RuntimeUpdatesProcessor.INSTANCE.startupFailed();
} catch (Exception e) {
close();
log.error("Failed to recover after failed start", e);
//this is the end of the road, we just exit
//generally we only hit this if something is already listening on the HTTP port
//or the system config is so broken we can't start HTTP
System.exit(1);
}
}
}

}
} finally {
Thread.currentThread().setContextClassLoader(old);
Expand Down Expand Up @@ -176,9 +182,15 @@ public synchronized void restartApp(Set<String> changedResources) {
firstStartCompleted = true;
} catch (Throwable t) {
deploymentProblem = t;
log.error("Failed to start quarkus", t);
Thread.currentThread().setContextClassLoader(curatedApplication.getAugmentClassLoader());
LoggingSetupRecorder.handleFailedStart();
Throwable rootCause = t;
while (rootCause.getCause() != null) {
rootCause = rootCause.getCause();
}
if (!(rootCause instanceof BindException)) {
log.error("Failed to start quarkus", t);
Thread.currentThread().setContextClassLoader(curatedApplication.getAugmentClassLoader());
LoggingSetupRecorder.handleFailedStart();
}
}
} finally {
restarting = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,11 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem,
ObjectOutputStream obj = new ObjectOutputStream(out);
List<String> paths = new ArrayList<>();
for (AppDependency i : curateOutcomeBuildItem.getEffectiveModel().getFullDeploymentDeps()) {
paths.addAll(relativePaths.get(i.getArtifact().getKey()));
final List<String> list = relativePaths.get(i.getArtifact().getKey());
// some of the dependencies may have been filtered out
if (list != null) {
paths.addAll(list);
}
}
obj.writeObject(paths);
obj.close();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.runtime;

import java.net.BindException;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
Expand All @@ -14,6 +15,7 @@
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.CDI;

import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
import org.graalvm.nativeimage.ImageInfo;
import org.jboss.logging.Logger;
import org.wildfly.common.lock.Locks;
Expand Down Expand Up @@ -139,8 +141,28 @@ public static void run(Application application, Class<? extends QuarkusApplicati
}
} catch (Exception e) {
if (exitCodeHandler == null) {
Logger.getLogger(Application.class).errorv(e, "Failed to start application (with profile {0})",
ProfileManager.getActiveProfile());
Throwable rootCause = e;
while (rootCause.getCause() != null) {
rootCause = rootCause.getCause();
}
Logger applicationLogger = Logger.getLogger(Application.class);
if (rootCause instanceof BindException) {
int port = ConfigProviderResolver.instance().getConfig()
.getOptionalValue("quarkus.http.port", Integer.class).orElse(8080);
applicationLogger.error("Port " + port + " seems to be in use by another process. " +
"Quarkus may already be running or the port is used by another application.");
if (System.getProperty("os.name").startsWith("Windows")) {
applicationLogger.info("Use 'netstat -a -b -n -o' to identify the process occupying the port.");
applicationLogger.info("You can try to kill it with 'taskkill /PID <pid>' or via the Task Manager.");
} else {
applicationLogger
.info("Use 'netstat -anop | grep " + port + "' to identify the process occupying the port.");
applicationLogger.info("You can try to kill it with 'kill -9 <pid>'.");
}
} else {
applicationLogger.errorv(rootCause, "Failed to start application (with profile {0})",
ProfileManager.getActiveProfile());
}
}
stateLock.lock();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,25 +296,29 @@ private void collectDependencies(ResolvedConfiguration configuration,

private void addDevModePaths(final DependencyImpl dep, ResolvedArtifact a, Project project) {
final JavaPluginConvention javaConvention = project.getConvention().findPlugin(JavaPluginConvention.class);
if (javaConvention != null) {
SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
final File classesDir = new File(QuarkusGradleUtils.getClassesDir(mainSourceSet, project.getBuildDir(), false));
if (classesDir.exists()) {
dep.addPath(classesDir);
}
for (File resourcesDir : mainSourceSet.getResources().getSourceDirectories()) {
if (resourcesDir.exists()) {
dep.addPath(resourcesDir);
if (javaConvention == null) {
dep.addPath(a.getFile());
} else {
SourceSet mainSourceSet = javaConvention.getSourceSets().findByName(SourceSet.MAIN_SOURCE_SET_NAME);
if (mainSourceSet != null) {
final File classesDir = new File(QuarkusGradleUtils.getClassesDir(mainSourceSet, project.getBuildDir(), false));
if (classesDir.exists()) {
dep.addPath(classesDir);
}
}
for (File outputDir : project.getTasks().findByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME)
.getOutputs().getFiles()) {
if (outputDir.exists()) {
dep.addPath(outputDir);
for (File resourcesDir : mainSourceSet.getResources().getSourceDirectories()) {
if (resourcesDir.exists()) {
dep.addPath(resourcesDir);
}
}
for (File outputDir : project.getTasks().findByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME)
.getOutputs().getFiles()) {
if (outputDir.exists()) {
dep.addPath(outputDir);
}
}
} else {
dep.addPath(a.getFile());
}
} else {
dep.addPath(a.getFile());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,10 @@ private void addLocalProject(Project project, DevModeContext context, Set<AppArt
}

SourceSetContainer sourceSets = javaConvention.getSourceSets();
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
SourceSet mainSourceSet = sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME);
if (mainSourceSet == null) {
return;
}
Set<String> sourcePaths = new HashSet<>();
Set<String> sourceParentPaths = new HashSet<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static QuarkusPlatformDescriptor resolvePlatformDescriptor(final String bomGroup
DefaultArtifactVersion pluginVersion = new DefaultArtifactVersion(baseVersion);
int majorVer = pluginVersion.getMajorVersion();
int minorVer = pluginVersion.getMinorVersion();
version = "[" + majorVer + "." + minorVer + "-alpha, " + majorVer + "." + (minorVer + 1) + ")";
version = "[" + majorVer + "." + minorVer + "-alpha, " + majorVer + "." + (minorVer + 1) + "-alpha)";
}
}

Expand Down
36 changes: 34 additions & 2 deletions devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.jar.Manifest;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;

import org.apache.maven.artifact.Artifact;
Expand Down Expand Up @@ -75,6 +76,7 @@
import org.eclipse.aether.util.artifact.JavaScopes;

import io.quarkus.bootstrap.model.AppArtifactKey;
import io.quarkus.bootstrap.model.AppModel;
import io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions;
import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject;
import io.quarkus.bootstrap.resolver.maven.workspace.LocalWorkspace;
Expand All @@ -93,6 +95,7 @@
*/
@Mojo(name = "dev", defaultPhase = LifecyclePhase.PREPARE_PACKAGE, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class DevMojo extends AbstractMojo {
private static final String EXT_PROPERTIES_PATH = "META-INF/quarkus-extension.properties";

/**
* running any one of these phases means the compile phase will have been run, if these have
Expand Down Expand Up @@ -712,11 +715,35 @@ void prepare(final boolean triggerCompile) throws Exception {

//in most cases these are not used, however they need to be present for some
//parent-first cases such as logging
//first we go through and get all the parent first artifacts
Set<AppArtifactKey> parentFirstArtifacts = new HashSet<>();
for (Artifact appDep : project.getArtifacts()) {
if (appDep.getArtifactHandler().getExtension().equals("jar") && appDep.getFile().isFile()) {
try (ZipFile file = new ZipFile(appDep.getFile())) {
ZipEntry entry = file.getEntry(EXT_PROPERTIES_PATH);
if (entry != null) {
Properties p = new Properties();
try (InputStream inputStream = file.getInputStream(entry)) {
p.load(inputStream);
String parentFirst = p.getProperty(AppModel.PARENT_FIRST_ARTIFACTS);
if (parentFirst != null) {
String[] artifacts = parentFirst.split(",");
for (String artifact : artifacts) {
parentFirstArtifacts.add(new AppArtifactKey(artifact.split(":")));
}
}
}

}
}
}
}
for (Artifact appDep : project.getArtifacts()) {
// only add the artifact if it's present in the dev mode context
// we need this to avoid having jars on the classpath multiple times
if (!devModeContext.getLocalArtifacts().contains(new AppArtifactKey(appDep.getGroupId(), appDep.getArtifactId(),
appDep.getClassifier(), appDep.getArtifactHandler().getExtension()))) {
AppArtifactKey key = new AppArtifactKey(appDep.getGroupId(), appDep.getArtifactId(),
appDep.getClassifier(), appDep.getArtifactHandler().getExtension());
if (!devModeContext.getLocalArtifacts().contains(key) && parentFirstArtifacts.contains(key)) {
addToClassPaths(classPathManifest, appDep.getFile());
}
}
Expand Down Expand Up @@ -898,6 +925,11 @@ public void run() throws Exception {
@Override
public void run() {
process.destroy();
try {
process.waitFor();
} catch (InterruptedException ignored) {
getLog().warn("Unable to properly wait for dev-mode end", ignored);
}
}
}, "Development Mode Shutdown Hook"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ language:
guide-native: https://quarkus.io/guides/gradle-tooling#building-a-native-executable
cmd:
dev: gradle quarkusDev
package: gradle quarkusBuild
package-uberjar: gradle quarkusBuild --uber-jar
package: gradle build
package-uberjar: gradle build -Dquarkus.package.type=uber-jar
package-native: gradle build -Dquarkus.package.type=native
package-native-container: gradle build -Dquarkus.package.type=native -Dquarkus.native.container-build=true
build-ci: gradle build
Expand Down
Loading

0 comments on commit a13cf9c

Please sign in to comment.