Skip to main content

[JIRA] Commented: (FABAN-11) Driver fails under JDK 7

  • From: "Scott Oaks (JIRA)" <jira-no-reply@...>
  • To: issues@...
  • Subject: [JIRA] Commented: (FABAN-11) Driver fails under JDK 7
  • Date: Wed, 16 Apr 2014 22:31:49 +0000 (UTC)
  • Auto-submitted: auto-generated


    [ 
https://java.net/jira/browse/FABAN-11?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=374515#action_374515
 ] 

Scott Oaks commented on FABAN-11:
---------------------------------

Here is a patch for the issue.

diff --git 
a/driver/src/com/sun/faban/driver/transport/sunhttp/HttpClient.java 
b/driver/src/com/sun/faban/driver/transport/sunhttp/HttpClient.java
index 7245a3b..38ad0a6 100644
--- a/driver/src/com/sun/faban/driver/transport/sunhttp/HttpClient.java
+++ b/driver/src/com/sun/faban/driver/transport/sunhttp/HttpClient.java
@@ -24,6 +24,7 @@
 package com.sun.faban.driver.transport.sunhttp;

 import java.io.IOException;
+import java.lang.reflect.Method;
 import java.net.InetSocketAddress;
 import java.net.Proxy;
 import java.net.Socket;
@@ -44,8 +45,14 @@ import java.security.PrivilegedAction;
  */
 public class HttpClient extends sun.net.www.http.HttpClient {

+    private static Method getMethod;
     static {
         kac = new KeepAliveCache();
+       try {
+           getMethod = kac.getClass().getMethod("get", new Class[]{ 
URL.class, Object.class } );
+       } catch (NoSuchMethodException nsme) {
+           throw new ExceptionInInitializerError(nsme);
+       }
     }
     /** Superclass' inCache is private. Needed to define and check usage. */
     protected boolean inCache;
@@ -86,7 +93,11 @@ public class HttpClient extends 
sun.net.www.http.HttpClient {
         HttpClient ret = null;
         /* see if one's already around */
         if (useCache) {
-            ret = (HttpClient) kac.get(url, null);
+           try {
+                ret = (HttpClient) getMethod.invoke(kac, new Object[]{url, 
null});
+           } catch (Exception iae) {
+               throw new IOException("Can't invoke on KeepAliveCache", iae);
+           }
             if (ret != null) {
                 if ((ret.proxy != null && ret.proxy.equals(p))
                         || (ret.proxy == null && p == null)) {


> Driver fails under JDK 7
> ------------------------
>
>                 Key: FABAN-11
>                 URL: https://java.net/jira/browse/FABAN-11
>             Project: faban
>          Issue Type: Bug
>            Reporter: Scott Oaks
>            Assignee: azeemj
>
> Running a driver with JDK 7 yields this error:
> java.lang.NoSuchMethodError: 
> sun.net.www.http.KeepAliveCache.get(Ljava/net/URL;Ljava/lang/Object;)Ljava/lang/Object;
>         at 
> com.sun.faban.driver.transport.sunhttp.HttpClient.New(HttpClient.java:87)
>         at 
> com.sun.faban.driver.transport.sunhttp.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:99)
>         at 
> com.sun.faban.driver.transport.sunhttp.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:41)
>         at 
> sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:928)
>         at 
> sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:846)
>         at 
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1296)
>         at 
> java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
>         at 
> com.sun.faban.driver.transport.sunhttp.SunHttpTransport.readURL(SunHttpTransport.java:177)
>         at 
> com.sun.faban.driver.transport.sunhttp.SunHttpTransport.readURL(SunHttpTransport.java:191)
>         at 
> com.sun.faban.driver.transport.sunhttp.SunHttpTransport.readURL(SunHttpTransport.java:217)
>         at 
> com.sun.faban.driver.HttpTransport.readURL(HttpTransport.java:190)
> This is the peril of using unsupported classes...though the Sun Transport 
> is still lighter weight than the Apache Transport.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[JIRA] Commented: (FABAN-11) Driver fails under JDK 7

Scott Oaks (JIRA) 04/16/2014

<Possible follow-up(s)>

[JIRA] Commented: (FABAN-11) Driver fails under JDK 7

yaominchen (JIRA) 04/22/2014

[JIRA] Commented: (FABAN-11) Driver fails under JDK 7

jamesxcheng (JIRA) 04/23/2014
 
 
Close
loading
Please Confirm
Close