Skip to content

Commit

Permalink
Core: minor refactoring of StartupContext
Browse files Browse the repository at this point in the history
- remove unused fields and methods
- add a comment to StartupContext#values
  • Loading branch information
mkouba committed Jul 3, 2024
1 parent 7b817b5 commit 7a385df
Showing 1 changed file with 4 additions and 14 deletions.
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

0 comments on commit 7a385df

Please sign in to comment.