Repository: micronaut-projects/micronaut-core
File: core/src/main/java/io/micronaut/core/execution/DelayedExecutionFlowImpl.java (Java)

Code before:
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.micronaut.core.execution;

import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Supplier;

@SuppressWarnings("rawtypes")
final class DelayedExecutionFlowImpl<T> implements DelayedExecutionFlow<T> {
    private static final Logger LOG = LoggerFactory.getLogger(DelayedExecutionFlowImpl.class);

    /**
     * The head of the linked list of steps in this flow.
     */
    private Step head = new Head();
    /**
     * The tail of the linked list of steps in this flow.
     */
    private Step tail = head;
    private Runnable onCancel;
    private volatile boolean cancelled;

    /**
     * Perform the given step with the given item. Continue on until there is either no more steps,
     * either because onComplete was hit or because the consumer is not finished adding all the
     * steps, or until a step does not finish immediately, e.g. flatMap returning a non-immediate
     * flow.
     *
     * @param step The step to execute first
     * @param executionFlow The previous execution flow
     */
    private static void work(Step step, ExecutionFlow<Object> executionFlow) {
        do {
            executionFlow = step.apply(executionFlow);
            step = step.atomicSetOutput(executionFlow);
        } while (step != null);
    }

    @Override
    public void completeFrom(@NonNull ExecutionFlow<T> flow) {

Review comment (suggestion):
```suggestion
    private Head head = new Head();
```

Code after:
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.micronaut.core.execution;

import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Supplier;

@SuppressWarnings("rawtypes")
final class DelayedExecutionFlowImpl<T> implements DelayedExecutionFlow<T> {
    private static final Logger LOG = LoggerFactory.getLogger(DelayedExecutionFlowImpl.class);

    /**
     * The head of the linked list of steps in this flow.
     */
    private Head head = new Head();
    /**
     * The tail of the linked list of steps in this flow.
     */
    private Step tail = head;
    private Runnable onCancel;
    private volatile boolean cancelled;

    /**
     * Perform the given step with the given item. Continue on until there is either no more steps,
     * either because onComplete was hit or because the consumer is not finished adding all the
     * steps, or until a step does not finish immediately, e.g. flatMap returning a non-immediate
     * flow.
     *
     * @param step The step to execute first
     * @param executionFlow The previous execution flow
     */
    private static void work(Step step, ExecutionFlow<Object> executionFlow) {
        do {
            executionFlow = step.apply(executionFlow);
            step = step.atomicSetOutput(executionFlow);
        } while (step != null);
    }

    @Override
    public void completeFrom(@NonNull ExecutionFlow<T> flow) {