axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From keith chapman <>
Subject Re: Axis2 API design issue, Should we fix it?
Date Wed, 06 May 2009 03:52:12 GMT
See comments inline.

On Wed, May 6, 2009 at 8:39 AM, Glen Daniels <> wrote:

> 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.

The reason we have implemented a clone is the limitation in the API. If the
return type was Map we could have returned the allServices map. Wouldn't
this clone be expensive when there are lots of services deployed?

+1 to adding JavaDoc saying that please use this map for reading purposes


> <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

Keith Chapman
Senior Software Engineer
WSO2 Inc.
Oxygenating the Web Service Platform.


View raw message