Re: Seemingly incorrect short-circuiting logic

sebb <[email protected]> Mon, 17 Oct 2011 01:06:21 +0100
Newsgroups gmane.comp.jakarta.cactus.devel
Message-ID <CAOGo0VaXcTXpN8ZObR3pncw4nYsjC_T=pho8HMxD70qG4Mpp3Q@mail.gmail.com>
Wrong mailing list?

This is Jakarta, not Jackrabbit ...

On 17 October 2011 00:44, Dave Brosius <[email protected]> wrote:
> Greetings,
>
> org.apache.jackrabbit.webdav.security.report.AclPrincipalReport.java
>
> does the following
>
> This logic seems wrong to me
>
> *if (href =3D=3D null && respMap.containsKey(href)) {*
>
>
> i'd expect it should be ||
>
> correct?
>
>
> =A0@Override
> =A0 =A0public void init(DavResource resource, ReportInfo info) throws
> DavException {
> =A0 =A0 =A0 =A0super.init(resource, info);
> =A0 =A0 =A0 =A0// build the DAV:responses objects.
> =A0 =A0 =A0 =A0DavProperty<?> acl =3D resource.getProperty(SecurityConsta=
nts.ACL);
> =A0 =A0 =A0 =A0if (!(acl instanceof AclProperty)) {
> =A0 =A0 =A0 =A0 =A0 =A0throw new
> DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "DAV:acl proper=
ty
> expected.");
> =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0DavResourceLocator loc =3D resource.getLocator();
> =A0 =A0 =A0 =A0Map<String, MultiStatusResponse> respMap =3D new HashMap<S=
tring,
> MultiStatusResponse>();
> =A0 =A0 =A0 =A0List<AclProperty.Ace> list =3D (List<AclProperty.Ace>)
> ((AclProperty)acl).getValue();
> =A0 =A0 =A0 =A0for (AclProperty.Ace ace : list) {
> =A0 =A0 =A0 =A0 =A0 =A0String href =3D ace.getPrincipal().getHref();
> *if (href =3D=3D null && respMap.containsKey(href)) {*
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0// ignore non-href principals and principa=
ls that have been
> listed before
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue;
> =A0 =A0 =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0 =A0 =A0// href-principal that has not been found before
> =A0 =A0 =A0 =A0 =A0 =A0DavResourceLocator princLocator =3D
> loc.getFactory().createResourceLocator(loc.getPrefix(), href);
> =A0 =A0 =A0 =A0 =A0 =A0DavResource principalResource =3D
> resource.getFactory().createResource(princLocator, resource.getSession())=
;
> =A0 =A0 =A0 =A0 =A0 =A0respMap.put(href, new MultiStatusResponse(principa=
lResource,
> info.getPropertyNameSet()));
> =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0this.responses =3D respMap.values().toArray(new
> MultiStatusResponse[respMap.size()]);
> =A0 =A0}
>
>