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

Merge code freeze changes #288

Merged
merged 1 commit into from
Jan 2, 2025
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
12 changes: 12 additions & 0 deletions src/main/java/io/iworkflow/core/ImplementationException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.iworkflow.core;

// This indicates issues in the implementation of the workflow
public class ImplementationException extends RuntimeException {
public ImplementationException(Throwable cause) {
super(cause);
}

public ImplementationException(String message) {
super(message);
}
}
15 changes: 11 additions & 4 deletions src/main/java/io/iworkflow/core/RpcDefinitions.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package io.iworkflow.core;

import com.google.common.collect.ImmutableMap;
import io.iworkflow.core.communication.Communication;
import io.iworkflow.core.persistence.Persistence;

import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Map;
import java.lang.reflect.Modifier;

public final class RpcDefinitions {
private RpcDefinitions() {
@@ -100,12 +99,20 @@ public interface RpcProc0NoPersistence extends Serializable {
void execute(Context context, Communication communication);
}

public static final String ERROR_MESSAGE = "An RPC method must be in the form of one of {@link RpcDefinitions}";
public static final String DEFINITION_ERROR_MESSAGE = "An RPC method must be in the form of one of {@link RpcDefinitions}";

public static final String FINAL_MODIFIER_ERROR_MESSAGE = "An RPC method must not be final";

public static void validateRpcMethod(final Method method) {
RpcMethodMetadata methodMetadata = RpcMethodMatcher.match(method);
final boolean isFinal = Modifier.isFinal(method.getModifiers());

if (isFinal) {
throw new ImplementationException(FINAL_MODIFIER_ERROR_MESSAGE);
}

if (methodMetadata == null) {
throw new WorkflowDefinitionException(ERROR_MESSAGE);
throw new WorkflowDefinitionException(DEFINITION_ERROR_MESSAGE);
}
}
}