Changeset 14627


Ignore:
Timestamp:
02/16/14 21:25:20 (8 years ago)
Author:
Mark Evenson
Message:

(partially) restore CL:LOAD from jar files.

There is apparently a fair amount of "breakage" of cases that used to
load no longer working which seems due to the changes in the semantics
for finding the FASL init loader. The following tests are now broken
but no longer cause the JVM to crash: JAR-PATHNAME.LOAD.HTTP.1,
JAR-PATHNAME.LOAD.HTTP.2, JAR-PATHNAME.LOAD.HTTP.4,
JAR-PATHNAME.LOAD.HTTP.6, JAR-PATHNAME.LOAD.HTTP.7,
and JAR-PATHNAME.LOAD.HTTP.9. Need to follow this up in subsequent work.

Fixed the underlying HttpHead?.get() interface used to determine
whether to used a cache version. The custom HTTP HEAD code that was
working under Java 6 no longer worked on Java 7.

Added to HttpHead?.get() asynchronous java.lang.Throwable on a socket
timeout of 5000 ms.

Location:
trunk/abcl
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Debug.java

    r13700 r14627  
    8787    }
    8888
     89    @SuppressWarnings("CallToThreadDumpStack")
    8990    public static final void trace(Throwable t)
    9091    {
     
    9293    }
    9394
     95    public static final void trace(String message, Throwable t)
     96    {
     97       trace(message);
     98       trace(t);
     99    }
    94100    public static final Symbol _DEBUG_WARN_
    95101        = exportSpecial("*DEBUG-WARN*", PACKAGE_SYS, NIL);
  • trunk/abcl/src/org/armedbear/lisp/ZipCache.java

    r14598 r14627  
    165165                // headers, which if we don't find, we give up and
    166166                // refetch the resource.
    167                 String dateString = HttpHead.get(url, "Last-Modified");
     167                String dateString = null;
     168                try {
     169                  dateString = HttpHead.get(url, "Last-Modified");
     170                } catch (IOException ex) {
     171                  Debug.trace(ex);
     172                }
    168173                Date date = null;
    169174                ParsePosition pos = new ParsePosition(0);
  • trunk/abcl/src/org/armedbear/lisp/util/HttpHead.java

    r14612 r14627  
    3838import java.io.IOException;
    3939import java.io.InputStreamReader;
     40import java.io.OutputStreamWriter;
    4041import java.io.PrintWriter;
    4142import java.net.InetSocketAddress;
     
    4950 */
    5051public class HttpHead {
    51     static private String get(String urlString, String key) {
     52    static private String get(String urlString, String key) throws IOException {
    5253        URL url = null;
    5354        try {
     
    5960    }
    6061
    61     static public String get(URL url, String key) {
     62    static public String get(URL url, String key) throws IOException {
    6263        Socket socket = null;
    6364        String result = null;
     
    6869                return result;
    6970            }
    70 
    71             socket = new Socket(Proxy.NO_PROXY); // XXX add Proxy
    72 
     71            String host = url.getHost();
    7372            int port = url.getPort();
    7473            if (port == -1) {
    7574                port = 80;
    7675            }
    77             InetSocketAddress address = new InetSocketAddress(url.getHost(), port);
    78             try {
    79                 socket.connect(address, 5000); // ??? too long?  too short?
    80             } catch (IOException ex) {
    81                 log("Connection failed: " + ex);
    82                 return result;
    83             }
    84 
     76            socket = new Socket(host, port);
     77           
    8578            PrintWriter out = null;
    8679            BufferedReader in = null;
    8780            try {
    8881                socket.setSoTimeout(5000); // ms
    89                 out = new PrintWriter(socket.getOutputStream());
     82                out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);
    9083                in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    9184            } catch (IOException e) {
     
    9487            }
    9588
     89            String CRLF = "\r\n";
    9690            String head = "HEAD " + url.getPath() + " HTTP/1.1";
    97             out.println(head);
    98             out.println("Host: " + url.getAuthority());
    99             out.println("Connection: close");
    100             out.println("");
     91            out.print(head + CRLF);
     92            out.print("Host: " + url.getAuthority() + CRLF);
     93            out.print("Connection: close" + CRLF);
     94            out.print(CRLF);
    10195            out.flush();
    10296
     
    106100            } catch (IOException e) {
    107101                log("Failed to read HTTP response: " + e);
     102            }
     103            if (line == null) {
     104              throw new IOException("Could not access URL to parse headers.");
    108105            }
    109106            String status[] = line.split("\\s");
     
    155152
    156153    public static void main(String argv[]) {
    157         if (argv.length != 1) {
    158             System.out.println("Usage: <cmd> URL");
    159             return;
    160         }
    161         String modified = get(argv[0], "Last-Modified");
    162         if (modified != null) {
    163             System.out.println("Last-Modified: " + modified);
    164         } else {
    165             System.out.println("No result returned.");
    166         }
     154      if (argv.length != 1) {
     155        System.out.println("Usage: <cmd> URL");
     156        return;
     157      }
     158      String modified = null;
     159      try {
     160        modified = get(argv[0], "Last-Modified");
     161      } catch (IOException ex) {
     162        System.err.println("Unable to get Last-Modified header: ");
     163        ex.printStackTrace(System.err);
     164      }
     165      if (modified != null) {
     166        System.out.println("Last-Modified: " + modified);
     167      } else {
     168        System.out.println("No result returned.");
     169      }
    167170    }
    168171}
  • trunk/abcl/test/lisp/abcl/jar-pathname.lisp

    r14613 r14627  
    150150  t)
    151151
    152 Ã§u(deftest jar-pathname.load.5
     152(deftest jar-pathname.load.5
    153153    (load-from-jar *tmp-jar-path* "eek.lisp")
    154154  t)
     
    210210
    211211;;; wrapped in PROGN for easy disabling without a network connection
    212 ;;; XXX come up with a better abstraction
    213 
    214 ;; disable until fix loading fasls via HTTP
    215 #+nil  Bombs JVM!  --ME 20140126
    216212(progn
    217213  (deftest jar-pathname.load.http.1
  • trunk/abcl/test/src/org/armedbear/lisp/util/HttpHeadTest.java

    r14611 r14627  
    1 /*
    2  * To change this license header, choose License Headers in Project Properties.
    3  * To change this template file, choose Tools | Templates
    4  * and open the template in the editor.
    5  */
    6 
    71package org.armedbear.lisp.util;
    82
     3import java.io.IOException;
    94import java.net.MalformedURLException;
    105import java.net.URL;
     
    1813import static org.junit.Assert.*;
    1914
    20 /**
    21  *
    22  * @author evenson
    23  */
    2415public class HttpHeadTest {
    2516 
     
    4334  }
    4435
    45   /**
    46    * Test of get method, of class HttpHead.
    47    */
    4836  @Test
    4937  public void testGet() {
    50     System.out.println("get");
    5138    URL url = null;
    5239    try {
    53       url = new URL("http://abcl-dynamic-install.googlecode.com/files/baz-20130403a.jar");
     40      url = new URL("http://abcl.org/fasl/42/baz-20140105a-fasl-42.jar");
    5441    } catch (MalformedURLException ex) {
    5542      Logger.getLogger(HttpHeadTest.class.getName()).log(Level.SEVERE, null, ex);
    5643    }
    5744    String key = "Last-Modified";
    58     String expResult = "";
    59     String result = HttpHead.get(url, key);
    60     assertEquals(expResult, result);
    61     System.out.println("Last-Modifed result was "+ result);
    62     fail("The test case is a prototype.");
     45    String result = null;
     46    try {
     47      result = HttpHead.get(url, key);
     48    } catch (IOException ex) {
     49      Logger.getLogger(HttpHeadTest.class.getName()).log(Level.SEVERE, null, ex);
     50    }
     51    assertNotNull(result);
     52    System.out.println("Last-Modified result was "+ result);
    6353  }
    6454
    65   /**
    66    * Test of main method, of class HttpHead.
    67    */
    6855  @Test
    6956  public void testMain() {
    7057    System.out.println("main");
    71     String[] argv = null;
     58    String[] argv = {"http://google.com/"};
    7259    HttpHead.main(argv);
    73     // TODO review the generated test code and remove the default call to fail.
    74     fail("The test case is a prototype.");
    7560  }
    7661 
Note: See TracChangeset for help on using the changeset viewer.