Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: minor refactoring of StartupContext #41653

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions core/runtime/src/main/java/io/quarkus/runtime/StartupContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ public class StartupContext implements Closeable {

private static final Logger LOG = Logger.getLogger(StartupContext.class);

// Holds values for returned proxies
// These values are usually returned from recorder methods but can be also set explicitly
// For example, the raw command line args and ShutdownContext are set when the StartupContext is created
private final Map<String, Object> values = new HashMap<>();
private Object lastValue;
// this is done to distinguish between the value having never been set and having been set as null
private boolean lastValueSet = false;

private final Deque<Runnable> shutdownTasks = new ConcurrentLinkedDeque<>();
private final Deque<Runnable> lastShutdownTasks = new ConcurrentLinkedDeque<>();
private String[] commandLineArgs;
Expand Down Expand Up @@ -58,28 +59,17 @@ public String[] get() {

public void putValue(String name, Object value) {
values.put(name, value);
lastValueSet = true;
this.lastValue = value;
}

public Object getValue(String name) {
return values.get(name);
}

public Object getLastValue() {
return lastValue;
}

public boolean isLastValueSet() {
return lastValueSet;
}

@Override
public void close() {
runAllAndClear(shutdownTasks);
runAllAndClear(lastShutdownTasks);
values.clear();
lastValue = null;
}

private void runAllAndClear(Deque<Runnable> tasks) {
Expand Down
Loading