You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Christophe Darville <cd...@internetvista.com> on 2022/03/17 13:26:06 UTC
Class SimpleResponseConsumer is final
Hi,
In HttpClient5, the class org.apache.hc.client5.http.async.methods.SimpleResponseConsumer is final. Would it be possible to make this class not final ? I would like to extend it so I can override the buildResult method.
Regards,
Christophe
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Class SimpleResponseConsumer is final
Posted by Kalnichevski Oleg <ol...@ok2consulting.com>.
On 3/17/2022 5:48 PM, Christophe Darville wrote:
> I just wanted to use SimpleAsyncEntityConsumer to avoid to create my own class that will do basically the same job. But it is ok, I will create my own “SimpleAsyncEntityConsumer”
>
> Regards,
> Christophe
>
If you want to use SimpleAsyncEntityConsumer in production you are doing
something very wrong.
Oleg
>> On 17 Mar 2022, at 17:41, Oleg Kalnichevski <ol...@apache.org> wrote:
>>
>> On Thu, 2022-03-17 at 17:23 +0100, Christophe Darville wrote:
>>> Hi Oleg,
>>>
>>> Thank you for your answer. Before sending my post, I first tried to
>>> extends AbstractAsyncResponseConsumer like in your sample code but
>>> unfortunately the class SimpleAsyncEntityConsumer used in create() is
>>> not public and I cannot take advantage of that class. This is why, in
>>> my case, extending SimpleResponseConsumer would do the trick (or
>>> making SimpleAsyncEntityConsumer public …)
>>>
>>> Regards,
>>> Christophe
>>
>> I am not sure I understand the problem.
>> Use AbstractBinAsyncEntityConsumer or
>> AbstractCharAsyncEntityConsumer instead.
>>
>> Simple* class variety are effectively internal I do not want to open
>> them up. They are not supposed to be used in real productive code.
>>
>> Oleg
>>
>>
>>>
>>>> On 17 Mar 2022, at 16:56, Oleg Kalnichevski <ol...@apache.org>
>>>> wrote:
>>>>
>>>> Please extend AbstractAsyncResponseConsumer instead
>>>>
>>>> ----
>>>>
>>>> public class MyResponseConsumer extends
>>>> AbstractAsyncResponseConsumer<SimpleHttpResponse, byte[]> {
>>>>
>>>> MyResponseConsumer(final AsyncEntityConsumer<byte[]>
>>>> entityConsumer) {
>>>> super(entityConsumer);
>>>> }
>>>>
>>>> public static SimpleResponseConsumer create() {
>>>> return new SimpleResponseConsumer(new
>>>> SimpleAsyncEntityConsumer());
>>>> }
>>>>
>>>> @Override
>>>> public void informationResponse(final HttpResponse response,
>>>> final HttpContext context) throws HttpException, IOException {
>>>> }
>>>>
>>>> @Override
>>>> protected SimpleHttpResponse buildResult(final HttpResponse
>>>> response, final byte[] entity, final ContentType contentType) {
>>>> final SimpleHttpResponse simpleResponse =
>>>> SimpleHttpResponse.copy(response);
>>>> if (entity != null) {
>>>> simpleResponse.setBody(entity, contentType);
>>>> }
>>>> return simpleResponse;
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> On Thu, 2022-03-17 at 14:26 +0100, Christophe Darville wrote:
>>>>> Hi,
>>>>>
>>>>> In HttpClient5, the class
>>>>> org.apache.hc.client5.http.async.methods.SimpleResponseConsumer
>>>>> is
>>>>> final. Would it be possible to make this class not final ? I
>>>>> would
>>>>> like to extend it so I can override the buildResult method.
>>>>>
>>>>> Regards,
>>>>> Christophe
>>>>> ---------------------------------------------------------------
>>>>> ------
>>>>> To unsubscribe, e-mail:
>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>> For additional commands, e-mail:
>>>>> httpclient-users-help@hc.apache.org
>>>>>
>>>>
>>>> -----------------------------------------------------------------
>>>> ----
>>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>>> For additional commands, e-mail:
>>>> httpclient-users-help@hc.apache.org
>>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Class SimpleResponseConsumer is final
Posted by Christophe Darville <cd...@internetvista.com>.
I just wanted to use SimpleAsyncEntityConsumer to avoid to create my own class that will do basically the same job. But it is ok, I will create my own “SimpleAsyncEntityConsumer”
Regards,
Christophe
> On 17 Mar 2022, at 17:41, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> On Thu, 2022-03-17 at 17:23 +0100, Christophe Darville wrote:
>> Hi Oleg,
>>
>> Thank you for your answer. Before sending my post, I first tried to
>> extends AbstractAsyncResponseConsumer like in your sample code but
>> unfortunately the class SimpleAsyncEntityConsumer used in create() is
>> not public and I cannot take advantage of that class. This is why, in
>> my case, extending SimpleResponseConsumer would do the trick (or
>> making SimpleAsyncEntityConsumer public …)
>>
>> Regards,
>> Christophe
>
> I am not sure I understand the problem.
> Use AbstractBinAsyncEntityConsumer or
> AbstractCharAsyncEntityConsumer instead.
>
> Simple* class variety are effectively internal I do not want to open
> them up. They are not supposed to be used in real productive code.
>
> Oleg
>
>
>>
>>> On 17 Mar 2022, at 16:56, Oleg Kalnichevski <ol...@apache.org>
>>> wrote:
>>>
>>> Please extend AbstractAsyncResponseConsumer instead
>>>
>>> ----
>>>
>>> public class MyResponseConsumer extends
>>> AbstractAsyncResponseConsumer<SimpleHttpResponse, byte[]> {
>>>
>>> MyResponseConsumer(final AsyncEntityConsumer<byte[]>
>>> entityConsumer) {
>>> super(entityConsumer);
>>> }
>>>
>>> public static SimpleResponseConsumer create() {
>>> return new SimpleResponseConsumer(new
>>> SimpleAsyncEntityConsumer());
>>> }
>>>
>>> @Override
>>> public void informationResponse(final HttpResponse response,
>>> final HttpContext context) throws HttpException, IOException {
>>> }
>>>
>>> @Override
>>> protected SimpleHttpResponse buildResult(final HttpResponse
>>> response, final byte[] entity, final ContentType contentType) {
>>> final SimpleHttpResponse simpleResponse =
>>> SimpleHttpResponse.copy(response);
>>> if (entity != null) {
>>> simpleResponse.setBody(entity, contentType);
>>> }
>>> return simpleResponse;
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> On Thu, 2022-03-17 at 14:26 +0100, Christophe Darville wrote:
>>>> Hi,
>>>>
>>>> In HttpClient5, the class
>>>> org.apache.hc.client5.http.async.methods.SimpleResponseConsumer
>>>> is
>>>> final. Would it be possible to make this class not final ? I
>>>> would
>>>> like to extend it so I can override the buildResult method.
>>>>
>>>> Regards,
>>>> Christophe
>>>> ---------------------------------------------------------------
>>>> ------
>>>> To unsubscribe, e-mail:
>>>> httpclient-users-unsubscribe@hc.apache.org
>>>> For additional commands, e-mail:
>>>> httpclient-users-help@hc.apache.org
>>>>
>>>
>>> -----------------------------------------------------------------
>>> ----
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> For additional commands, e-mail:
>>> httpclient-users-help@hc.apache.org
>>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Class SimpleResponseConsumer is final
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2022-03-17 at 17:23 +0100, Christophe Darville wrote:
> Hi Oleg,
>
> Thank you for your answer. Before sending my post, I first tried to
> extends AbstractAsyncResponseConsumer like in your sample code but
> unfortunately the class SimpleAsyncEntityConsumer used in create() is
> not public and I cannot take advantage of that class. This is why, in
> my case, extending SimpleResponseConsumer would do the trick (or
> making SimpleAsyncEntityConsumer public …)
>
> Regards,
> Christophe
I am not sure I understand the problem.
Use AbstractBinAsyncEntityConsumer or
AbstractCharAsyncEntityConsumer instead.
Simple* class variety are effectively internal I do not want to open
them up. They are not supposed to be used in real productive code.
Oleg
>
> > On 17 Mar 2022, at 16:56, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> >
> > Please extend AbstractAsyncResponseConsumer instead
> >
> > ----
> >
> > public class MyResponseConsumer extends
> > AbstractAsyncResponseConsumer<SimpleHttpResponse, byte[]> {
> >
> > MyResponseConsumer(final AsyncEntityConsumer<byte[]>
> > entityConsumer) {
> > super(entityConsumer);
> > }
> >
> > public static SimpleResponseConsumer create() {
> > return new SimpleResponseConsumer(new
> > SimpleAsyncEntityConsumer());
> > }
> >
> > @Override
> > public void informationResponse(final HttpResponse response,
> > final HttpContext context) throws HttpException, IOException {
> > }
> >
> > @Override
> > protected SimpleHttpResponse buildResult(final HttpResponse
> > response, final byte[] entity, final ContentType contentType) {
> > final SimpleHttpResponse simpleResponse =
> > SimpleHttpResponse.copy(response);
> > if (entity != null) {
> > simpleResponse.setBody(entity, contentType);
> > }
> > return simpleResponse;
> > }
> >
> > }
> >
> >
> >
> > On Thu, 2022-03-17 at 14:26 +0100, Christophe Darville wrote:
> > > Hi,
> > >
> > > In HttpClient5, the class
> > > org.apache.hc.client5.http.async.methods.SimpleResponseConsumer
> > > is
> > > final. Would it be possible to make this class not final ? I
> > > would
> > > like to extend it so I can override the buildResult method.
> > >
> > > Regards,
> > > Christophe
> > > ---------------------------------------------------------------
> > > ------
> > > To unsubscribe, e-mail:
> > > httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail:
> > > httpclient-users-help@hc.apache.org
> > >
> >
> > -----------------------------------------------------------------
> > ----
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail:
> > httpclient-users-help@hc.apache.org
> >
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Class SimpleResponseConsumer is final
Posted by Christophe Darville <cd...@internetvista.com>.
Hi Oleg,
Thank you for your answer. Before sending my post, I first tried to extends AbstractAsyncResponseConsumer like in your sample code but unfortunately the class SimpleAsyncEntityConsumer used in create() is not public and I cannot take advantage of that class. This is why, in my case, extending SimpleResponseConsumer would do the trick (or making SimpleAsyncEntityConsumer public …)
Regards,
Christophe
> On 17 Mar 2022, at 16:56, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> Please extend AbstractAsyncResponseConsumer instead
>
> ----
>
> public class MyResponseConsumer extends AbstractAsyncResponseConsumer<SimpleHttpResponse, byte[]> {
>
> MyResponseConsumer(final AsyncEntityConsumer<byte[]> entityConsumer) {
> super(entityConsumer);
> }
>
> public static SimpleResponseConsumer create() {
> return new SimpleResponseConsumer(new SimpleAsyncEntityConsumer());
> }
>
> @Override
> public void informationResponse(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
> }
>
> @Override
> protected SimpleHttpResponse buildResult(final HttpResponse response, final byte[] entity, final ContentType contentType) {
> final SimpleHttpResponse simpleResponse = SimpleHttpResponse.copy(response);
> if (entity != null) {
> simpleResponse.setBody(entity, contentType);
> }
> return simpleResponse;
> }
>
> }
>
>
>
> On Thu, 2022-03-17 at 14:26 +0100, Christophe Darville wrote:
>> Hi,
>>
>> In HttpClient5, the class
>> org.apache.hc.client5.http.async.methods.SimpleResponseConsumer is
>> final. Would it be possible to make this class not final ? I would
>> like to extend it so I can override the buildResult method.
>>
>> Regards,
>> Christophe
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
Re: Class SimpleResponseConsumer is final
Posted by Oleg Kalnichevski <ol...@apache.org>.
Please extend AbstractAsyncResponseConsumer instead
----
public class MyResponseConsumer extends AbstractAsyncResponseConsumer<SimpleHttpResponse, byte[]> {
MyResponseConsumer(final AsyncEntityConsumer<byte[]> entityConsumer) {
super(entityConsumer);
}
public static SimpleResponseConsumer create() {
return new SimpleResponseConsumer(new SimpleAsyncEntityConsumer());
}
@Override
public void informationResponse(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
}
@Override
protected SimpleHttpResponse buildResult(final HttpResponse response, final byte[] entity, final ContentType contentType) {
final SimpleHttpResponse simpleResponse = SimpleHttpResponse.copy(response);
if (entity != null) {
simpleResponse.setBody(entity, contentType);
}
return simpleResponse;
}
}
On Thu, 2022-03-17 at 14:26 +0100, Christophe Darville wrote:
> Hi,
>
> In HttpClient5, the class
> org.apache.hc.client5.http.async.methods.SimpleResponseConsumer is
> final. Would it be possible to make this class not final ? I would
> like to extend it so I can override the buildResult method.
>
> Regards,
> Christophe
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org