tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Correct behavior while checking the thread binding in DirContextURLStreamHandler ?
Date Tue, 31 Jan 2012 20:40:21 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ivan,

On 1/27/12 11:40 PM, Ivan wrote:
> if (result != null) return result;
> 
> // Checking thread biding result =
> threadBindings.get(currentThread); <-------------- Here, the value
> from threadBindings is always ignored ? is there something like "if
> (result != null) return result;" required there ?
> 
> // Checking parent CL binding currentCL = currentCL.getParent(); 
> while (currentCL != null) { result = clBindings.get(currentCL); if
> (result != null) return result; currentCL = currentCL.getParent(); 
> }
> 
> if (result == null) throw new IllegalStateException("Illegal class
> loader binding");
> 
> return result;

That does look fishy.

"result" will be ignored if currentCL.getParent returns non-null. If
currentCL.getParent returns null, then the method throws an exception.
It looks like this could be re-written in a more straightforward way
like this:

  currentCL = currentCL.getParent();
  if(null == result && null == currentCL)
    throw new IllegalArgumentException(...);

  while(currentCL != null)
    // continue

Of course, you still need to check for null after the loop, so it's
not like the change really affects anything other than minor readability.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8oUbUACgkQ9CaO5/Lv0PDGvwCgkELv0wJaVlzVxJc+UkUxi+Vx
9vAAnAgQYg0loutHFkxYxEzoJFqZYb3I
=e8sd
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message