Re: [cxf] branch master updated: [CXF-7532]REST on JMS transport can't handle the request message with text messageType

2017-10-20 Thread Sergey Beryozkin
Thanks Freeman, it looks fine, yes, it's a bit tricky to make sure it 
works across all of JAX-RS providers, especially with custom MBRs 
expecting InputStream to be not null...


Sergey

On 20/10/17 03:08, Freeman Fang wrote:

Hi Sergey,

Cleaned up accordingly.

Cheers
-
Freeman(Yue) Fang

Red Hat, Inc.
FuseSource is now part of Red Hat



On Oct 20, 2017, at 5:59 AM, Sergey Beryozkin > wrote:


Some JAX-RS providers check Reader or XMLStreamReader if InputStream 
is null.
But at the moment, Freeman, please do a bit of cleanup as agreed, and 
then we can check if the use ReaderInputStream can be avoided at all.


Sergey

On 19/10/17 19:47, Daniel Kulp wrote:
If using the TEXT stuff for JMS, it should remain as a Reader on the 
message if at all possible.  Converting from Reader to InputStream is 
not a trivial operation and does enact a performance penalty.   All 
of the SOAP pathways for JMS should be OK for use of a Reader so that 
we can avoid the entire String->UTF-8 bytes->chars round tripping.

Dan
On Oct 19, 2017, at 5:21 AM, ffang > wrote:


I modified the JMS transport part and set ReaderInputStream instead 
of Reader, running all tests now, will see what I can get.


If I run into any test failure, I will keep things as is, just clean up.
-
Freeman(Yue) Fang

Red Hat, Inc.
FuseSource is now part of Red Hat



On Oct 19, 2017, at 5:16 PM, Sergey Beryozkin > wrote:


If we assume that checking Reader can be useful in the general 
sense, then may be lets keep things as is, with the minor cleanup 
only...


Sergey
On 19/10/17 10:05, Sergey Beryozkin wrote:

Hi Freeman
Reader may likely need to be set too for SOAP, and I recall 
checking Reader somewhere else too (will double check now), but I 
thought may be the transport can set both Reader and InputStream, 
hmm, that is an extra instance though, may be lets start with 
moving ReaderInputStream to the core first ?

Sergey
On 19/10/17 09:59, ffang wrote:
Yeah, set ReaderInputStream instead of Reader for the JMS 
transport is a better solution. If no objection I will go this way.

-
Freeman(Yue) Fang

Red Hat, Inc.
FuseSource is now part of Red Hat



On Oct 19, 2017, at 4:50 PM, Sergey Beryozkin 
 
> wrote:


The other thing is, should JMS transport itself set 
ReaderInputStream as InputStream on the message, as opposed to 
patching the JAX-RS code in various places ?


Sergey
On 19/10/17 09:44, Sergey Beryozkin wrote:

Hi Freeman
Can you move ReaderInputStream to the CXF core where 
CachedInputStream and other IO utility code is located ?
Please also update the code which gets Reader.class and check 
it for null first, and also drop a comment re the JMS 
transport, checking the reader can make sense in all the cases...

Thanks, Sergey
On 19/10/17 04:16, ff...@apache.org  
 wrote:
This is an automated email from the ASF dual-hosted git 
repository.


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


The following commit(s) were added to refs/heads/master by 
this push:
 new 1d66475  [CXF-7532]REST on JMS transport can't handle 
the request message with text messageType

1d66475 is described below

commit 1d66475b4dea2a0031dcb1765e8e9fd08430ec9b
Author: Freeman Fang  >

AuthorDate: Thu Oct 19 11:15:50 2017 +0800

[CXF-7532]REST on JMS transport can't handle the request 
message with text messageType

---
 .../org/apache/cxf/jaxrs/impl/ResponseImpl.java    |   5 +
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java |   6 +-
 .../apache/cxf/jaxrs/utils/ReaderInputStream.java  | 296 
+

 .../apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java |  90 +++
 4 files changed, 396 insertions(+), 1 deletion(-)

diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java

index e3a3acf..82f183a 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
@@ -58,6 +58,7 @@ import 
org.apache.cxf.jaxrs.provider.ProviderFactory;

 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.ReaderInputStream;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
