Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
*/
package io.javaoperatorsdk.operator.processing.dependent.workflow;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.fabric8.kubernetes.api.model.HasMetadata;

abstract class NodeExecutor<R, P extends HasMetadata> implements Runnable {

private static final Logger log = LoggerFactory.getLogger(NodeExecutor.class);

private final DependentResourceNode<R, P> dependentResourceNode;
private final AbstractWorkflowExecutor<P> workflowExecutor;

Expand All @@ -37,6 +42,10 @@ public void run() {
} catch (Exception e) {
// Exception is required because of Kotlin
workflowExecutor.handleExceptionInExecutor(dependentResourceNode, e);
} catch (Error e) {
// without this user would see no sign about the error
log.error("java.lang.Error during execution", e);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also add it to the incremental recording of error messages that the workflow keeps?

Copy link
Collaborator Author

@csviri csviri Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not, this is just for a corner case, where we receive Errors. Those should not be caught in general in Java, and indicate a fundamental issue. Think of receving here an OutOfMemoryError. But also from the original reported issue the NoSuchFieldError indicates an issue with the bytecode. So we simply should not handle it.

throw e;
} finally {
workflowExecutor.handleNodeExecutionFinish(dependentResourceNode);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright Java Operator SDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.javaoperatorsdk.operator.processing.dependent.workflow;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class NodeExecutorTest {

private NodeExecutor errorThrowingNodeExecutor =
new NodeExecutor(null, null) {
@Override
protected void doRun(DependentResourceNode dependentResourceNode) {
throw new NoSuchFieldError();
}
};

// for manual testing only to verify you can see the log message
@Disabled
@Test
void nodeExecutorLogsError() throws InterruptedException {
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(errorThrowingNodeExecutor);
Thread.sleep(500);
}
}