cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: No way to remove Context user property
Date Fri, 09 Nov 2012 08:23:24 GMT
> Very strange what my question still has no answers.

Nah, it is normal that everyone's availability to help on the community list varies, and sometimes
you don't get an immediate answer.

> There is no way to remove user property from data context because property
> container implementation uses ConcurrentHashMap that does not support null
> values. Can I create task in cayenne jira bugtracker?


Good catch. Definitely create a Jira. We'll need to fix it.

Thanks,
Andrus


On Nov 9, 2012, at 7:29 AM, Alexey Katorgin <progmonster@gmail.com> wrote:
> Very strange what my question still has no answers. I'll try to be more clear:
> 
>        ServerRuntime runtime = ...;
> 
>        ObjectContext ctx = runtime.getContext();
> 
>        ctx.setUserProperty("my-property", "value");
> 
>        ctx.setUserProperty("my-property", null); // throws NPE and no another 
> way to delete property.
> 
>        /// Workaround:
>        // Define global constant: public static final Object EMPTY_VALUE = new 
> Object();
> 
>        // Clear property:
>        ctx.setUserProperty("my-property", EMPTY_VALUE);
> 
>        // Check if empty:        
>        if (EMPTY_VALUE.equals(ctx.getUserProperty("my-property"))) {
>            // ...
>        }
> 
>        // Should have in API anything like:
>        ctx.removeUserProperty("my-property");
> 
> 
> May be should I ask this question to devel group?
> 
> 
> Thanks,
> Alexey Katorgin.
> 
> 
> 


Mime
View raw message