Mercurial > hg > release > icedtea-web-1.6
changeset 1267:3049b4003737
Broken file logging now dont crash itw
author | Jiri Vanek <jvanek@redhat.com> |
---|---|
date | Thu, 15 Oct 2015 15:09:37 +0200 |
parents | 2b1af623e3a8 |
children | 33bca916e032 |
files | ChangeLog NEWS netx/net/sourceforge/jnlp/util/logging/FileLog.java netx/net/sourceforge/jnlp/util/logging/OutputController.java netx/net/sourceforge/jnlp/util/logging/PrintStreamLogger.java netx/net/sourceforge/jnlp/util/logging/SingleStreamLogger.java netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java netx/net/sourceforge/jnlp/util/logging/WinSystemLog.java netx/net/sourceforge/jnlp/util/logging/headers/PluginMessage.java |
diffstat | 9 files changed, 75 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Oct 08 12:11:49 2015 +0200 +++ b/ChangeLog Thu Oct 15 15:09:37 2015 +0200 @@ -1,3 +1,20 @@ +2015-10-15 Jiri Vanek <jvanek@redhat.com> + + Broken file logging now dont crash itw + * NEWS: mentioned + * netx/net/sourceforge/jnlp/util/logging/FileLog.java: Instance now acquired + from factory method (createFileLog) which defaults new SingleStreamLoggerImpl + if normal initialization fails. + * netx/net/sourceforge/jnlp/util/logging/OutputController.java: (getFileLog) + uses new factory method rather then constructor. + * netx/net/sourceforge/jnlp/util/logging/SingleStreamLogger.java: enforces + now also close method + * netx/net/sourceforge/jnlp/util/logging/PrintStreamLogger.java: impl close + * netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java: impl close + * netx/net/sourceforge/jnlp/util/logging/WinSystemLog.java: impl close + * netx/net/sourceforge/jnlp/util/logging/headers/PluginMessage.java: removed + unused import + 2015-10-07 Jiri Vanek <jvanek@redhat.com> All connection restrictions now consider also port
--- a/NEWS Thu Oct 08 12:11:49 2015 +0200 +++ b/NEWS Thu Oct 15 15:09:37 2015 +0200 @@ -23,6 +23,7 @@ * RH1231441 Unable to read the text of the buttons of the security dialogue * Fixed RH1233697 icedtea-web: applet origin spoofing * Fixed RH1233667 icedtea-web: unexpected permanent authorization of unsigned applets +* fixed fatal impact of initialization error of FileLog * MissingALACAdialog made available also for unsigned applications (but ignoring actual manifest value) and fixed * NetX - fixed issues with -html shortcuts
--- a/netx/net/sourceforge/jnlp/util/logging/FileLog.java Thu Oct 08 12:11:49 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/logging/FileLog.java Thu Oct 15 15:09:37 2015 +0200 @@ -52,6 +52,23 @@ * This class writes log information to file. */ public final class FileLog implements SingleStreamLogger { + + private static final class SingleStreamLoggerImpl implements SingleStreamLogger { + + public SingleStreamLoggerImpl() { + } + + @Override + public void log(String s) { + //dummy + } + + @Override + public void close() { + //dummy + } + } + private static SimpleDateFormat fileLogNameFormatter = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.S"); /**"Tue Nov 19 09:43:50 CET 2013"*/ private static SimpleDateFormat pluginSharedFormatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZ yyyy"); @@ -60,22 +77,33 @@ private final FileHandler fh; private static final String defaultloggerName = "IcedTea-Web file-logger"; - public FileLog() { + public static SingleStreamLogger createFileLog() { + SingleStreamLogger s; + try { + s = new FileLog(); + } catch (Exception ex) { + //we do not wont to block whole logging just because initialization error in "new FileLog()" + OutputController.getLogger().log(ex); + s = new SingleStreamLoggerImpl(); + } + return s; + } + + private FileLog() { this(false); } - public FileLog(boolean append) { + private FileLog(boolean append) { this(defaultloggerName, LogConfig.getLogConfig().getIcedteaLogDir() + "itw-javantx-" + getStamp() + ".log", append); } - - - public FileLog(String fileName, boolean append) { + // testing constructor + FileLog(String fileName, boolean append) { this(fileName, fileName, append); } - - public FileLog(String loggerName, String fileName, boolean append) { - try { + + private FileLog(String loggerName, String fileName, boolean append) { + try { File futureFile = new File(fileName); if (!futureFile.exists()) { FileUtils.createRestrictedFile(futureFile, true); @@ -106,6 +134,7 @@ impl.log(Level.FINE, s); } + @Override public void close() { fh.close(); } @@ -121,4 +150,5 @@ public static SimpleDateFormat getPluginSharedFormatter() { return pluginSharedFormatter; } + }
--- a/netx/net/sourceforge/jnlp/util/logging/OutputController.java Thu Oct 08 12:11:49 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/logging/OutputController.java Thu Oct 15 15:09:37 2015 +0200 @@ -333,9 +333,10 @@ //https://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_Java //https://en.wikipedia.org/wiki/Initialization_on_demand_holder_idiom - private static volatile FileLog INSTANCE = new FileLog(); + private static volatile SingleStreamLogger INSTANCE = FileLog.createFileLog(); } - private FileLog getFileLog() { + + private SingleStreamLogger getFileLog() { return FileLogHolder.INSTANCE; }
--- a/netx/net/sourceforge/jnlp/util/logging/PrintStreamLogger.java Thu Oct 08 12:11:49 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/logging/PrintStreamLogger.java Thu Oct 15 15:09:37 2015 +0200 @@ -58,11 +58,10 @@ public void setStream(PrintStream stream) { this.stream = stream; } - - - - - + @Override + public void close() { + stream.flush(); + } }
--- a/netx/net/sourceforge/jnlp/util/logging/SingleStreamLogger.java Thu Oct 08 12:11:49 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/logging/SingleStreamLogger.java Thu Oct 15 15:09:37 2015 +0200 @@ -37,10 +37,10 @@ package net.sourceforge.jnlp.util.logging; public interface SingleStreamLogger { - - + public void log(String s); + public void close(); }
--- a/netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java Thu Oct 08 12:11:49 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java Thu Oct 15 15:09:37 2015 +0200 @@ -63,6 +63,11 @@ OutputController.getLogger().log(ex); } } - + + @Override + public void close() { + //nope + } + }
--- a/netx/net/sourceforge/jnlp/util/logging/WinSystemLog.java Thu Oct 08 12:11:49 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/logging/WinSystemLog.java Thu Oct 15 15:09:37 2015 +0200 @@ -49,9 +49,10 @@ public void log(String s) { //not yet implemented } - - - + @Override + public void close() { + //nope + } }
--- a/netx/net/sourceforge/jnlp/util/logging/headers/PluginMessage.java Thu Oct 08 12:11:49 2015 +0200 +++ b/netx/net/sourceforge/jnlp/util/logging/headers/PluginMessage.java Thu Oct 15 15:09:37 2015 +0200 @@ -38,7 +38,6 @@ package net.sourceforge.jnlp.util.logging.headers; import java.util.Date; -import net.sourceforge.jnlp.util.logging.FileLog; import net.sourceforge.jnlp.util.logging.OutputController; public class PluginMessage implements MessageWithHeader{