From 97f74776d591af02b73d79cf5b35e8eb4492be48 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Thu, 14 Sep 2017 09:34:12 -0400 Subject: [PATCH] Allow UOW to be null in {a}sync(UnitOfWork uow). --- pom.xml | 2 +- .../helenus/core/operation/AbstractOptionalOperation.java | 5 ++--- .../net/helenus/core/operation/AbstractStreamOperation.java | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index d1b3a78..5748c69 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 net.helenus helenus-core - 2.0.34-SNAPSHOT + 2.0.35-SNAPSHOT jar helenus diff --git a/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java b/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java index ba99e2a..f4bf79b 100644 --- a/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java +++ b/src/main/java/net/helenus/core/operation/AbstractOptionalOperation.java @@ -67,7 +67,7 @@ public abstract class AbstractOptionalOperation sync(UnitOfWork uow) { - Objects.requireNonNull(uow, "Unit of Work should not be null."); + if (uow == null) return sync(); final Timer.Context context = requestLatency.time(); try { @@ -112,8 +112,7 @@ public abstract class AbstractOptionalOperation> async(UnitOfWork uow) { - Objects.requireNonNull(uow, "Unit of Work should not be null."); - + if (uow == null) return async(); return CompletableFuture.>supplyAsync(() -> sync(uow)); } diff --git a/src/main/java/net/helenus/core/operation/AbstractStreamOperation.java b/src/main/java/net/helenus/core/operation/AbstractStreamOperation.java index ff80787..6cec8f9 100644 --- a/src/main/java/net/helenus/core/operation/AbstractStreamOperation.java +++ b/src/main/java/net/helenus/core/operation/AbstractStreamOperation.java @@ -72,7 +72,7 @@ public abstract class AbstractStreamOperation sync(UnitOfWork uow) { - Objects.requireNonNull(uow, "Unit of Work should not be null."); + if (uow == null) return sync(); final Timer.Context context = requestLatency.time(); try { @@ -110,8 +110,7 @@ public abstract class AbstractStreamOperation> async(UnitOfWork uow) { - Objects.requireNonNull(uow, "Unit of Work should not be null."); - + if (uow == null) return async(); return CompletableFuture.>supplyAsync(() -> sync(uow)); }