Reformat the code using mvn clean process-sources

This commit is contained in:
Peter Palaga
2020-07-29 11:56:23 +02:00
parent 213edf6712
commit 7768ef39bf
66 changed files with 1364 additions and 1763 deletions

View File

@@ -19,7 +19,8 @@ package org.jboss.fuse.mvnd.client;
import java.nio.Buffer;
/**
* File origin: https://github.com/gradle/gradle/blob/v5.6.2/subprojects/base-services/src/main/java/org/gradle/internal/io/BufferCaster.java
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/base-services/src/main/java/org/gradle/internal/io/BufferCaster.java
*/
public class BufferCaster {
/**

View File

@@ -62,7 +62,8 @@ public class ClientLayout extends Layout {
}
/**
* @return absolute normalized path to local Maven repository or {@code null} if the server is supposed to use the default
* @return absolute normalized path to local Maven repository or {@code null} if the server is supposed to use the
* default
*/
public Path getLocalMavenRepository() {
return localMavenRepository;

View File

@@ -30,7 +30,6 @@ import java.util.Map.Entry;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.function.Consumer;
import org.jboss.fuse.mvnd.client.Message.BuildException;
import org.jline.terminal.Size;
import org.jline.terminal.Terminal;
@@ -62,6 +61,7 @@ public interface ClientOutput extends AutoCloseable, Consumer<String> {
private static final Logger LOGGER = LoggerFactory.getLogger(TerminalOutput.class);
private final TerminalUpdater updater;
private final BlockingQueue<Map.Entry<String, String>> queue;
public TerminalOutput(Path logFile) throws IOException {
this.queue = new LinkedBlockingDeque<>();
this.updater = new TerminalUpdater(queue, logFile);

View File

@@ -17,12 +17,12 @@ package org.jboss.fuse.mvnd.client;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* File origin: https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/client/DaemonClientConnection.java
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/client/DaemonClientConnection.java
*/
public class DaemonClientConnection {
@@ -34,7 +34,8 @@ public class DaemonClientConnection {
private boolean hasReceived;
private final Lock dispatchLock = new ReentrantLock();
public DaemonClientConnection(DaemonConnection<Message> connection, DaemonInfo daemon, StaleAddressDetector staleAddressDetector) {
public DaemonClientConnection(DaemonConnection<Message> connection, DaemonInfo daemon,
StaleAddressDetector staleAddressDetector) {
this.connection = connection;
this.daemon = daemon;
this.staleAddressDetector = staleAddressDetector;

View File

@@ -15,7 +15,6 @@
*/
package org.jboss.fuse.mvnd.client;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
@@ -23,7 +22,8 @@ import java.util.Objects;
import java.util.function.Supplier;
/**
* File origin: https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/context/DaemonCompatibilitySpec.java
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/context/DaemonCompatibilitySpec.java
*/
public class DaemonCompatibilitySpec {
@@ -32,7 +32,7 @@ public class DaemonCompatibilitySpec {
/**
* @param javaHome make sure the Path is a result of {@link Path#toRealPath(java.nio.file.LinkOption...)}
* @param options the options
* @param options the options
*/
public DaemonCompatibilitySpec(Path javaHome, List<String> options) {
this.javaHome = Objects.requireNonNull(javaHome, "javaHome");
@@ -46,7 +46,9 @@ public class DaemonCompatibilitySpec {
if (!daemonOptsMatch(daemon)) {
return new Result(false, () -> "At least one daemon option is different.\n" + diff(daemon));
}
return new Result(true, () -> {throw new RuntimeException("No reason if DaemonCompatibilityResult.compatible == true");});
return new Result(true, () -> {
throw new RuntimeException("No reason if DaemonCompatibilityResult.compatible == true");
});
}
private String diff(DaemonInfo context) {
@@ -59,7 +61,7 @@ public class DaemonCompatibilitySpec {
private boolean daemonOptsMatch(DaemonInfo daemon) {
return daemon.getOptions().containsAll(options)
&& daemon.getOptions().size() == options.size();
&& daemon.getOptions().size() == options.size();
}
private boolean javaHomeMatches(DaemonInfo daemon) {

View File

@@ -32,12 +32,12 @@ import java.nio.channels.SocketChannel;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* File origin: https://github.com/gradle/gradle/blob/v5.6.2/subprojects/messaging/src/main/java/org/gradle/internal/remote/internal/inet/SocketConnection.java
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/messaging/src/main/java/org/gradle/internal/remote/internal/inet/SocketConnection.java
*
*/
public class DaemonConnection<T> implements AutoCloseable {
@@ -81,7 +81,8 @@ public class DaemonConnection<T> implements AutoCloseable {
}
return null;
} catch (ClassNotFoundException | IOException e) {
throw new DaemonException.RecoverableMessageIOException(String.format("Could not read message from '%s'.", remoteAddress), e);
throw new DaemonException.RecoverableMessageIOException(
String.format("Could not read message from '%s'.", remoteAddress), e);
} catch (Throwable e) {
throw new DaemonException.MessageIOException(String.format("Could not read message from '%s'.", remoteAddress), e);
}
@@ -113,9 +114,11 @@ public class DaemonConnection<T> implements AutoCloseable {
serializer.write(outstr, message);
outstr.flush();
} catch (ClassNotFoundException | IOException e) {
throw new DaemonException.RecoverableMessageIOException(String.format("Could not write message %s to '%s'.", message, remoteAddress), e);
throw new DaemonException.RecoverableMessageIOException(
String.format("Could not write message %s to '%s'.", message, remoteAddress), e);
} catch (Throwable e) {
throw new DaemonException.MessageIOException(String.format("Could not write message %s to '%s'.", message, remoteAddress), e);
throw new DaemonException.MessageIOException(
String.format("Could not write message %s to '%s'.", message, remoteAddress), e);
}
}

View File

@@ -30,7 +30,6 @@ import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.jboss.fuse.mvnd.client.DaemonCompatibilitySpec.Result;
import org.jboss.fuse.mvnd.jpm.Process;
import org.jboss.fuse.mvnd.jpm.ScriptUtils;
@@ -41,7 +40,8 @@ import static java.lang.Thread.sleep;
import static org.jboss.fuse.mvnd.client.DaemonState.Canceled;
/**
* File origin: https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/client/DefaultDaemonConnector.java
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/client/DefaultDaemonConnector.java
*/
public class DaemonConnector {
@@ -56,7 +56,8 @@ public class DaemonConnector {
private final Serializer<Message> serializer;
private final BuildProperties buildProperties;
public DaemonConnector(ClientLayout layout, DaemonRegistry registry, BuildProperties buildProperties, Serializer<Message> serializer) {
public DaemonConnector(ClientLayout layout, DaemonRegistry registry, BuildProperties buildProperties,
Serializer<Message> serializer) {
this.layout = layout;
this.registry = registry;
this.buildProperties = buildProperties;
@@ -164,7 +165,8 @@ public class DaemonConnector {
return findConnection(compatibleIdleDaemons);
}
private DaemonClientConnection connectToCanceledDaemon(Collection<DaemonInfo> busyDaemons, DaemonCompatibilitySpec constraint) {
private DaemonClientConnection connectToCanceledDaemon(Collection<DaemonInfo> busyDaemons,
DaemonCompatibilitySpec constraint) {
DaemonClientConnection connection = null;
Map<Boolean, List<DaemonInfo>> canceledBusy = busyDaemons.stream()
.collect(Collectors.groupingBy(di -> di.getState() == Canceled));
@@ -246,7 +248,7 @@ public class DaemonConnector {
args.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000");
}
args.add("-Dmaven.home=\"" + mavenHome + "\"");
args.add("-Dlogback.configurationFile=\""+ layout.getLogbackConfigurationPath() +"\"");
args.add("-Dlogback.configurationFile=\"" + layout.getLogbackConfigurationPath() + "\"");
args.add("-Ddaemon.uid=" + uid);
args.add("-Xmx4g");
final String timeout = Environment.DAEMON_IDLE_TIMEOUT.systemProperty().asString();
@@ -277,7 +279,6 @@ public class DaemonConnector {
return result;
}
private DaemonClientConnection connectToDaemonWithId(String daemon) throws DaemonException.ConnectException {
// Look for 'our' daemon among the busy daemons - a daemon will start in busy state so that nobody else will grab it.
DaemonInfo daemonInfo = registry.get(daemon);
@@ -292,7 +293,8 @@ public class DaemonConnector {
return null;
}
private DaemonClientConnection connectToDaemon(DaemonInfo daemon, DaemonClientConnection.StaleAddressDetector staleAddressDetector) throws DaemonException.ConnectException {
private DaemonClientConnection connectToDaemon(DaemonInfo daemon,
DaemonClientConnection.StaleAddressDetector staleAddressDetector) throws DaemonException.ConnectException {
LOGGER.debug("Connecting to Daemon");
try {
DaemonConnection<Message> connection = connect(daemon.getAddress());
@@ -318,7 +320,8 @@ public class DaemonConnector {
public boolean maybeStaleAddress(Exception failure) {
LOGGER.info("Removing daemon from the registry due to communication failure. Daemon information: {}", daemon);
final long timestamp = System.currentTimeMillis();
final DaemonStopEvent stopEvent = new DaemonStopEvent(daemon.getUid(), timestamp, null, "by user or operating system");
final DaemonStopEvent stopEvent = new DaemonStopEvent(daemon.getUid(), timestamp, null,
"by user or operating system");
registry.storeStopEvent(stopEvent);
registry.remove(daemon.getUid());
return exposeAsStale;

View File

@@ -26,7 +26,8 @@ import java.util.List;
import java.util.stream.Collector;
/**
* File origin: https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/diagnostics/DaemonDiagnostics.java
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/diagnostics/DaemonDiagnostics.java
*/
public class DaemonDiagnostics {
@@ -58,9 +59,9 @@ public class DaemonDiagnostics {
}
/**
* @param path to read from tail
* @param maxLines max lines to read
* @return tail content
* @param path to read from tail
* @param maxLines max lines to read
* @return tail content
* @throws IOException when reading failed
*/
static String tail(Path path, int maxLines) throws IOException {
@@ -70,7 +71,7 @@ public class DaemonDiagnostics {
}
static <T> Collector<T, ?, List<T>> lastN(int n) {
return Collector.<T, Deque<T>, List<T>>of(ArrayDeque::new, (acc, t) -> {
return Collector.<T, Deque<T>, List<T>> of(ArrayDeque::new, (acc, t) -> {
if (acc.size() == n)
acc.pollFirst();
acc.add(t);

View File

@@ -21,11 +21,12 @@ package org.jboss.fuse.mvnd.client;
* take precedent over lower ordinal statuses when aggregating
* results.
*
* File origin: https://github.com/gradle/gradle/blob/v6.5.1/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/server/expiry/DaemonExpirationStatus.java
* File origin:
* https://github.com/gradle/gradle/blob/v6.5.1/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/server/expiry/DaemonExpirationStatus.java
*/
public enum DaemonExpirationStatus {
DO_NOT_EXPIRE,
QUIET_EXPIRE,
GRACEFUL_EXPIRE,
IMMEDIATE_EXPIRE;
}
}

View File

@@ -15,14 +15,14 @@
*/
package org.jboss.fuse.mvnd.client;
import java.util.List;
import static org.jboss.fuse.mvnd.client.DaemonState.Busy;
import static org.jboss.fuse.mvnd.client.DaemonState.Idle;
import java.nio.file.Path;
import java.util.List;
/**
* File origin: https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/registry/DaemonInfo.java
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/registry/DaemonInfo.java
*/
public class DaemonInfo {
@@ -39,9 +39,9 @@ public class DaemonInfo {
private final long lastBusy;
public DaemonInfo(String uid, String javaHome, String mavenHome,
int pid, int address, int idleTimeout,
String locale, List<String> options,
DaemonState state, long lastIdle, long lastBusy) {
int pid, int address, int idleTimeout,
String locale, List<String> options,
DaemonState state, long lastIdle, long lastBusy) {
this.uid = uid;
this.javaHome = javaHome;
this.mavenHome = mavenHome;
@@ -121,6 +121,7 @@ public class DaemonInfo {
appendNonKeyFields(sb);
return sb.append('}').toString();
}
public StringBuilder appendNonKeyFields(StringBuilder sb) {
return sb.append("javaHome=").append(javaHome)
.append(", options=").append(options)

View File

@@ -16,9 +16,6 @@
package org.jboss.fuse.mvnd.client;
import static org.jboss.fuse.mvnd.client.DaemonState.Canceled;
import static org.jboss.fuse.mvnd.client.DaemonState.Idle;
import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
@@ -39,17 +36,19 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.misc.Unsafe;
import sun.nio.ch.DirectBuffer;
import static org.jboss.fuse.mvnd.client.DaemonState.Canceled;
import static org.jboss.fuse.mvnd.client.DaemonState.Idle;
/**
* Access to daemon registry files. Useful also for testing.
*
* File origin: https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/registry/DaemonRegistry.java
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/registry/DaemonRegistry.java
*/
public class DaemonRegistry implements AutoCloseable {
@@ -252,7 +251,8 @@ public class DaemonRegistry implements AutoCloseable {
DaemonState state = DaemonState.values()[buffer.get()];
long lastIdle = buffer.getLong();
long lastBusy = buffer.getLong();
DaemonInfo di = new DaemonInfo(uid, javaHome, mavenHome, pid, address, idle, locale, opts, state, lastIdle, lastBusy);
DaemonInfo di = new DaemonInfo(uid, javaHome, mavenHome, pid, address, idle, locale, opts, state,
lastIdle, lastBusy);
infosMap.putIfAbsent(di.getUid(), di);
}
stopEvents.clear();
@@ -401,9 +401,8 @@ public class DaemonRegistry implements AutoCloseable {
long millis = (System.nanoTime() - start) / 1000000;
if (millis > 200) {
LOGGER.warn(currentThread().getName() +
", to obtain a lock took " +
millis / 1e3 + " seconds"
);
", to obtain a lock took " +
millis / 1e3 + " seconds");
}
return true;
}
@@ -497,12 +496,14 @@ public class DaemonRegistry implements AutoCloseable {
private AtomicBoolean barrier;
private void readBarrier() {
if (barrier == null) barrier = new AtomicBoolean();
if (barrier == null)
barrier = new AtomicBoolean();
barrier.get();
}
private void writeBarrier() {
if (barrier == null) barrier = new AtomicBoolean();
if (barrier == null)
barrier = new AtomicBoolean();
barrier.lazySet(false);
}

View File

@@ -16,7 +16,8 @@
package org.jboss.fuse.mvnd.client;
/**
* File origin https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/server/api/DaemonStateControl.java
* File origin
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/server/api/DaemonStateControl.java
*/
public enum DaemonState {

View File

@@ -24,7 +24,8 @@ import java.util.Objects;
/**
* Information regarding when and why a daemon was stopped.
*
* File origin: https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/registry/DaemonStopEvent.java
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/launcher/src/main/java/org/gradle/launcher/daemon/registry/DaemonStopEvent.java
*/
public class DaemonStopEvent implements Serializable {
@@ -58,8 +59,10 @@ public class DaemonStopEvent implements Serializable {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
DaemonStopEvent that = (DaemonStopEvent) o;
return Objects.equals(uid, that.uid)
&& timestamp == that.timestamp

View File

@@ -27,7 +27,6 @@ import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import org.fusesource.jansi.Ansi;
import org.jboss.fuse.mvnd.client.ClientOutput.TerminalOutput;
import org.jboss.fuse.mvnd.client.Message.BuildEvent;
@@ -87,7 +86,7 @@ public class DefaultClient implements Client {
.toAbsolutePath().normalize();
final Path javaHome = Environment.JAVA_HOME
.systemProperty() // only write java.home to mvnd.properties if it was explicitly set on command line
// via -Djava.home=...
// via -Djava.home=...
.asPath();
final Path mvndPropertiesPath = Environment.MVND_PROPERTIES_PATH
.commandLineProperty(() -> commandLineProperties)
@@ -139,7 +138,7 @@ public class DefaultClient implements Client {
if (arg.startsWith("-D")) {
final int eqPos = arg.indexOf('=');
if (eqPos >= 0) {
commandLineProperties.setProperty(arg.substring(2, eqPos), arg.substring(eqPos+1));
commandLineProperties.setProperty(arg.substring(2, eqPos), arg.substring(eqPos + 1));
} else {
commandLineProperties.setProperty(arg.substring(2), "");
}
@@ -154,7 +153,6 @@ public class DefaultClient implements Client {
return new DefaultResult(argv, null);
}
// Print version if needed
if (version || showVersion || debug) {
final String nativeSuffix = Environment.isNative() ? " (native)" : "";
@@ -227,7 +225,8 @@ public class DefaultClient implements Client {
if (m instanceof BuildException) {
final BuildException e = (BuildException) m;
output.error(e);
return new DefaultResult(argv, new Exception(e.getClassName() + ": "+ e.getMessage() + "\n" + e.getStackTrace()));
return new DefaultResult(argv,
new Exception(e.getClassName() + ": " + e.getMessage() + "\n" + e.getStackTrace()));
} else if (m instanceof BuildEvent) {
BuildEvent be = (BuildEvent) m;
switch (be.getType()) {

View File

@@ -132,7 +132,8 @@ public enum Environment {
.toAbsolutePath().normalize();
}
public static Path findLogbackConfigurationPath(Supplier<Properties> mvndProperties, Path mvndPropertiesPath, Path mvndHome) {
public static Path findLogbackConfigurationPath(Supplier<Properties> mvndProperties, Path mvndPropertiesPath,
Path mvndHome) {
return LOGBACK_CONFIGURATION_FILE
.systemProperty()
.orLocalProperty(mvndProperties, mvndPropertiesPath)
@@ -157,7 +158,7 @@ public enum Environment {
private Environment.ValueSource environmentVariableSource() {
if (environmentVariable == null) {
throw new IllegalStateException(
"Cannot use " + Environment.class.getName() + "."+ name() +" for getting an environment variable");
"Cannot use " + Environment.class.getName() + "." + name() + " for getting an environment variable");
}
return new ValueSource(
description -> description.append("environment variable ").append(environmentVariable),

View File

@@ -38,7 +38,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.slf4j.Logger;
@@ -132,7 +131,8 @@ public class Installer {
final Path dest = destinationDir.resolve(entry.getName()).normalize();
if (!dest.startsWith(destinationDir)) {
/* Avoid writing to paths outside of mvndHome */
throw new IllegalStateException("Possibly tainted ZIP entry name " + entry.getName() + " would have to be unpacked outside of " + destinationDir);
throw new IllegalStateException("Possibly tainted ZIP entry name " + entry.getName()
+ " would have to be unpacked outside of " + destinationDir);
}
if (entry.isDirectory()) {
Files.createDirectories(dest);

View File

@@ -113,6 +113,7 @@ public abstract class Message {
public enum Type {
BuildStarted, BuildStopped, ProjectStarted, ProjectStopped, MojoStarted, MojoStopped
}
final Type type;
final String projectId;
final String display;
@@ -177,14 +178,14 @@ public abstract class Message {
return null;
}
switch (type) {
case BUILD_REQUEST:
return readBuildRequest(input);
case BUILD_EVENT:
return readBuildEvent(input);
case BUILD_MESSAGE:
return readBuildMessage(input);
case BUILD_EXCEPTION:
return readBuildException(input);
case BUILD_REQUEST:
return readBuildRequest(input);
case BUILD_EVENT:
return readBuildEvent(input);
case BUILD_MESSAGE:
return readBuildMessage(input);
case BUILD_EXCEPTION:
return readBuildException(input);
}
throw new IllegalStateException("Unexpected message type: " + type);
}

View File

@@ -20,11 +20,13 @@ import java.io.DataOutputStream;
import java.io.EOFException;
/**
* File origin: https://github.com/gradle/gradle/blob/v5.6.2/subprojects/messaging/src/main/java/org/gradle/internal/serialize/Serializer.java
* File origin:
* https://github.com/gradle/gradle/blob/v5.6.2/subprojects/messaging/src/main/java/org/gradle/internal/serialize/Serializer.java
*/
public interface Serializer<T> {
/**
* Reads the next object from the given stream. The implementation must not perform any buffering, so that it reads only those bytes from the input stream that are
* Reads the next object from the given stream. The implementation must not perform any buffering, so that it reads only
* those bytes from the input stream that are
* required to deserialize the next object.
*
* @throws EOFException When the next object cannot be fully read due to reaching the end of stream.

View File

@@ -27,23 +27,22 @@ public class ServerMain {
public static void main(String[] args) throws Exception {
final String uidStr = Environment.DAEMON_UID.systemProperty().orFail().asString();
final Path mavenHome = Environment.MAVEN_HOME.systemProperty().orFail().asPath();
URL[] classpath =
Stream.concat(
Stream.concat(Files.list(mavenHome.resolve("lib/ext")),
Files.list(mavenHome.resolve("lib")))
.filter(p -> p.getFileName().toString().endsWith(".jar"))
.filter(Files::isRegularFile),
Stream.of(mavenHome.resolve("conf"), mavenHome.resolve("conf/logging")))
.map(Path::normalize)
.map(Path::toUri)
.map(uri -> {
try {
return uri.toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
})
.toArray(URL[]::new);
URL[] classpath = Stream.concat(
Stream.concat(Files.list(mavenHome.resolve("lib/ext")),
Files.list(mavenHome.resolve("lib")))
.filter(p -> p.getFileName().toString().endsWith(".jar"))
.filter(Files::isRegularFile),
Stream.of(mavenHome.resolve("conf"), mavenHome.resolve("conf/logging")))
.map(Path::normalize)
.map(Path::toUri)
.map(uri -> {
try {
return uri.toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
})
.toArray(URL[]::new);
ClassLoader loader = new URLClassLoader(classpath, null) {
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {

View File

@@ -15,23 +15,21 @@
*/
package org.jboss.fuse.mvnd.client.svm;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.zip.ZipException;
import org.apache.commons.compress.archivers.zip.AsiExtraField;
import org.apache.commons.compress.archivers.zip.ExtraFieldParsingBehavior;
import org.apache.commons.compress.archivers.zip.ExtraFieldUtils;
import org.apache.commons.compress.archivers.zip.ExtraFieldUtils.UnparseableExtraField;
import org.apache.commons.compress.archivers.zip.ZipExtraField;
import org.apache.commons.compress.archivers.zip.ZipShort;
import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.KeepOriginal;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.zip.ZipException;
import org.apache.commons.compress.archivers.zip.AsiExtraField;
import org.apache.commons.compress.archivers.zip.ExtraFieldParsingBehavior;
import org.apache.commons.compress.archivers.zip.ExtraFieldUtils;
import org.apache.commons.compress.archivers.zip.ExtraFieldUtils.UnparseableExtraField;
import org.apache.commons.compress.archivers.zip.ZipExtraField;
import org.apache.commons.compress.archivers.zip.ZipShort;
@TargetClass(ExtraFieldUtils.class)
@Substitute
@@ -46,20 +44,19 @@ public final class ExtraFieldUtilsSubstitution {
registerInst(new AsiExtraField());
}
public static void registerInst(ZipExtraField ze) {
implementations.put(ze.getHeaderId(), ze.getClass());
}
@KeepOriginal
public static ZipExtraField createExtraField(final ZipShort headerId)
throws InstantiationException, IllegalAccessException {
throws InstantiationException, IllegalAccessException {
return null;
}
@KeepOriginal
public static ZipExtraField createExtraFieldNoDefault(final ZipShort headerId)
throws InstantiationException, IllegalAccessException {
throws InstantiationException, IllegalAccessException {
return null;
}
@@ -70,21 +67,21 @@ public final class ExtraFieldUtilsSubstitution {
@KeepOriginal
public static ZipExtraField[] parse(final byte[] data, final boolean local)
throws ZipException {
throws ZipException {
return null;
}
@KeepOriginal
public static ZipExtraField[] parse(final byte[] data, final boolean local,
final UnparseableExtraField onUnparseableData)
throws ZipException {
final UnparseableExtraField onUnparseableData)
throws ZipException {
return null;
}
@KeepOriginal
public static ZipExtraField[] parse(final byte[] data, final boolean local,
final ExtraFieldParsingBehavior parsingBehavior)
throws ZipException {
final ExtraFieldParsingBehavior parsingBehavior)
throws ZipException {
return null;
}
@@ -100,7 +97,7 @@ public final class ExtraFieldUtilsSubstitution {
@KeepOriginal
public static ZipExtraField fillExtraField(final ZipExtraField ze, final byte[] data, final int off,
final int len, final boolean local) throws ZipException {
final int len, final boolean local) throws ZipException {
return null;
}

View File

@@ -15,17 +15,16 @@
*/
package org.jboss.fuse.mvnd.client.svm;
import org.graalvm.nativeimage.hosted.Feature;
import com.oracle.svm.core.annotate.AutomaticFeature;
import org.graalvm.nativeimage.hosted.Feature;
@AutomaticFeature
public class ReflectionRegistration implements Feature {
public void beforeAnalysis(BeforeAnalysisAccess access) {
// try {
// RuntimeReflection.register(AsiExtraField.class.getConstructors());
// } catch (SecurityException e) {
// throw new RuntimeException(e);
// }
// try {
// RuntimeReflection.register(AsiExtraField.class.getConstructors());
// } catch (SecurityException e) {
// throw new RuntimeException(e);
// }
}
}

View File

@@ -15,13 +15,12 @@
*/
package org.jboss.fuse.mvnd.client.svm;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import org.slf4j.MDC;
import org.slf4j.impl.StaticMDCBinder;
import org.slf4j.spi.MDCAdapter;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
@TargetClass(MDC.class)
final class StaticMDCBinderSubstitution {

View File

@@ -29,13 +29,15 @@ public interface Process extends Serializable {
/**
* Retrieves the PID of the process
*
* @return the pid
*/
int getPid();
/**
* Check if this process is still running
* @return <code>true</code> if the process is running
*
* @return <code>true</code> if the process is running
* @throws IOException if an error occurs
*/
boolean isRunning() throws IOException;

View File

@@ -25,12 +25,12 @@ import java.io.InputStreamReader;
import java.io.InterruptedIOException;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* File origin: https://github.com/apache/karaf/blob/karaf-4.2.6/util/src/main/java/org/apache/karaf/jpm/impl/ProcessImpl.java
* File origin:
* https://github.com/apache/karaf/blob/karaf-4.2.6/util/src/main/java/org/apache/karaf/jpm/impl/ProcessImpl.java
*/
public class ProcessImpl implements Process {
@@ -96,11 +96,11 @@ public class ProcessImpl implements Process {
public OutputStream getInputStream() throws FileNotFoundException {
return new FileOutputStream(input);
}
public InputStream getOutputStream() throws FileNotFoundException {
return new FileInputStream(output);
}
public InputStream getErrorStream() throws FileNotFoundException {
return new FileInputStream(error);
}

View File

@@ -25,12 +25,12 @@ import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Map;
import java.util.Scanner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* File origin: https://github.com/apache/karaf/blob/karaf-4.2.6/util/src/main/java/org/apache/karaf/jpm/impl/ScriptUtils.java
* File origin:
* https://github.com/apache/karaf/blob/karaf-4.2.6/util/src/main/java/org/apache/karaf/jpm/impl/ScriptUtils.java
*/
public class ScriptUtils {
@@ -44,14 +44,14 @@ public class ScriptUtils {
String res = "windows/" + name + ".vbs";
ScriptUtils.copyFilteredResource(res, script, props);
return executeProcess(new java.lang.ProcessBuilder("cscript",
"/NOLOGO",
"//E:vbs",
script.getCanonicalPath()));
"/NOLOGO",
"//E:vbs",
script.getCanonicalPath()));
} else {
String res = "unix/" + name + ".sh";
ScriptUtils.copyFilteredResource(res, script, props);
return executeProcess(new java.lang.ProcessBuilder("/bin/sh",
script.getCanonicalPath()));
script.getCanonicalPath()));
}
} finally {
script.delete();
@@ -77,7 +77,7 @@ public class ScriptUtils {
PrintStream out = new PrintStream(new FileOutputStream(outFile));
try {
Scanner scanner = new Scanner(is);
while (scanner.hasNextLine() ) {
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
line = filter(line, props);
LOG.trace("Script line {}", line);
@@ -115,10 +115,10 @@ public class ScriptUtils {
private static String filter(String line, Map<String, String> props) {
for (Map.Entry<String, String> i : props.entrySet()) {
int p1 = line.indexOf(i.getKey());
if( p1 >= 0 ) {
if (p1 >= 0) {
String l1 = line.substring(0, p1);
String l2 = line.substring(p1+i.getKey().length());
line = l1+i.getValue()+l2;
String l2 = line.substring(p1 + i.getKey().length());
line = l1 + i.getValue() + l2;
}
}
return line;

View File

@@ -21,10 +21,6 @@ import java.nio.file.Path;
import java.util.Arrays;
import java.util.Locale;
import java.util.Random;
import org.jboss.fuse.mvnd.client.DaemonInfo;
import org.jboss.fuse.mvnd.client.DaemonRegistry;
import org.jboss.fuse.mvnd.client.DaemonState;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

View File

@@ -19,7 +19,6 @@ import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;