Changeset 2757


Ignore:
Timestamp:
03/27/13 16:30:08 (11 years ago)
Author:
twagoo
Message:

Close log file after reading tail
[Refs #294]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/frontend/ViewLogPage.java

    r2756 r2757  
    1414import org.apache.wicket.markup.html.link.Link;
    1515import org.apache.wicket.model.Model;
     16import org.slf4j.LoggerFactory;
    1617
    1718/**
     
    2122 */
    2223public class ViewLogPage extends SecureAdminWebPage {
     24
     25    private final static org.slf4j.Logger logger = LoggerFactory.getLogger(ViewLogPage.class);
    2326
    2427    public ViewLogPage(final PageParameters pageParameters) {
     
    4649        if (logFile != null) {
    4750            try {
    48                 final RandomAccessFile raLogFile = geFileTail(logFile, tailSize);
     51                RandomAccessFile raLogFile = null;
    4952                try {
     53                    raLogFile = geFileTail(logFile, tailSize);
    5054                    final String content = getLogFileContent(raLogFile);
    5155
     
    5458
    5559                    add(new DownloadLink("logDownloadLink", logFile));
     60                } catch (IOException ioEx) {
     61                    add(new Label("logLabel", "Could not read from log file. See error message below."));
     62                    add(new TextArea("logText", new Model(ioEx.getMessage())));
     63                    throw (ioEx);
    5664                } finally {
    57                     raLogFile.close();
     65                    if (raLogFile != null) {
     66                        raLogFile.close();
     67                    }
    5868                }
    5969            } catch (IOException ioEx) {
    60                 add(new Label("logLabel", "Could not read from log file. See error message below."));
    61                 add(new TextArea("logText", new Model(ioEx.getMessage())));
     70                logger.error("Error in reading log file", ioEx);
    6271            }
    6372        }
Note: See TracChangeset for help on using the changeset viewer.