diff options
Diffstat (limited to 'tests/test-extensions')
-rw-r--r-- | tests/test-extensions/net/sourceforge/jnlp/LoggingBottleneck.java | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/test-extensions/net/sourceforge/jnlp/LoggingBottleneck.java b/tests/test-extensions/net/sourceforge/jnlp/LoggingBottleneck.java index 75db3b5..20a73fe 100644 --- a/tests/test-extensions/net/sourceforge/jnlp/LoggingBottleneck.java +++ b/tests/test-extensions/net/sourceforge/jnlp/LoggingBottleneck.java @@ -45,6 +45,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.lang.reflect.Method; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -80,10 +81,10 @@ public class LoggingBottleneck { * map of classes, each have map of methods, each have errorlist, outLIst, and allList (allist contains also not std or err messages) * class.testMethod.logs */ - final Map<String, Map<String, TestsLogs>> processLogs = new HashMap<String, Map<String, TestsLogs>>(100); + final Map<String, Map<String, TestsLogs>> processLogs = Collections.synchronizedMap(new HashMap<String, Map<String, TestsLogs>>(1000)); private boolean added = false; - public static LoggingBottleneck getDefaultLoggingBottleneck() { + synchronized public static LoggingBottleneck getDefaultLoggingBottleneck() { if (loggingBottleneck == null) { loggingBottleneck = new LoggingBottleneck(); } @@ -101,11 +102,15 @@ public class LoggingBottleneck { } } - void writeXmlLog() throws FileNotFoundException, IOException { + synchronized void writeXmlLog() throws FileNotFoundException, IOException { writeXmlLog(DEFAULT_LOG_FILE); } - void writeXmlLog(File f) throws FileNotFoundException, IOException { + synchronized void writeXmlLog(File f) throws FileNotFoundException, IOException { + writeXmlLog(f, Collections.unmodifiableMap(processLogs)); + } + + synchronized static void writeXmlLog(File f, Map<String, Map<String, TestsLogs>> processLogs) throws FileNotFoundException, IOException { Writer w = new OutputStreamWriter(new FileOutputStream(f)); Set<Entry<String, Map<String, TestsLogs>>> classes = processLogs.entrySet(); w.write("<" + LOGS_ELEMENT + ">"); @@ -127,7 +132,7 @@ public class LoggingBottleneck { w.close(); } - void addToXmlLog(String message, boolean printToOut, boolean printToErr, StackTraceElement ste) { + synchronized void addToXmlLog(String message, boolean printToOut, boolean printToErr, StackTraceElement ste) { Map<String, TestsLogs> classLog = processLogs.get(ste.getClassName()); if (classLog == null) { classLog = new HashMap<String, TestsLogs>(50); @@ -157,7 +162,7 @@ public class LoggingBottleneck { methodLog.add(printToErr, printToOut, message); } - public String modifyMethodWithForBrowser(String methodBrowseredName, String className) { + synchronized public String modifyMethodWithForBrowser(String methodBrowseredName, String className) { try { Class clazz = Class.forName(className); /* @@ -180,11 +185,11 @@ public class LoggingBottleneck { return methodBrowseredName; } - public void setLoggedBrowser(String loggedBrowser) { + synchronized public void setLoggedBrowser(String loggedBrowser) { this.loggedBrowser = loggedBrowser; } - public void logIntoPlaintextLog(String message, boolean printToOut, boolean printToErr) { + synchronized public void logIntoPlaintextLog(String message, boolean printToOut, boolean printToErr) { try { if (printToOut) { LoggingBottleneck.getDefaultLoggingBottleneck().stdout(message); @@ -216,7 +221,7 @@ public class LoggingBottleneck { DEFAULT_STDLOGS_WRITER.flush(); } - public static String clearChars(String ss) { + synchronized public static String clearChars(String ss) { StringBuilder s = new StringBuilder(ss); for (int i = 0; i < s.length(); i++) { char q = s.charAt(i); |