Changeset 34294 for main/trunk


Ignore:
Timestamp:
2020-07-27T15:42:51+12:00 (4 years ago)
Author:
ak19
Message:

Kathy noticed that the try-with-resources does not work with the JDK 6 on the 64 bit VM, so the nightlies failed to go through. Going back to the old way of writing try statements that work with closeable resources. There may be more errors on the nightly remaining, but this was the first.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataToCSV.java

    r34285 r34294  
    344344        .withQuoteMode(QuoteMode.MINIMAL)
    345345        .withTrim();
    346    
    347     try (CSVPrinter printer = new CSVPrinter(new FileWriter(csvFile, appendSetting), customCSVFormat)) {
     346
     347    // try-with-resources breaks on 64 bit Linux nightly binary VM as that uses JDK 6.
     348    //try (CSVPrinter printer = new CSVPrinter(new FileWriter(csvFile, appendSetting), customCSVFormat)) {
     349
     350    CSVPrinter printer = null;
     351    try {
     352        printer = new CSVPrinter(new FileWriter(csvFile, appendSetting), customCSVFormat);
     353       
    348354        printer.printRecord(columnHeadings);
    349355        // https://javadoc.io/doc/org.apache.commons/commons-csv/latest/index.html
     
    380386        printer.println(); // done writing a record
    381387        }
     388
     389        printer.close(true); // flush and close
     390       
    382391    } catch (IOException ex) {
    383392        success = false;
     
    385394        System.err.println("Caught exception when writing meta to CSVFile " + csvFile.getAbsolutePath());
    386395        System.err.println("\t" + ex.getMessage());
     396
     397        SafeProcess.closeResource(printer);
    387398    }
    388399
Note: See TracChangeset for help on using the changeset viewer.