This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 1c61f89  Core API refactoring.
1c61f89 is described below

commit 1c61f89f7b60871cb6d5ab450414d0700112416d
Author: JamesBognar <[email protected]>
AuthorDate: Sat Oct 23 11:10:58 2021 -0400

    Core API refactoring.
---
 .../main/java/org/apache/juneau/rest/RestContext.java    |  2 +-
 .../main/java/org/apache/juneau/rest/RestOpSession.java  |  6 +++---
 .../main/java/org/apache/juneau/rest/RestResponse.java   | 16 ++++++++--------
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index 58efd85..c1aa805 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -7015,7 +7015,7 @@ public class RestContext extends Context {
                        }
                }
 
-               Object output = 
opSession.getResponse().getOutput().get().orElse(null);
+               Object output = 
opSession.getResponse().getOutput().orElse(null);
                throw new NotImplemented("No response processors found to 
process output of type ''{0}''", className(output));
        }
 
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpSession.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpSession.java
index 40c0da8..1e9fda7 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpSession.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpSession.java
@@ -200,10 +200,10 @@ public class RestOpSession extends ContextSession {
                        }
                }
 
-               Optional<Optional<Object>> o = res.getOutput();
-               if (o.isPresent())
+               Optional<Object> o = res.getOutput();
+               if (o != null)
                        for (RestConverter converter : ctx.getConverters())
-                               res.setOutput(converter.convert(req, 
o.get().orElse(null)));
+                               res.setOutput(converter.convert(req, 
o.orElse(null)));
        }
 
        /**
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
index 0e396af..212c082 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
@@ -65,7 +65,7 @@ public final class RestResponse {
        private HttpServletResponse inner;
        private final RestRequest request;
 
-       private Optional<Optional<Object>> output = empty();  // The POJO being 
sent to the output.
+       private Optional<Object> output;  // The POJO being sent to the output.
        private ServletOutputStream sos;
        private FinishableServletOutputStream os;
        private FinishablePrintWriter w;
@@ -179,7 +179,7 @@ public final class RestResponse {
         * @return This object.
         */
        public RestResponse setOutput(Object output) {
-               this.output = of(ofNullable(output));
+               this.output = ofNullable(output);
                return this;
        }
 
@@ -208,13 +208,13 @@ public final class RestResponse {
         * Returns the output that was set by calling {@link 
#setOutput(Object)}.
         *
         * <p>
-        * If it's empty, then {@link #setOutput(Object)} wasn't called.
-        * <br>If it's not empty but contains an empty, then 
<c>setObject(<jk>null</jk>)</c> was called.
+        * If it's null, then {@link #setOutput(Object)} wasn't called.
+        * <br>If it contains an empty, then <c>setObject(<jk>null</jk>)</c> 
was called.
         * <br>Otherwise, {@link #setOutput(Object)} was called with a non-null 
value.
         *
-        * @return The output object.  Never <jk>null</jk>.
+        * @return The output object, or <jk>null</jk> if {@link 
#setOutput(Object)} was never called.
         */
-       public Optional<Optional<Object>> getOutput() {
+       public Optional<Object> getOutput() {
                return output;
        }
 
@@ -231,7 +231,7 @@ public final class RestResponse {
         * @return <jk>true</jk> if the response contains output.
         */
        public boolean hasOutput() {
-               return output.isPresent();
+               return output != null;
        }
 
        /**
@@ -766,7 +766,7 @@ public final class RestResponse {
        }
 
        private Object getRawOutput() {
-               return output.isPresent() ? output.get().orElse(null) : null;
+               return output == null ? null : output.orElse(null);
        }
 
        /**

Reply via email to