axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Daniels <g...@thoughtcraft.com>
Subject Re: Axis2 API design issue, Should we fix it?
Date Wed, 06 May 2009 03:09:33 GMT
keith chapman wrote:
>     > In my view this is highly inefficient, especially if you have
>     plenty of
>     > services in the system. Wouldn't it be better to fix the API and
>     return
>     > a Map instead of a HashMap? If we did that we could simple return
>     > allServices instead of returning a copy of it.
> 
>     You don't want to return an actual reference to a mutable object
>     that backs a
>     significant data model - otherwise people could just get that Map and
>     (mistakenly or maliciously) randomly add and delete services.
>  
> Agreed. But now that we've been doing it people may have code that
> expect it to be there. So we need a mechanism for returning this map.

Um - we aren't currently returning the actual Map, we're returning a clone of
it (just done manually instead of using clone()).  You had suggested
returning the actual Map itself, which is what I was reacting to above.  I'm
not saying the API should go away.

<rant>
Of course, if we had any kind of reasonable JavaDoc, there would be a clear
indication in the API docs that the returned HashMap was in fact a clone and
that inserting or removing things from it would have no effect on the system.
</rant>

Thanks,
--Glen

Mime
View raw message