@@ -342,6 +343,10 @@ public final class ResponseImpl extends 
Response {

 entityStreamAvailable = entityStream != null;
 } else if (entity 

Re: [cxf] branch master updated: [CXF-7532]REST on JMS transport can't handle the request message with text messageType

2017-10-19 Thread Freeman Fang
Hi Sergey,

Cleaned up accordingly.

Cheers
-
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat



> On Oct 20, 2017, at 5:59 AM, Sergey Beryozkin  wrote:
> 
> Some JAX-RS providers check Reader or XMLStreamReader if InputStream is null.
> But at the moment, Freeman, please do a bit of cleanup as agreed, and then we 
> can check if the use ReaderInputStream can be avoided at all.
> 
> Sergey
> 
> On 19/10/17 19:47, Daniel Kulp wrote:
>> If using the TEXT stuff for JMS, it should remain as a Reader on the message 
>> if at all possible.  Converting from Reader to InputStream is not a trivial 
>> operation and does enact a performance penalty.   All of the SOAP pathways 
>> for JMS should be OK for use of a Reader so that we can avoid the entire 
>> String->UTF-8 bytes->chars round tripping.
>> Dan
>> On Oct 19, 2017, at 5:21 AM, ffang  wrote:
>>> 
>>> I modified the JMS transport part and set ReaderInputStream instead of 
>>> Reader, running all tests now, will see what I can get.
>>> 
>>> If I run into any test failure, I will keep things as is, just clean up.
>>> -
>>> Freeman(Yue) Fang
>>> 
>>> Red Hat, Inc.
>>> FuseSource is now part of Red Hat
>>> 
>>> 
>>> 
 On Oct 19, 2017, at 5:16 PM, Sergey Beryozkin  wrote:
 
 If we assume that checking Reader can be useful in the general sense, then 
 may be lets keep things as is, with the minor cleanup only...
 
 Sergey
 On 19/10/17 10:05, Sergey Beryozkin wrote:
> Hi Freeman
> Reader may likely need to be set too for SOAP, and I recall checking 
> Reader somewhere else too (will double check now), but I thought may be 
> the transport can set both Reader and InputStream, hmm, that is an extra 
> instance though, may be lets start with moving ReaderInputStream to the 
> core first ?
> Sergey
> On 19/10/17 09:59, ffang wrote:
>> Yeah, set ReaderInputStream instead of Reader for the JMS transport is a 
>> better solution. If no objection I will go this way.
>> -
>> Freeman(Yue) Fang
>> 
>> Red Hat, Inc.
>> FuseSource is now part of Red Hat
>> 
>> 
>> 
>>> On Oct 19, 2017, at 4:50 PM, Sergey Beryozkin >> > wrote:
>>> 
>>> The other thing is, should JMS transport itself set ReaderInputStream 
>>> as InputStream on the message, as opposed to patching the JAX-RS code 
>>> in various places ?
>>> 
>>> Sergey
>>> On 19/10/17 09:44, Sergey Beryozkin wrote:
 Hi Freeman
 Can you move ReaderInputStream to the CXF core where CachedInputStream 
 and other IO utility code is located ?
 Please also update the code which gets Reader.class and check it for 
 null first, and also drop a comment re the JMS transport, checking the 
 reader can make sense in all the cases...
 Thanks, Sergey
 On 19/10/17 04:16, ff...@apache.org  wrote:
> This is an automated email from the ASF dual-hosted git repository.
> 
> ffang pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/cxf.git
> 
> 
> The following commit(s) were added to refs/heads/master by this push:
>  new 1d66475  [CXF-7532]REST on JMS transport can't handle the 
> request message with text messageType
> 1d66475 is described below
> 
> commit 1d66475b4dea2a0031dcb1765e8e9fd08430ec9b
> Author: Freeman Fang  >
> AuthorDate: Thu Oct 19 11:15:50 2017 +0800
> 
> [CXF-7532]REST on JMS transport can't handle the request message 
> with text messageType
> ---
>  .../org/apache/cxf/jaxrs/impl/ResponseImpl.java|   5 +
>  .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java |   6 +-
>  .../apache/cxf/jaxrs/utils/ReaderInputStream.java  | 296 
> +
>  .../apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java |  90 +++
>  4 files changed, 396 insertions(+), 1 deletion(-)
> 
> diff --git 
> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>  
> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
> index e3a3acf..82f183a 100644
> --- 
> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
> +++ 
> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
> @@ -58,6 +58,7 @@ import 
> org.apache.cxf.jaxrs.provider.ProviderFactory;
>  import org.apache.cxf.jaxrs.utils.HttpUtils;
>  import org.apache.cxf.jaxrs.utils.InjectionUtils;

Re: [cxf] branch master updated: [CXF-7532]REST on JMS transport can't handle the request message with text messageType

2017-10-19 Thread Sergey Beryozkin
Some JAX-RS providers check Reader or XMLStreamReader if InputStream is 
null.
But at the moment, Freeman, please do a bit of cleanup as agreed, and 
then we can check if the use ReaderInputStream can be avoided at all.


Sergey

On 19/10/17 19:47, Daniel Kulp wrote:

If using the TEXT stuff for JMS, it should remain as a Reader on the message if at 
all possible.  Converting from Reader to InputStream is not a trivial operation and 
does enact a performance penalty.   All of the SOAP pathways for JMS should be OK for 
use of a Reader so that we can avoid the entire String->UTF-8 bytes->chars 
round tripping.

Dan


On Oct 19, 2017, at 5:21 AM, ffang  wrote:


I modified the JMS transport part and set ReaderInputStream instead of Reader, 
running all tests now, will see what I can get.

If I run into any test failure, I will keep things as is, just clean up.
-
Freeman(Yue) Fang

Red Hat, Inc.
FuseSource is now part of Red Hat




On Oct 19, 2017, at 5:16 PM, Sergey Beryozkin  wrote:

If we assume that checking Reader can be useful in the general sense, then may 
be lets keep things as is, with the minor cleanup only...

Sergey
On 19/10/17 10:05, Sergey Beryozkin wrote:

Hi Freeman
Reader may likely need to be set too for SOAP, and I recall checking Reader 
somewhere else too (will double check now), but I thought may be the transport 
can set both Reader and InputStream, hmm, that is an extra instance though, may 
be lets start with moving ReaderInputStream to the core first ?
Sergey
On 19/10/17 09:59, ffang wrote:

Yeah, set ReaderInputStream instead of Reader for the JMS transport is a better 
solution. If no objection I will go this way.
-
Freeman(Yue) Fang

Red Hat, Inc.
FuseSource is now part of Red Hat




On Oct 19, 2017, at 4:50 PM, Sergey Beryozkin > wrote:

The other thing is, should JMS transport itself set ReaderInputStream as 
InputStream on the message, as opposed to patching the JAX-RS code in various 
places ?

Sergey
On 19/10/17 09:44, Sergey Beryozkin wrote:

Hi Freeman
Can you move ReaderInputStream to the CXF core where CachedInputStream and 
other IO utility code is located ?
Please also update the code which gets Reader.class and check it for null 
first, and also drop a comment re the JMS transport, checking the reader can 
make sense in all the cases...
Thanks, Sergey
On 19/10/17 04:16, ff...@apache.org  wrote:

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

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


The following commit(s) were added to refs/heads/master by this push:
  new 1d66475  [CXF-7532]REST on JMS transport can't handle the request 
message with text messageType
1d66475 is described below

commit 1d66475b4dea2a0031dcb1765e8e9fd08430ec9b
Author: Freeman Fang >
AuthorDate: Thu Oct 19 11:15:50 2017 +0800

 [CXF-7532]REST on JMS transport can't handle the request message with text 
messageType
---
  .../org/apache/cxf/jaxrs/impl/ResponseImpl.java|   5 +
  .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java |   6 +-
  .../apache/cxf/jaxrs/utils/ReaderInputStream.java  | 296 +
  .../apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java |  90 +++
  4 files changed, 396 insertions(+), 1 deletion(-)

diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
index e3a3acf..82f183a 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
@@ -58,6 +58,7 @@ import org.apache.cxf.jaxrs.provider.ProviderFactory;
  import org.apache.cxf.jaxrs.utils.HttpUtils;
  import org.apache.cxf.jaxrs.utils.InjectionUtils;
  import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.ReaderInputStream;
  import org.apache.cxf.message.Message;
  import org.apache.cxf.message.MessageUtils;
@@ -342,6 +343,10 @@ public final class ResponseImpl extends Response {
  entityStreamAvailable = entityStream != null;
  } else if (entity instanceof InputStream) {
  entityStream = InputStream.class.cast(entity);
+} else {
+Message inMessage = getResponseMessage();
+Reader reader = inMessage.getContent(Reader.class);
+entityStream = InputStream.class.cast(new 
ReaderInputStream(reader));
  }
  // we need to check for readers even if no IS is set - the readers 
may still do it
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index 0ef6565..509f76d 100644
--- 

Re: [cxf] branch master updated: [CXF-7532]REST on JMS transport can't handle the request message with text messageType

2017-10-19 Thread Daniel Kulp
If using the TEXT stuff for JMS, it should remain as a Reader on the message if 
at all possible.  Converting from Reader to InputStream is not a trivial 
operation and does enact a performance penalty.   All of the SOAP pathways for 
JMS should be OK for use of a Reader so that we can avoid the entire 
String->UTF-8 bytes->chars round tripping.  

Dan


On Oct 19, 2017, at 5:21 AM, ffang  wrote:
> 
> I modified the JMS transport part and set ReaderInputStream instead of 
> Reader, running all tests now, will see what I can get.
> 
> If I run into any test failure, I will keep things as is, just clean up.
> -
> Freeman(Yue) Fang
> 
> Red Hat, Inc. 
> FuseSource is now part of Red Hat
> 
> 
> 
>> On Oct 19, 2017, at 5:16 PM, Sergey Beryozkin  wrote:
>> 
>> If we assume that checking Reader can be useful in the general sense, then 
>> may be lets keep things as is, with the minor cleanup only...
>> 
>> Sergey
>> On 19/10/17 10:05, Sergey Beryozkin wrote:
>>> Hi Freeman
>>> Reader may likely need to be set too for SOAP, and I recall checking Reader 
>>> somewhere else too (will double check now), but I thought may be the 
>>> transport can set both Reader and InputStream, hmm, that is an extra 
>>> instance though, may be lets start with moving ReaderInputStream to the 
>>> core first ?
>>> Sergey
>>> On 19/10/17 09:59, ffang wrote:
 Yeah, set ReaderInputStream instead of Reader for the JMS transport is a 
 better solution. If no objection I will go this way.
 -
 Freeman(Yue) Fang
 
 Red Hat, Inc.
 FuseSource is now part of Red Hat
 
 
 
> On Oct 19, 2017, at 4:50 PM, Sergey Beryozkin  > wrote:
> 
> The other thing is, should JMS transport itself set ReaderInputStream as 
> InputStream on the message, as opposed to patching the JAX-RS code in 
> various places ?
> 
> Sergey
> On 19/10/17 09:44, Sergey Beryozkin wrote:
>> Hi Freeman
>> Can you move ReaderInputStream to the CXF core where CachedInputStream 
>> and other IO utility code is located ?
>> Please also update the code which gets Reader.class and check it for 
>> null first, and also drop a comment re the JMS transport, checking the 
>> reader can make sense in all the cases...
>> Thanks, Sergey
>> On 19/10/17 04:16, ff...@apache.org  wrote:
>>> This is an automated email from the ASF dual-hosted git repository.
>>> 
>>> ffang pushed a commit to branch master
>>> in repository https://gitbox.apache.org/repos/asf/cxf.git
>>> 
>>> 
>>> The following commit(s) were added to refs/heads/master by this push:
>>>  new 1d66475  [CXF-7532]REST on JMS transport can't handle the 
>>> request message with text messageType
>>> 1d66475 is described below
>>> 
>>> commit 1d66475b4dea2a0031dcb1765e8e9fd08430ec9b
>>> Author: Freeman Fang >> >
>>> AuthorDate: Thu Oct 19 11:15:50 2017 +0800
>>> 
>>> [CXF-7532]REST on JMS transport can't handle the request message 
>>> with text messageType
>>> ---
>>>  .../org/apache/cxf/jaxrs/impl/ResponseImpl.java|   5 +
>>>  .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java |   6 +-
>>>  .../apache/cxf/jaxrs/utils/ReaderInputStream.java  | 296 
>>> +
>>>  .../apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java |  90 +++
>>>  4 files changed, 396 insertions(+), 1 deletion(-)
>>> 
>>> diff --git 
>>> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>>  
>>> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>>  
>>> index e3a3acf..82f183a 100644
>>> --- 
>>> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>>  
>>> +++ 
>>> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>>  
>>> @@ -58,6 +58,7 @@ import org.apache.cxf.jaxrs.provider.ProviderFactory;
>>>  import org.apache.cxf.jaxrs.utils.HttpUtils;
>>>  import org.apache.cxf.jaxrs.utils.InjectionUtils;
>>>  import org.apache.cxf.jaxrs.utils.JAXRSUtils;
>>> +import org.apache.cxf.jaxrs.utils.ReaderInputStream;
>>>  import org.apache.cxf.message.Message;
>>>  import org.apache.cxf.message.MessageUtils;
>>> @@ -342,6 +343,10 @@ public final class ResponseImpl extends Response {
>>>  entityStreamAvailable = entityStream != null;
>>>  } else if (entity instanceof InputStream) {
>>>  entityStream = InputStream.class.cast(entity);
>>> +} else {
>>> +Message inMessage = getResponseMessage();
>>> +Reader reader = inMessage.getContent(Reader.class);
>>> +

Re: [cxf] branch master updated: [CXF-7532]REST on JMS transport can't handle the request message with text messageType

2017-10-19 Thread ffang
I modified the JMS transport part and set ReaderInputStream instead of Reader, 
running all tests now, will see what I can get.

If I run into any test failure, I will keep things as is, just clean up.
-
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat



> On Oct 19, 2017, at 5:16 PM, Sergey Beryozkin  wrote:
> 
> If we assume that checking Reader can be useful in the general sense, then 
> may be lets keep things as is, with the minor cleanup only...
> 
> Sergey
> On 19/10/17 10:05, Sergey Beryozkin wrote:
>> Hi Freeman
>> Reader may likely need to be set too for SOAP, and I recall checking Reader 
>> somewhere else too (will double check now), but I thought may be the 
>> transport can set both Reader and InputStream, hmm, that is an extra 
>> instance though, may be lets start with moving ReaderInputStream to the core 
>> first ?
>> Sergey
>> On 19/10/17 09:59, ffang wrote:
>>> Yeah, set ReaderInputStream instead of Reader for the JMS transport is a 
>>> better solution. If no objection I will go this way.
>>> -
>>> Freeman(Yue) Fang
>>> 
>>> Red Hat, Inc.
>>> FuseSource is now part of Red Hat
>>> 
>>> 
>>> 
 On Oct 19, 2017, at 4:50 PM, Sergey Beryozkin > wrote:
 
 The other thing is, should JMS transport itself set ReaderInputStream as 
 InputStream on the message, as opposed to patching the JAX-RS code in 
 various places ?
 
 Sergey
 On 19/10/17 09:44, Sergey Beryozkin wrote:
> Hi Freeman
> Can you move ReaderInputStream to the CXF core where CachedInputStream 
> and other IO utility code is located ?
> Please also update the code which gets Reader.class and check it for null 
> first, and also drop a comment re the JMS transport, checking the reader 
> can make sense in all the cases...
> Thanks, Sergey
> On 19/10/17 04:16, ff...@apache.org  wrote:
>> This is an automated email from the ASF dual-hosted git repository.
>> 
>> ffang pushed a commit to branch master
>> in repository https://gitbox.apache.org/repos/asf/cxf.git
>> 
>> 
>> The following commit(s) were added to refs/heads/master by this push:
>>   new 1d66475  [CXF-7532]REST on JMS transport can't handle the 
>> request message with text messageType
>> 1d66475 is described below
>> 
>> commit 1d66475b4dea2a0031dcb1765e8e9fd08430ec9b
>> Author: Freeman Fang > >
>> AuthorDate: Thu Oct 19 11:15:50 2017 +0800
>> 
>>  [CXF-7532]REST on JMS transport can't handle the request message 
>> with text messageType
>> ---
>>   .../org/apache/cxf/jaxrs/impl/ResponseImpl.java|   5 +
>>   .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java |   6 +-
>>   .../apache/cxf/jaxrs/utils/ReaderInputStream.java  | 296 
>> +
>>   .../apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java |  90 +++
>>   4 files changed, 396 insertions(+), 1 deletion(-)
>> 
>> diff --git 
>> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>  
>> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>  
>> index e3a3acf..82f183a 100644
>> --- 
>> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>  
>> +++ 
>> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>  
>> @@ -58,6 +58,7 @@ import org.apache.cxf.jaxrs.provider.ProviderFactory;
>>   import org.apache.cxf.jaxrs.utils.HttpUtils;
>>   import org.apache.cxf.jaxrs.utils.InjectionUtils;
>>   import org.apache.cxf.jaxrs.utils.JAXRSUtils;
>> +import org.apache.cxf.jaxrs.utils.ReaderInputStream;
>>   import org.apache.cxf.message.Message;
>>   import org.apache.cxf.message.MessageUtils;
>> @@ -342,6 +343,10 @@ public final class ResponseImpl extends Response {
>>   entityStreamAvailable = entityStream != null;
>>   } else if (entity instanceof InputStream) {
>>   entityStream = InputStream.class.cast(entity);
>> +} else {
>> +Message inMessage = getResponseMessage();
>> +Reader reader = inMessage.getContent(Reader.class);
>> +entityStream = InputStream.class.cast(new 
>> ReaderInputStream(reader));
>>   }
>>   // we need to check for readers even if no IS is set - the 
>> readers may still do it
>> diff --git 
>> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
>>  
>> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
>>  
>> index 0ef6565..509f76d 100644
>> --- 
>> 

Re: [cxf] branch master updated: [CXF-7532]REST on JMS transport can't handle the request message with text messageType

2017-10-19 Thread Sergey Beryozkin
If we assume that checking Reader can be useful in the general sense, 
then may be lets keep things as is, with the minor cleanup only...


Sergey
On 19/10/17 10:05, Sergey Beryozkin wrote:

Hi Freeman

Reader may likely need to be set too for SOAP, and I recall checking 
Reader somewhere else too (will double check now), but I thought may be 
the transport can set both Reader and InputStream, hmm, that is an extra 
instance though, may be lets start with moving ReaderInputStream to the 
core first ?


Sergey
On 19/10/17 09:59, ffang wrote:
Yeah, set ReaderInputStream instead of Reader for the JMS transport is 
a better solution. If no objection I will go this way.

-
Freeman(Yue) Fang

Red Hat, Inc.
FuseSource is now part of Red Hat



On Oct 19, 2017, at 4:50 PM, Sergey Beryozkin > wrote:


The other thing is, should JMS transport itself set ReaderInputStream 
as InputStream on the message, as opposed to patching the JAX-RS code 
in various places ?


Sergey
On 19/10/17 09:44, Sergey Beryozkin wrote:

Hi Freeman
Can you move ReaderInputStream to the CXF core where 
CachedInputStream and other IO utility code is located ?
Please also update the code which gets Reader.class and check it for 
null first, and also drop a comment re the JMS transport, checking 
the reader can make sense in all the cases...

Thanks, Sergey
On 19/10/17 04:16, ff...@apache.org  wrote:

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

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


The following commit(s) were added to refs/heads/master by this push:
  new 1d66475  [CXF-7532]REST on JMS transport can't handle the 
request message with text messageType

1d66475 is described below

commit 1d66475b4dea2a0031dcb1765e8e9fd08430ec9b
Author: Freeman Fang >

AuthorDate: Thu Oct 19 11:15:50 2017 +0800

 [CXF-7532]REST on JMS transport can't handle the request 
message with text messageType

---
  .../org/apache/cxf/jaxrs/impl/ResponseImpl.java    |   5 +
  .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java |   6 +-
  .../apache/cxf/jaxrs/utils/ReaderInputStream.java  | 296 
+

  .../apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java |  90 +++
  4 files changed, 396 insertions(+), 1 deletion(-)

diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 


index e3a3acf..82f183a 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 

+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 

@@ -58,6 +58,7 @@ import 
org.apache.cxf.jaxrs.provider.ProviderFactory;

  import org.apache.cxf.jaxrs.utils.HttpUtils;
  import org.apache.cxf.jaxrs.utils.InjectionUtils;
  import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.ReaderInputStream;
  import org.apache.cxf.message.Message;
  import org.apache.cxf.message.MessageUtils;
@@ -342,6 +343,10 @@ public final class ResponseImpl extends 
Response {

  entityStreamAvailable = entityStream != null;
  } else if (entity instanceof InputStream) {
  entityStream = InputStream.class.cast(entity);
+    } else {
+    Message inMessage = getResponseMessage();
+    Reader reader = inMessage.getContent(Reader.class);
+    entityStream = InputStream.class.cast(new 
ReaderInputStream(reader));

  }
  // we need to check for readers even if no IS is set - 
the readers may still do it
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 


index 0ef6565..509f76d 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 

+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 


@@ -832,7 +832,11 @@ public final class JAXRSUtils {
 OperationResourceInfo 
ori)

  throws IOException, WebApplicationException {
  InputStream is = message.getContent(InputStream.class);
-
+    if (is == null) {
+    //may use the jms transport so check the Reader;
+    Reader reader = message.getContent(Reader.class);
+    is = new ReaderInputStream(reader);
+    }
  if (parameter.getType() == ParameterType.REQUEST_BODY) {
  if (parameterClass == AsyncResponse.class) {
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java 


new file mode 100644
index 000..c7b142e
--- /dev/null
+++ 

Re: [cxf] branch master updated: [CXF-7532]REST on JMS transport can't handle the request message with text messageType

2017-10-19 Thread ffang
Sure, will do!
-
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat



> On Oct 19, 2017, at 5:05 PM, Sergey Beryozkin  wrote:
> 
> Hi Freeman
> 
> Reader may likely need to be set too for SOAP, and I recall checking Reader 
> somewhere else too (will double check now), but I thought may be the 
> transport can set both Reader and InputStream, hmm, that is an extra instance 
> though, may be lets start with moving ReaderInputStream to the core first ?
> 
> Sergey
> On 19/10/17 09:59, ffang wrote:
>> Yeah, set ReaderInputStream instead of Reader for the JMS transport is a 
>> better solution. If no objection I will go this way.
>> -
>> Freeman(Yue) Fang
>> Red Hat, Inc.
>> FuseSource is now part of Red Hat
>>> On Oct 19, 2017, at 4:50 PM, Sergey Beryozkin >> > wrote:
>>> 
>>> The other thing is, should JMS transport itself set ReaderInputStream as 
>>> InputStream on the message, as opposed to patching the JAX-RS code in 
>>> various places ?
>>> 
>>> Sergey
>>> On 19/10/17 09:44, Sergey Beryozkin wrote:
 Hi Freeman
 Can you move ReaderInputStream to the CXF core where CachedInputStream and 
 other IO utility code is located ?
 Please also update the code which gets Reader.class and check it for null 
 first, and also drop a comment re the JMS transport, checking the reader 
 can make sense in all the cases...
 Thanks, Sergey
 On 19/10/17 04:16, ff...@apache.org  wrote:
> This is an automated email from the ASF dual-hosted git repository.
> 
> ffang pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/cxf.git
> 
> 
> The following commit(s) were added to refs/heads/master by this push:
>   new 1d66475  [CXF-7532]REST on JMS transport can't handle the 
> request message with text messageType
> 1d66475 is described below
> 
> commit 1d66475b4dea2a0031dcb1765e8e9fd08430ec9b
> Author: Freeman Fang  >
> AuthorDate: Thu Oct 19 11:15:50 2017 +0800
> 
>  [CXF-7532]REST on JMS transport can't handle the request message 
> with text messageType
> ---
>   .../org/apache/cxf/jaxrs/impl/ResponseImpl.java|   5 +
>   .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java |   6 +-
>   .../apache/cxf/jaxrs/utils/ReaderInputStream.java  | 296 
> +
>   .../apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java |  90 +++
>   4 files changed, 396 insertions(+), 1 deletion(-)
> 
> diff --git 
> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>  
> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>  
> index e3a3acf..82f183a 100644
> --- 
> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>  
> +++ 
> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>  
> @@ -58,6 +58,7 @@ import org.apache.cxf.jaxrs.provider.ProviderFactory;
>   import org.apache.cxf.jaxrs.utils.HttpUtils;
>   import org.apache.cxf.jaxrs.utils.InjectionUtils;
>   import org.apache.cxf.jaxrs.utils.JAXRSUtils;
> +import org.apache.cxf.jaxrs.utils.ReaderInputStream;
>   import org.apache.cxf.message.Message;
>   import org.apache.cxf.message.MessageUtils;
> @@ -342,6 +343,10 @@ public final class ResponseImpl extends Response {
>   entityStreamAvailable = entityStream != null;
>   } else if (entity instanceof InputStream) {
>   entityStream = InputStream.class.cast(entity);
> +} else {
> +Message inMessage = getResponseMessage();
> +Reader reader = inMessage.getContent(Reader.class);
> +entityStream = InputStream.class.cast(new 
> ReaderInputStream(reader));
>   }
>   // we need to check for readers even if no IS is set - the 
> readers may still do it
> diff --git 
> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
>  
> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
>  
> index 0ef6565..509f76d 100644
> --- 
> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
>  
> +++ 
> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
>  
> @@ -832,7 +832,11 @@ public final class JAXRSUtils {
>  OperationResourceInfo ori)
>   throws IOException, WebApplicationException {
>   InputStream is = message.getContent(InputStream.class);
> -
> +if (is == null) {
> +//may use the jms transport so check the 

Re: [cxf] branch master updated: [CXF-7532]REST on JMS transport can't handle the request message with text messageType

2017-10-19 Thread Sergey Beryozkin

Hi Freeman

Reader may likely need to be set too for SOAP, and I recall checking 
Reader somewhere else too (will double check now), but I thought may be 
the transport can set both Reader and InputStream, hmm, that is an extra 
instance though, may be lets start with moving ReaderInputStream to the 
core first ?


Sergey
On 19/10/17 09:59, ffang wrote:
Yeah, set ReaderInputStream instead of Reader for the JMS transport is a 
better solution. If no objection I will go this way.

-
Freeman(Yue) Fang

Red Hat, Inc.
FuseSource is now part of Red Hat



On Oct 19, 2017, at 4:50 PM, Sergey Beryozkin > wrote:


The other thing is, should JMS transport itself set ReaderInputStream 
as InputStream on the message, as opposed to patching the JAX-RS code 
in various places ?


Sergey
On 19/10/17 09:44, Sergey Beryozkin wrote:

Hi Freeman
Can you move ReaderInputStream to the CXF core where 
CachedInputStream and other IO utility code is located ?
Please also update the code which gets Reader.class and check it for 
null first, and also drop a comment re the JMS transport, checking 
the reader can make sense in all the cases...

Thanks, Sergey
On 19/10/17 04:16, ff...@apache.org  wrote:

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

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


The following commit(s) were added to refs/heads/master by this push:
  new 1d66475  [CXF-7532]REST on JMS transport can't handle the 
request message with text messageType

1d66475 is described below

commit 1d66475b4dea2a0031dcb1765e8e9fd08430ec9b
Author: Freeman Fang >

AuthorDate: Thu Oct 19 11:15:50 2017 +0800

 [CXF-7532]REST on JMS transport can't handle the request 
message with text messageType

---
  .../org/apache/cxf/jaxrs/impl/ResponseImpl.java    |   5 +
  .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java |   6 +-
  .../apache/cxf/jaxrs/utils/ReaderInputStream.java  | 296 
+

  .../apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java |  90 +++
  4 files changed, 396 insertions(+), 1 deletion(-)

diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 


index e3a3acf..82f183a 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 

+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 


@@ -58,6 +58,7 @@ import org.apache.cxf.jaxrs.provider.ProviderFactory;
  import org.apache.cxf.jaxrs.utils.HttpUtils;
  import org.apache.cxf.jaxrs.utils.InjectionUtils;
  import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.ReaderInputStream;
  import org.apache.cxf.message.Message;
  import org.apache.cxf.message.MessageUtils;
@@ -342,6 +343,10 @@ public final class ResponseImpl extends Response {
  entityStreamAvailable = entityStream != null;
  } else if (entity instanceof InputStream) {
  entityStream = InputStream.class.cast(entity);
+    } else {
+    Message inMessage = getResponseMessage();
+    Reader reader = inMessage.getContent(Reader.class);
+    entityStream = InputStream.class.cast(new 
ReaderInputStream(reader));

  }
  // we need to check for readers even if no IS is set - the 
readers may still do it
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 


index 0ef6565..509f76d 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 

+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 


@@ -832,7 +832,11 @@ public final class JAXRSUtils {
 OperationResourceInfo ori)
  throws IOException, WebApplicationException {
  InputStream is = message.getContent(InputStream.class);
-
+    if (is == null) {
+    //may use the jms transport so check the Reader;
+    Reader reader = message.getContent(Reader.class);
+    is = new ReaderInputStream(reader);
+    }
  if (parameter.getType() == ParameterType.REQUEST_BODY) {
  if (parameterClass == AsyncResponse.class) {
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java 


new file mode 100644
index 000..c7b142e
--- /dev/null
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java 


@@ -0,0 +1,296 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE 

Re: [cxf] branch master updated: [CXF-7532]REST on JMS transport can't handle the request message with text messageType

2017-10-19 Thread ffang
Yeah, set ReaderInputStream instead of Reader for the JMS transport is a better 
solution. If no objection I will go this way.
-
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat



> On Oct 19, 2017, at 4:50 PM, Sergey Beryozkin  wrote:
> 
> The other thing is, should JMS transport itself set ReaderInputStream as 
> InputStream on the message, as opposed to patching the JAX-RS code in various 
> places ?
> 
> Sergey
> On 19/10/17 09:44, Sergey Beryozkin wrote:
>> Hi Freeman
>> Can you move ReaderInputStream to the CXF core where CachedInputStream and 
>> other IO utility code is located ?
>> Please also update the code which gets Reader.class and check it for null 
>> first, and also drop a comment re the JMS transport, checking the reader can 
>> make sense in all the cases...
>> Thanks, Sergey
>> On 19/10/17 04:16, ff...@apache.org wrote:
>>> This is an automated email from the ASF dual-hosted git repository.
>>> 
>>> ffang pushed a commit to branch master
>>> in repository https://gitbox.apache.org/repos/asf/cxf.git
>>> 
>>> 
>>> The following commit(s) were added to refs/heads/master by this push:
>>>   new 1d66475  [CXF-7532]REST on JMS transport can't handle the request 
>>> message with text messageType
>>> 1d66475 is described below
>>> 
>>> commit 1d66475b4dea2a0031dcb1765e8e9fd08430ec9b
>>> Author: Freeman Fang 
>>> AuthorDate: Thu Oct 19 11:15:50 2017 +0800
>>> 
>>>  [CXF-7532]REST on JMS transport can't handle the request message with 
>>> text messageType
>>> ---
>>>   .../org/apache/cxf/jaxrs/impl/ResponseImpl.java|   5 +
>>>   .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java |   6 +-
>>>   .../apache/cxf/jaxrs/utils/ReaderInputStream.java  | 296 
>>> +
>>>   .../apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java |  90 +++
>>>   4 files changed, 396 insertions(+), 1 deletion(-)
>>> 
>>> diff --git 
>>> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>>  
>>> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>>  
>>> index e3a3acf..82f183a 100644
>>> --- 
>>> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>>  
>>> +++ 
>>> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
>>>  
>>> @@ -58,6 +58,7 @@ import org.apache.cxf.jaxrs.provider.ProviderFactory;
>>>   import org.apache.cxf.jaxrs.utils.HttpUtils;
>>>   import org.apache.cxf.jaxrs.utils.InjectionUtils;
>>>   import org.apache.cxf.jaxrs.utils.JAXRSUtils;
>>> +import org.apache.cxf.jaxrs.utils.ReaderInputStream;
>>>   import org.apache.cxf.message.Message;
>>>   import org.apache.cxf.message.MessageUtils;
>>> @@ -342,6 +343,10 @@ public final class ResponseImpl extends Response {
>>>   entityStreamAvailable = entityStream != null;
>>>   } else if (entity instanceof InputStream) {
>>>   entityStream = InputStream.class.cast(entity);
>>> +} else {
>>> +Message inMessage = getResponseMessage();
>>> +Reader reader = inMessage.getContent(Reader.class);
>>> +entityStream = InputStream.class.cast(new 
>>> ReaderInputStream(reader));
>>>   }
>>>   // we need to check for readers even if no IS is set - the 
>>> readers may still do it
>>> diff --git 
>>> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
>>>  
>>> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
>>>  
>>> index 0ef6565..509f76d 100644
>>> --- 
>>> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
>>>  
>>> +++ 
>>> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
>>>  
>>> @@ -832,7 +832,11 @@ public final class JAXRSUtils {
>>>  OperationResourceInfo ori)
>>>   throws IOException, WebApplicationException {
>>>   InputStream is = message.getContent(InputStream.class);
>>> -
>>> +if (is == null) {
>>> +//may use the jms transport so check the Reader;
>>> +Reader reader = message.getContent(Reader.class);
>>> +is = new ReaderInputStream(reader);
>>> +}
>>>   if (parameter.getType() == ParameterType.REQUEST_BODY) {
>>>   if (parameterClass == AsyncResponse.class) {
>>> diff --git 
>>> a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java
>>>  
>>> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java
>>>  
>>> new file mode 100644
>>> index 000..c7b142e
>>> --- /dev/null
>>> +++ 
>>> b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java
>>>  
>>> @@ -0,0 +1,296 @@
>>> +/**
>>> + * Licensed to the Apache Software Foundation (ASF) under one
>>> + * or more contributor license agreements. See the NOTICE file
>>> + * distributed with this work 

Re: [cxf] branch master updated: [CXF-7532]REST on JMS transport can't handle the request message with text messageType

2017-10-19 Thread Sergey Beryozkin
The other thing is, should JMS transport itself set ReaderInputStream as 
InputStream on the message, as opposed to patching the JAX-RS code in 
various places ?


Sergey
On 19/10/17 09:44, Sergey Beryozkin wrote:

Hi Freeman

Can you move ReaderInputStream to the CXF core where CachedInputStream 
and other IO utility code is located ?


Please also update the code which gets Reader.class and check it for 
null first, and also drop a comment re the JMS transport, checking the 
reader can make sense in all the cases...


Thanks, Sergey
On 19/10/17 04:16, ff...@apache.org wrote:

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

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


The following commit(s) were added to refs/heads/master by this push:
  new 1d66475  [CXF-7532]REST on JMS transport can't handle the 
request message with text messageType

1d66475 is described below

commit 1d66475b4dea2a0031dcb1765e8e9fd08430ec9b
Author: Freeman Fang 
AuthorDate: Thu Oct 19 11:15:50 2017 +0800

 [CXF-7532]REST on JMS transport can't handle the request message 
with text messageType

---
  .../org/apache/cxf/jaxrs/impl/ResponseImpl.java    |   5 +
  .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java |   6 +-
  .../apache/cxf/jaxrs/utils/ReaderInputStream.java  | 296 
+

  .../apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java |  90 +++
  4 files changed, 396 insertions(+), 1 deletion(-)

diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 


index e3a3acf..82f183a 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 

+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 


@@ -58,6 +58,7 @@ import org.apache.cxf.jaxrs.provider.ProviderFactory;
  import org.apache.cxf.jaxrs.utils.HttpUtils;
  import org.apache.cxf.jaxrs.utils.InjectionUtils;
  import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.ReaderInputStream;
  import org.apache.cxf.message.Message;
  import org.apache.cxf.message.MessageUtils;
@@ -342,6 +343,10 @@ public final class ResponseImpl extends Response {
  entityStreamAvailable = entityStream != null;
  } else if (entity instanceof InputStream) {
  entityStream = InputStream.class.cast(entity);
+    } else {
+    Message inMessage = getResponseMessage();
+    Reader reader = inMessage.getContent(Reader.class);
+    entityStream = InputStream.class.cast(new 
ReaderInputStream(reader));

  }
  // we need to check for readers even if no IS is set - the 
readers may still do it
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 


index 0ef6565..509f76d 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 

+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 


@@ -832,7 +832,11 @@ public final class JAXRSUtils {
 OperationResourceInfo ori)
  throws IOException, WebApplicationException {
  InputStream is = message.getContent(InputStream.class);
-
+    if (is == null) {
+    //may use the jms transport so check the Reader;
+    Reader reader = message.getContent(Reader.class);
+    is = new ReaderInputStream(reader);
+    }
  if (parameter.getType() == ParameterType.REQUEST_BODY) {
  if (parameterClass == AsyncResponse.class) {
diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java 


new file mode 100644
index 000..c7b142e
--- /dev/null
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java 


@@ -0,0 +1,296 @@
+/**
+ * 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.jaxrs.utils;
+

Re: [cxf] branch master updated: [CXF-7532]REST on JMS transport can't handle the request message with text messageType

2017-10-19 Thread Sergey Beryozkin

Hi Freeman

Can you move ReaderInputStream to the CXF core where CachedInputStream 
and other IO utility code is located ?


Please also update the code which gets Reader.class and check it for 
null first, and also drop a comment re the JMS transport, checking the 
reader can make sense in all the cases...


Thanks, Sergey
On 19/10/17 04:16, ff...@apache.org wrote:

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

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


The following commit(s) were added to refs/heads/master by this push:
  new 1d66475  [CXF-7532]REST on JMS transport can't handle the request 
message with text messageType
1d66475 is described below

commit 1d66475b4dea2a0031dcb1765e8e9fd08430ec9b
Author: Freeman Fang 
AuthorDate: Thu Oct 19 11:15:50 2017 +0800

 [CXF-7532]REST on JMS transport can't handle the request message with text 
messageType
---
  .../org/apache/cxf/jaxrs/impl/ResponseImpl.java|   5 +
  .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java |   6 +-
  .../apache/cxf/jaxrs/utils/ReaderInputStream.java  | 296 +
  .../apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java |  90 +++
  4 files changed, 396 insertions(+), 1 deletion(-)

diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
index e3a3acf..82f183a 100644
--- 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
@@ -58,6 +58,7 @@ import org.apache.cxf.jaxrs.provider.ProviderFactory;
  import org.apache.cxf.jaxrs.utils.HttpUtils;
  import org.apache.cxf.jaxrs.utils.InjectionUtils;
  import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.ReaderInputStream;
  import org.apache.cxf.message.Message;
  import org.apache.cxf.message.MessageUtils;
  
@@ -342,6 +343,10 @@ public final class ResponseImpl extends Response {

  entityStreamAvailable = entityStream != null;
  } else if (entity instanceof InputStream) {
  entityStream = InputStream.class.cast(entity);
+} else {
+Message inMessage = getResponseMessage();
+Reader reader = inMessage.getContent(Reader.class);
+entityStream = InputStream.class.cast(new 
ReaderInputStream(reader));
  }
  
  // we need to check for readers even if no IS is set - the readers may still do it

diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index 0ef6565..509f76d 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -832,7 +832,11 @@ public final class JAXRSUtils {
 OperationResourceInfo ori)
  throws IOException, WebApplicationException {
  InputStream is = message.getContent(InputStream.class);
-
+if (is == null) {
+//may use the jms transport so check the Reader;
+Reader reader = message.getContent(Reader.class);
+is = new ReaderInputStream(reader);
+}
  if (parameter.getType() == ParameterType.REQUEST_BODY) {
  
  if (parameterClass == AsyncResponse.class) {

diff --git 
a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java
 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java
new file mode 100644
index 000..c7b142e
--- /dev/null
+++ 
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ReaderInputStream.java
@@ -0,0 +1,296 @@
+/**
+ * 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.jaxrs.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+import