You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2016/12/08 10:06:21 UTC
cxf git commit: [CXF-6882] Renaming UseNioWrite to UseNio so that it
can be bound the the parameter in the future and using the continuation reset
Repository: cxf
Updated Branches:
refs/heads/master 996d07454 -> 40dd6d61c
[CXF-6882] Renaming UseNioWrite to UseNio so that it can be bound the the parameter in the future and using the continuation reset
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/40dd6d61
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/40dd6d61
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/40dd6d61
Branch: refs/heads/master
Commit: 40dd6d61c5e6e276df9437e5f000e103ee6101d6
Parents: 996d074
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Thu Dec 8 10:06:02 2016 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Thu Dec 8 10:06:02 2016 +0000
----------------------------------------------------------------------
.../java/org/apache/cxf/annotations/UseNio.java | 38 ++++++++++++++++++++
.../org/apache/cxf/annotations/UseNioWrite.java | 38 --------------------
.../cxf/jaxrs/nio/NioMessageBodyWriter.java | 4 +--
.../cxf/jaxrs/nio/NioWriteListenerImpl.java | 7 +---
.../cxf/jaxrs/provider/BinaryDataProvider.java | 7 ++--
.../cxf/systest/jaxrs/nio/NioBookStore.java | 4 +--
6 files changed, 44 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/40dd6d61/core/src/main/java/org/apache/cxf/annotations/UseNio.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/annotations/UseNio.java b/core/src/main/java/org/apache/cxf/annotations/UseNio.java
new file mode 100644
index 0000000..ca29f97
--- /dev/null
+++ b/core/src/main/java/org/apache/cxf/annotations/UseNio.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+/**
+ * Instructs the runtime to copy the input stream to the output stream using NIO.
+ * This annotation will have no effect if continuations are not available
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ ElementType.METHOD })
+@Inherited
+public @interface UseNio {
+}
+
http://git-wip-us.apache.org/repos/asf/cxf/blob/40dd6d61/core/src/main/java/org/apache/cxf/annotations/UseNioWrite.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/annotations/UseNioWrite.java b/core/src/main/java/org/apache/cxf/annotations/UseNioWrite.java
deleted file mode 100644
index a9c797d..0000000
--- a/core/src/main/java/org/apache/cxf/annotations/UseNioWrite.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.annotations;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-/**
- * Instructs the runtime to copy the input stream to the output stream using NIO.
- * This annotation will have no effect if continuations are not available
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.METHOD })
-@Inherited
-public @interface UseNioWrite {
-}
-
http://git-wip-us.apache.org/repos/asf/cxf/blob/40dd6d61/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioMessageBodyWriter.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioMessageBodyWriter.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioMessageBodyWriter.java
index ac9f8ba..7b67cc0 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioMessageBodyWriter.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioMessageBodyWriter.java
@@ -54,9 +54,7 @@ public class NioMessageBodyWriter implements MessageBodyWriter<NioWriteEntity> {
NioWriteListenerImpl listener = new NioWriteListenerImpl(cont, entity, os);
Message m = JAXRSUtils.getCurrentMessage();
m.put(WriteListener.class, listener);
- // After this MBW registers the listener, JAXRSOutInterceptor is done, and the
- // out chain will need to be resumed from the interceptor which follows it
- m.put("suspend.chain.on.current.interceptor", Boolean.TRUE);
+ // return the current thread to the pool
cont.suspend(0);
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/40dd6d61/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteListenerImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteListenerImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteListenerImpl.java
index d35b4dd..2ed86dc 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteListenerImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioWriteListenerImpl.java
@@ -44,12 +44,7 @@ public final class NioWriteListenerImpl implements WriteListener {
public void onWritePossible() throws IOException {
while (cont.isReadyForWrite()) {
if (!entity.getWriter().write(out)) {
- // REVISIT:
- // Immediately closing the async context with cont.resume() works better
- // at the moment - with cont.resume() Jetty throws NPE in its internal code
- // which is quite possibly a Jetty bug.
- // Do we really need to complete the out chain after the response has been written out ?
- cont.resume();
+ cont.reset();
return;
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/40dd6d61/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
index f3e9353..cb376bd 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
@@ -49,7 +49,7 @@ import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.MessageBodyWriter;
-import org.apache.cxf.annotations.UseNioWrite;
+import org.apache.cxf.annotations.UseNio;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.MessageDigestInputStream;
import org.apache.cxf.continuations.Continuation;
@@ -202,7 +202,7 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider
Message inMessage = PhaseInterceptorChain.getCurrentMessage().getExchange().getInMessage();
handleRangeRequest(is, os, new HttpHeadersImpl(inMessage), outHeaders);
} else {
- boolean nioWrite = AnnotationUtils.getAnnotation(anns, UseNioWrite.class) != null;
+ boolean nioWrite = AnnotationUtils.getAnnotation(anns, UseNio.class) != null;
if (nioWrite) {
ContinuationProvider provider = getContinuationProvider();
if (provider != null) {
@@ -226,9 +226,6 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider
new DelegatingNioOutputStream(os));
Message m = JAXRSUtils.getCurrentMessage();
m.put(WriteListener.class, listener);
- // After this MBW registers the listener, JAXRSOutInterceptor is done, and the
- // out chain will need to be resumed from the interceptor which follows it
- m.put("suspend.chain.on.current.interceptor", Boolean.TRUE);
cont.suspend(0);
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/40dd6d61/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/nio/NioBookStore.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/nio/NioBookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/nio/NioBookStore.java
index ce2507a..e4a0c05 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/nio/NioBookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/nio/NioBookStore.java
@@ -29,7 +29,7 @@ import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.apache.cxf.annotations.UseNioWrite;
+import org.apache.cxf.annotations.UseNio;
import org.apache.cxf.helpers.IOUtils;
@Path("/bookstore")
@@ -71,7 +71,7 @@ public class NioBookStore {
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/is")
- @UseNioWrite
+ @UseNio
public InputStream readBooksFromInputStream() throws IOException {
return getClass().getResourceAsStream("/files/books.txt");
}