Skip to content

Commit

Permalink
New method in VertxContextSafetyToggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanne committed Feb 23, 2022
1 parent b056580 commit c2008ee
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,20 @@ private static void checkIsSafe(final Context context, final String errorMessage
/**
* @param safe set to {@code true} to explicitly mark the current context as safe, or {@code false} to explicitly mark it as
* unsafe.
* @throws IllegalStateException if there is no current context!
* @throws IllegalStateException if there is no current context, or if it's of the wrong type.
*/
public static void setCurrentContextSafe(boolean safe) {
public static void setCurrentContextSafe(final boolean safe) {
final io.vertx.core.Context context = Vertx.currentContext();
setContextSafe(context, safe);
}

/**
* @param safe set to {@code true} to explicitly mark the current context as safe, or {@code false} to explicitly mark it as
* unsafe.
* @param context The context to mark.
* @throws IllegalStateException if context is null or not of the expected type.
*/
public static void setContextSafe(final Context context, final boolean safe) {
if (context == null) {
throw new IllegalStateException("Can't set the context safety flag: no Vert.x context found");
} else if (!VertxContext.isDuplicatedContext(context)) {
Expand Down

0 comments on commit c2008ee

Please sign in to comment.