Skip to content

Commit

Permalink
Increase Copyright year from 2018 to 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed May 13, 2023
1 parent d9e460e commit 74d8ec8
Show file tree
Hide file tree
Showing 21 changed files with 75 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/ch/vorburger/exec/CompositeExecuteResultHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,25 +19,25 @@
*/
package ch.vorburger.exec;

import static java.util.Objects.requireNonNull;

import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.exec.DefaultExecuteResultHandler;
import org.apache.commons.exec.ExecuteException;
import org.apache.commons.exec.ExecuteResultHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.List;

import static java.util.Objects.requireNonNull;

class CompositeExecuteResultHandler extends DefaultExecuteResultHandler {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

private final List<? extends ExecuteResultHandler> handlers;
private final ManagedProcessState managedProcessState;

public CompositeExecuteResultHandler(ManagedProcessState managedProcessState, List<? extends ExecuteResultHandler> handlers) {
public CompositeExecuteResultHandler(ManagedProcessState managedProcessState,
List<? extends ExecuteResultHandler> handlers) {
super();
this.managedProcessState = requireNonNull(managedProcessState, "managedProcessState can't be null");
this.handlers = new ArrayList<>(handlers);
Expand All @@ -50,7 +50,7 @@ public void onProcessComplete(int exitValue) {
try {
handler.onProcessComplete(exitValue);
} catch (Exception e) {
logger.error(managedProcessState.getProcLongName() + " process handler failed on processComplete",e);
logger.error(managedProcessState.getProcLongName() + " process handler failed on processComplete", e);
}
}
}
Expand All @@ -62,7 +62,7 @@ public void onProcessFailed(ExecuteException processFailedException) {
try {
handler.onProcessFailed(processFailedException);
} catch (Exception e) {
logger.error(managedProcessState.getProcLongName() + " process handler failed on processComplete",e);
logger.error(managedProcessState.getProcLongName() + " process handler failed on processComplete", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,15 +19,14 @@
*/
package ch.vorburger.exec;

import static java.util.Objects.requireNonNull;

import java.lang.invoke.MethodHandles;
import org.apache.commons.exec.DefaultExecuteResultHandler;
import org.apache.commons.exec.ExecuteException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.invoke.MethodHandles;

import static java.util.Objects.requireNonNull;

/**
* Extends Commons Exec's {@link DefaultExecuteResultHandler} with logging and notify state to initializing class.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,12 +19,11 @@
*/
package ch.vorburger.exec;

import java.lang.invoke.MethodHandles;
import org.apache.commons.exec.ShutdownHookProcessDestroyer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.invoke.MethodHandles;

public class LoggingShutdownHookProcessDestroyer extends ShutdownHookProcessDestroyer {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

Expand Down
17 changes: 10 additions & 7 deletions src/main/java/ch/vorburger/exec/ManagedProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteException;
Expand Down Expand Up @@ -102,7 +101,8 @@ public class ManagedProcess implements ManagedProcessState {
* @param listener <CODE>ManagedProcessListener</CODE>
*/
ManagedProcess(CommandLine commandLine, File directory, Map<String, String> environment,
InputStream input, boolean destroyOnShutdown, int consoleBufferMaxLines, OutputStreamLogDispatcher outputStreamLogDispatcher,
InputStream input, boolean destroyOnShutdown, int consoleBufferMaxLines,
OutputStreamLogDispatcher outputStreamLogDispatcher,
List<OutputStream> stdOuts, List<OutputStream> stderr, ManagedProcessListener listener) {
this.commandLine = commandLine;
this.environment = environment;
Expand All @@ -120,7 +120,8 @@ public class ManagedProcess implements ManagedProcessState {
this.destroyOnShutdown = destroyOnShutdown;
this.consoleBufferMaxLines = consoleBufferMaxLines;
this.outputStreamLogDispatcher = outputStreamLogDispatcher;
this.resultHandler = new CompositeExecuteResultHandler(this, Arrays.asList(new LoggingExecuteResultHandler(this), new ProcessResultHandler(listener)));
this.resultHandler = new CompositeExecuteResultHandler(this,
Arrays.asList(new LoggingExecuteResultHandler(this), new ProcessResultHandler(listener)));
this.stdouts = new MultiOutputStream();
this.stderrs = new MultiOutputStream();
for (OutputStream stdOut : stdOuts) {
Expand Down Expand Up @@ -250,7 +251,8 @@ public boolean startAndWaitForConsoleMessageMaxMs(String messageInConsole,
final int SLEEP_TIME_MS = 50;
logger.info(
"Thread will wait for \"{}\" to appear in Console output of process {} for max. "
+ maxWaitUntilReturning + "ms", messageInConsole, getProcLongName());
+ maxWaitUntilReturning + "ms",
messageInConsole, getProcLongName());

startExecute();

Expand Down Expand Up @@ -516,7 +518,8 @@ private String getProcShortName() {
public String getProcLongName() {
return "Program "
+ commandLine.toString()
+ (executor.getWorkingDirectory() == null ? "" : " (in working directory "
+ executor.getWorkingDirectory().getAbsolutePath() + ")");
+ (executor.getWorkingDirectory() == null ? ""
: " (in working directory "
+ executor.getWorkingDirectory().getAbsolutePath() + ")");
}
}
8 changes: 5 additions & 3 deletions src/main/java/ch/vorburger/exec/ManagedProcessBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -234,7 +234,8 @@ public OutputStreamLogDispatcher getOutputStreamLogDispatcher() {
// ----

public ManagedProcess build() {
return new ManagedProcess(getCommandLine(), directory, environment, inputStream, destroyOnShutdown, consoleBufferMaxLines,
return new ManagedProcess(getCommandLine(), directory, environment, inputStream, destroyOnShutdown,
consoleBufferMaxLines,
outputStreamLogDispatcher, stdOuts, stdErrs, listener);
}

Expand Down Expand Up @@ -274,7 +275,8 @@ CommandLine getCommandLine() {
/**
* Intended for debugging / logging, only.
*/
@Override public String toString() {
@Override
public String toString() {
return commonsExecCommandLine.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,11 +19,10 @@
*/
package ch.vorburger.exec;

import java.lang.invoke.MethodHandles;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.invoke.MethodHandles;

/**
* Internal Listener that just provides debug info if ManagedProcessListener is not set externally
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/vorburger/exec/ManagedProcessState.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/vorburger/exec/MultiCauseIOException.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/ch/vorburger/exec/MultiOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,7 +41,8 @@ public class MultiOutputStream extends OutputStream {

protected final List<OutputStream> streams = new LinkedList<>();

public MultiOutputStream() {}
public MultiOutputStream() {
}

public MultiOutputStream(OutputStream... delegates) {
for (OutputStream delegate : delegates) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2016 - 2018 Michael Vorburger
* Copyright (C) 2016 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/vorburger/exec/OutputStreamType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2016 - 2018 Michael Vorburger
* Copyright (C) 2016 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/vorburger/exec/ProcessResultHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/ch/vorburger/exec/RollingLogOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,6 @@
package ch.vorburger.exec;

import java.util.Collection;

import org.apache.commons.collections4.queue.CircularFifoQueue;
import org.apache.commons.exec.LogOutputStream;

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/ch/vorburger/exec/SLF4jLogOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,7 +40,8 @@ class SLF4jLogOutputStream extends LogOutputStream {
private final OutputStreamType type;
private final String pid;

protected SLF4jLogOutputStream(Logger logger, String pid, OutputStreamType type, OutputStreamLogDispatcher dispatcher) {
protected SLF4jLogOutputStream(Logger logger, String pid, OutputStreamType type,
OutputStreamLogDispatcher dispatcher) {
this.dispatcher = dispatcher;
this.logger = logger;
this.type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/vorburger/exec/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2015 - 2018 Michael Vorburger
* Copyright (C) 2015 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* ch.vorburger.exec
* %%
* Copyright (C) 2012 - 2018 Michael Vorburger
* Copyright (C) 2012 - 2023 Michael Vorburger
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,7 +26,6 @@
import static org.junit.Assert.assertTrue;

import java.io.File;

import org.apache.commons.lang3.SystemUtils;
import org.junit.Test;

Expand Down
Loading

0 comments on commit 74d8ec8

Please sign in to comment.