You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "David Mays (JIRA)" <ji...@apache.org> on 2010/05/21 20:40:18 UTC

[jira] Updated: (HTTPCLIENT-937) Make CacheEntry use an immutable object to represent cache content

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-937?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Mays updated HTTPCLIENT-937:
----------------------------------

    Attachment: replace bytearray with httpentity.patch

Oleg,

Here is a patch that I believe accomplishes the desired effect.

We are still carrying a byte[] privately inside the CacheEntry, which makes for easy serialization.

But now, getBody() returns an HttpEntity which uses the ByteArrayEntity implementation, and is "new" for every call to getBody().

Because the byte[] that gets passed into the CacheEntryGenerator is itself a local variable within a method of CachingHttpClient, I do not believe there are any opportunities for external mutation of the content of that byte[]. However, because someone *could* create a CacheEntry in some other piece of code, and keep a reference to the byte[] that was used, I am not sure this meets the @Immutable requirement.

All, please feel free to comment and suggest alternatives.

Thanks,

Dave Mays

> Make CacheEntry use an immutable object to represent cache content 
> -------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-937
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-937
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: Cache
>            Reporter: Oleg Kalnichevski
>             Fix For: 4.1 Alpha3
>
>         Attachments: replace bytearray with httpentity.patch
>
>
> Make CacheEntry use an immutable object to represent cache content similar to HttpEntity

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org