[jboss-remoting-commits] JBoss Remoting SVN: r3776 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Wed Mar 26 01:28:07 EDT 2008
Author: ron.sigal at jboss.com
Date: 2008-03-26 01:28:07 -0400 (Wed, 26 Mar 2008)
New Revision: 3776
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java
Log:
JBREM-934: Put Class.getMethod() in AccessController.doPrivileged() calls.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java 2008-03-26 05:27:26 UTC (rev 3775)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java 2008-03-26 05:28:07 UTC (rev 3776)
@@ -500,7 +500,7 @@
return result;
}
- private void setChunked(Map metadata, HttpURLConnection conn)
+ private void setChunked(Map metadata, final HttpURLConnection conn)
{
String chunkedValue = (String) metadata.get("chunkedLength");
if (chunkedValue != null && chunkedValue.length() > 0)
@@ -515,7 +515,23 @@
*/
try
{
- Method setChunkedLengthMethod = conn.getClass().getMethod("setChunkedStreamingMode", new Class[]{int.class});
+ Method setChunkedLengthMethod = null;
+
+ try
+ {
+ setChunkedLengthMethod = (Method)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return conn.getClass().getMethod("setChunkedStreamingMode", new Class[]{int.class});
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+
setChunkedLengthMethod.invoke(conn, new Object[]{new Integer(chunkedLength)});
}
catch (NoSuchMethodException e)
@@ -532,6 +548,12 @@
log.error("Error setting http client connection chunked length.");
log.debug(e);
}
+ catch (Exception e)
+ {
+ // Unexpected.
+ log.error("Unexpected error setting http client connection chunked length.");
+ log.debug(e);
+ }
}
catch (NumberFormatException e)
{
@@ -725,7 +747,7 @@
*/
try
{
- Class proxyClass = ClassLoaderUtility.loadClass("java.net.Proxy", HTTPClientInvoker.class);
+ final Class proxyClass = ClassLoaderUtility.loadClass("java.net.Proxy", HTTPClientInvoker.class);
InetSocketAddress proxyAddress = new InetSocketAddress(proxyHost, proxyPort);
Class[] decalredClasses = proxyClass.getDeclaredClasses();
Class proxyTypeClass = null;
@@ -753,7 +775,23 @@
}
Constructor proxyConstructor = proxyClass.getConstructor(new Class[] {proxyTypeClass, SocketAddress.class});
Object proxy = proxyConstructor.newInstance(new Object[] {proxyType, proxyAddress});
- Method openConnection = externalURL.getClass().getMethod("openConnection", new Class[] {proxyClass});
+ Method openConnection = null;
+
+ try
+ {
+ openConnection = (Method)AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return URL.class.getMethod("openConnection", new Class[] {proxyClass});
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+
httpURLConn = (HttpURLConnection)openConnection.invoke(externalURL, new Object[] {proxy});
}
catch (Exception e)
More information about the jboss-remoting-commits
mailing list