Skip to content

Commit

Permalink
Make sure private methods cannot be annotated
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper committed Sep 6, 2024
1 parent 9c71385 commit 1e83e84
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ private Handler fromExecutableElement(ServiceType serviceType, ExecutableElement
messager.printMessage(
Diagnostic.Kind.ERROR, "You cannot annotate a static init as Restate method");
}
if (element.getModifiers().contains(Modifier.PRIVATE)) {
messager.printMessage(Diagnostic.Kind.ERROR, "The annotated method is private");
}

boolean isAnnotatedWithShared = element.getAnnotation(Shared.class) != null;
boolean isAnnotatedWithExclusive = element.getAnnotation(Exclusive.class) != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ class KElementConverter(
if (function.functionKind != FunctionKind.MEMBER) {
logger.error("Only member function declarations are supported as Restate handlers")
}
if (function.getVisibility() == Visibility.PRIVATE) {
logger.error("The annotated function is private", function)
}

val isAnnotatedWithShared =
function.isAnnotationPresent(dev.restate.sdk.annotation.Shared::class)
Expand Down

0 comments on commit 1e83e84

Please sign in to comment.