You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Felix Knecht <fe...@otego.com> on 2010/06/04 11:46:22 UTC

Logical Operators '&' vs Conditional-And Operator '&&'

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

To me it would look more logical use everywhere conditional operator
'&&' in the if restriction [1].

I don't think it's a false positive of findbugs
"NS: Potentially dangerous use of non-short-circuit logic
(NS_DANGEROUS_NON_SHORT_CIRCUIT)

This code seems to be using non-short-circuit logic (e.g., & or |)
rather than short-circuit logic (&& or ||). In addition, it seem
possible that, depending on the value of the left hand side, you might
not want to evaluate the right hand side (because it would have side
effects, could cause an exception or could be expensive.

Non-short-circuit logic causes both sides of the expression to be
evaluated even when the result can be inferred from knowing the
left-hand side. This can be less efficient and can result in errors if
the left-hand side guards cases when evaluating the right-hand side can
generate an error. "

[1]
http://people.apache.org/~felixk/shared-docs/xref/org/apache/directory/shared/ldap/schema/syntaxCheckers/UuidSyntaxChecker.html#85

PS:
Hope there's still enough coffee left ;-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwIy24ACgkQ2lZVCB08qHFYDgCePA6XE35v7gLoyhMUVAWeOILR
jjgAnA+CIdT9Ot856YW3h9Huxl0fhgdO
=K9BW
-----END PGP SIGNATURE-----