Skip to content

Commit

Permalink
Merge pull request #19204 from gsmet/2.1.1-backports-1
Browse files Browse the repository at this point in the history
2.1.1 backports 1
  • Loading branch information
gsmet authored Aug 4, 2021
2 parents 525e073 + 57852ea commit 7753100
Show file tree
Hide file tree
Showing 194 changed files with 5,192 additions and 828 deletions.
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<hibernate-orm.version>5.5.4.Final</hibernate-orm.version>
<hibernate-reactive.version>1.0.0.CR8</hibernate-reactive.version>
<hibernate-validator.version>6.2.0.Final</hibernate-validator.version>
<hibernate-search.version>6.0.5.Final</hibernate-search.version>
<hibernate-search.version>6.0.6.Final</hibernate-search.version>
<narayana.version>5.12.0.Final</narayana.version>
<jboss-transaction-api_1.2_spec.version>1.1.1.Final</jboss-transaction-api_1.2_spec.version>
<agroal.version>1.12</agroal.version>
Expand Down Expand Up @@ -161,7 +161,7 @@
<liquibase.version>4.3.5</liquibase.version>
<snakeyaml.version>1.29</snakeyaml.version>
<osgi.version>6.0.0</osgi.version>
<neo4j-java-driver.version>4.3.3</neo4j-java-driver.version>
<neo4j-java-driver.version>4.3.4</neo4j-java-driver.version>
<mongo-client.version>4.3.0</mongo-client.version>
<mongo-crypt.version>1.2.0</mongo-crypt.version>
<artemis.version>2.17.0</artemis.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ public interface Capability {

String TIKA = QUARKUS_PREFIX + "tika";

String MONGODB_CLIENT = QUARKUS_PREFIX + "mongodb-client";
String MONGODB_PANACHE = QUARKUS_PREFIX + "mongodb.panache";
String MONGODB_PANACHE_KOTLIN = MONGODB_PANACHE + ".kotlin";

String ELASTICSEARCH_REST_HIGH_LEVEL_CLIENT = QUARKUS_PREFIX + "elasticsearch-rest-high-level-client";

String FLYWAY = QUARKUS_PREFIX + "flyway";
String LIQUIBASE = QUARKUS_PREFIX + "liquibase";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ private ReflectiveClassBuildItem(boolean constructors, boolean methods, boolean
this.finalFieldsWritable = finalFieldsWritable;
this.weak = weak;
this.serialization = serialization;
if (weak) {
if (serialization) {
throw new RuntimeException("Weak reflection not supported with serialization");
}
if (finalFieldsWritable) {
throw new RuntimeException("Weak reflection not supported with finalFieldsWritable");
}
}
}

public ReflectiveClassBuildItem(boolean methods, boolean fields, String... className) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
public class AeshConsole extends QuarkusConsole {

private final Connection connection;
private final boolean inputSupport;
private Size size;
private Attributes attributes;

Expand Down Expand Up @@ -57,8 +56,7 @@ protected Boolean initialValue() {
private final ReadWriteLock positionLock = new ReentrantReadWriteLock();
private volatile boolean closed;

public AeshConsole(Connection connection, boolean inputSupport) {
this.inputSupport = inputSupport;
public AeshConsole(Connection connection) {
INSTANCE = this;
this.connection = connection;
connection.openNonBlocking();
Expand Down Expand Up @@ -111,9 +109,6 @@ public StatusLine registerStatusLine(int priority) {

@Override
public void setPromptMessage(String promptMessage) {
if (!inputSupport) {
return;
}
setMessage(0, promptMessage);
}

Expand Down Expand Up @@ -197,31 +192,26 @@ public void run() {
break;
}
});
if (inputSupport) {
// Keyboard handling
conn.setStdinHandler(keys -> {
var handler = inputHandler;
if (handler != null) {
handler.accept(keys);
}
if (doingReadline) {
for (var k : keys) {
if (k == '\n') {
doingReadline = false;
connection.enterRawMode();
}
// Keyboard handling
conn.setStdinHandler(keys -> {
var handler = inputHandler;
if (handler != null) {
handler.accept(keys);
}
if (doingReadline) {
for (var k : keys) {
if (k == '\n') {
doingReadline = false;
connection.enterRawMode();
}
}
});
}
}
});

conn.setCloseHandler(close -> end(conn));
conn.setSizeHandler(size -> setup(conn));

if (inputSupport) {
attributes = conn.enterRawMode();
} else {
attributes = conn.getAttributes();
}
attributes = conn.enterRawMode();

StringBuilder sb = new StringBuilder();
printStatusAndPrompt(sb);
Expand Down Expand Up @@ -393,9 +383,6 @@ public void write(byte[] buf, int off, int len) {

@Override
public void doReadLine() {
if (!inputSupport) {
return;
}
setPromptMessage("");
connection.setAttributes(attributes);
doingReadline = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,22 @@ public static synchronized void installConsole(TestConfig config, ConsoleConfig
//note that we never enable input for tests
//surefire communicates of stdin, so this can mess with it
boolean inputSupport = !test && !config.disableConsoleInput.orElse(consoleConfig.disableInput);
if (!inputSupport) {
QuarkusConsole.INSTANCE = new BasicConsole(colorEnabled,
inputSupport, consumer);
return;
}
try {
new TerminalConnection(new Consumer<Connection>() {
@Override
public void accept(Connection connection) {
if (connection.supportsAnsi() && !config.basicConsole.orElse(consoleConfig.basic)) {
QuarkusConsole.INSTANCE = new AeshConsole(connection,
inputSupport);
QuarkusConsole.INSTANCE = new AeshConsole(connection);
} else {
LinkedBlockingDeque<Integer> queue = new LinkedBlockingDeque<>();
connection.openNonBlocking();
if (inputSupport) {
connection.openNonBlocking();
}
connection.setStdinHandler(new Consumer<int[]>() {
@Override
public void accept(int[] ints) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ public static void init(QuarkusConsole console, DevModeType devModeType) {
return;
}
initialized = true;
console.setInputHandler(INSTANCE.consumer);
INSTANCE.installBuiltins(devModeType);
if (console.isInputSupported()) {
console.setInputHandler(INSTANCE.consumer);
INSTANCE.installBuiltins(devModeType);
}
}

void installBuiltins(DevModeType devModeType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ public void runTests() {
long start = System.currentTimeMillis();
ClassLoader old = Thread.currentThread().getContextClassLoader();
try (QuarkusClassLoader tcl = testApplication.createDeploymentClassLoader()) {
synchronized (this) {
if (aborted) {
return;
}
testsRunning = true;
}
Thread.currentThread().setContextClassLoader(tcl);
Consumer currentTestAppConsumer = (Consumer) tcl.loadClass(CurrentTestApplication.class.getName()).newInstance();
currentTestAppConsumer.accept(testApplication);
Expand Down Expand Up @@ -408,9 +414,18 @@ public void reportingEntryPublished(TestIdentifier testIdentifier, ReportEntry e
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
TracingHandler.setTracingHandler(null);
QuarkusConsole.INSTANCE.setOutputFilter(null);
Thread.currentThread().setContextClassLoader(old);
try {
TracingHandler.setTracingHandler(null);
QuarkusConsole.INSTANCE.setOutputFilter(null);
Thread.currentThread().setContextClassLoader(old);
} finally {
synchronized (this) {
testsRunning = false;
if (aborted) {
notifyAll();
}
}
}
}
}

Expand All @@ -424,6 +439,13 @@ public synchronized void abort() {
}
aborted = true;
notifyAll();
while (testsRunning) {
try {
wait();
} catch (InterruptedException e) {
//ignore
}
}
}

public synchronized void pause() {
Expand Down Expand Up @@ -662,6 +684,9 @@ public List<String> captureOutput() {
public boolean test(String logRecord) {
Thread thread = Thread.currentThread();
ClassLoader cl = thread.getContextClassLoader();
if (cl == null) {
return true;
}
while (cl.getParent() != null) {
if (cl == testApplication.getAugmentClassLoader()
|| cl == testApplication.getBaseRuntimeClassLoader()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class TestConsoleHandler implements TestListener {

private static final Logger log = Logger.getLogger("io.quarkus.test");

public static final ConsoleCommand TOGGLE_TEST_OUTPUT = new ConsoleCommand('o', "Toggle test output",
public static final ConsoleCommand TOGGLE_TEST_OUTPUT = new ConsoleCommand('o', "Toggle test output", "Toggle test output",
1000,
new ConsoleCommand.HelpState(TestSupport.instance().get()::isDisplayTestOutput),
() -> TestSupport.instance().get().toggleTestOutput());

Expand Down Expand Up @@ -87,15 +88,21 @@ private void setupPausedConsole() {
consoleContext.reset(new ConsoleCommand('r', "Resume testing", "to resume testing", 500, null, new Runnable() {
@Override
public void run() {
testsStatusOutput.setMessage(BLUE + "Starting tests" + RESET);
if (lastResults == null) {
testsStatusOutput.setMessage(BLUE + "Starting tests" + RESET);
}
TestSupport.instance().get().start();
}
}));
addTestOutput();
}

private void setupFirstRunConsole() {
testsStatusOutput.setMessage(BLUE + "Running tests for the first time" + RESET);
if (lastResults != null) {
resultsOutput.setMessage(lastResults);
} else {
testsStatusOutput.setMessage(BLUE + "Running tests for the first time" + RESET);
}
consoleContext.reset();
addTestOutput();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void run() {
}
}
if (run) {
runTests(current, true, true);
runTests(current, false, true);
}
}
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ public void init() {
cl.addCloseTask(new Runnable() {
@Override
public void run() {
testCuratedApplication.close();
try {
stop();
} finally {
testCuratedApplication.close();
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ void startTesting(TestConfig config, LiveReloadBuildItem liveReloadBuildItem,
testSupport.stop();
}
}

QuarkusClassLoader cl = (QuarkusClassLoader) Thread.currentThread().getContextClassLoader();
((QuarkusClassLoader) cl.parent()).addCloseTask(new Runnable() {
@Override
public void run() {
testSupport.stop();
}
});
}

@BuildStep(onlyIf = IsTest.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ public void accept(LogRecord logRecord, Consumer<LogRecord> logRecordConsumer) {
}
}
};
((QuarkusClassLoader) getClass().getClassLoader()).addCloseTask(new Runnable() {
@Override
public void run() {
CurrentAppExceptionHighlighter.THROWABLE_FORMATTER = null;
}
});
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Stream;

import org.apache.commons.lang3.RandomStringUtils;
import org.jboss.logging.Logger;

import io.quarkus.deployment.pkg.NativeConfig;
Expand All @@ -24,6 +26,7 @@ public abstract class NativeImageBuildContainerRunner extends NativeImageBuildRu
protected final NativeConfig.ContainerRuntime containerRuntime;
private final String[] baseContainerRuntimeArgs;
protected final String outputPath;
private final String containerName;

public NativeImageBuildContainerRunner(NativeConfig nativeConfig, Path outputDir) {
this.nativeConfig = nativeConfig;
Expand All @@ -33,7 +36,7 @@ public NativeImageBuildContainerRunner(NativeConfig nativeConfig, Path outputDir
this.baseContainerRuntimeArgs = new String[] { "--env", "LANG=C", "--rm" };

outputPath = outputDir == null ? null : outputDir.toAbsolutePath().toString();

containerName = "build-native-" + RandomStringUtils.random(5, true, false);
}

@Override
Expand Down Expand Up @@ -67,7 +70,12 @@ protected String[] getGraalVMVersionCommand(List<String> args) {

@Override
protected String[] getBuildCommand(List<String> args) {
return buildCommand("run", getContainerRuntimeBuildArgs(), args);
List<String> containerRuntimeBuildArgs = getContainerRuntimeBuildArgs();
List<String> effectiveContainerRuntimeBuildArgs = new ArrayList<>(containerRuntimeBuildArgs.size() + 2);
effectiveContainerRuntimeBuildArgs.addAll(containerRuntimeBuildArgs);
effectiveContainerRuntimeBuildArgs.add("--name");
effectiveContainerRuntimeBuildArgs.add(containerName);
return buildCommand("run", effectiveContainerRuntimeBuildArgs, args);
}

@Override
Expand All @@ -81,6 +89,24 @@ protected void objcopy(String... args) {
runCommand(command, null, null);
}

@Override
public void addShutdownHook(Process process) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (process.isAlive()) {
try {
Process removeProcess = new ProcessBuilder(
List.of(containerRuntime.getExecutableName(), "rm", "-f", containerName))
.redirectOutput(ProcessBuilder.Redirect.DISCARD)
.redirectError(ProcessBuilder.Redirect.DISCARD)
.start();
removeProcess.waitFor(2, TimeUnit.SECONDS);
} catch (IOException | InterruptedException e) {
log.debug("Unable to stop running container", e);
}
}
}));
}

protected List<String> getContainerRuntimeBuildArgs() {
List<String> containerRuntimeArgs = new ArrayList<>();
nativeConfig.containerRuntimeOptions.ifPresent(containerRuntimeArgs::addAll);
Expand Down
Loading

0 comments on commit 7753100

Please sign in to comment.