From fb97db9b264b65bc87963eee719c2e433488853c Mon Sep 17 00:00:00 2001 From: Thomas Knall Date: Tue, 25 Nov 2014 13:01:35 +0100 Subject: Fix buggy test. --- .../test/java/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/src/test/java/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java b/common/src/test/java/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java index 5b7a92004..e3468b89f 100644 --- a/common/src/test/java/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java +++ b/common/src/test/java/test/at/gv/egovernment/moa/util/DateTimeUtilsTest.java @@ -51,7 +51,8 @@ public class DateTimeUtilsTest extends TestCase { public void testParseDateTimeValid() throws Exception { Date date; - DateFormat format = SimpleDateFormat.getDateTimeInstance(); + DateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); + String dateStr; format.setTimeZone(TimeZone.getTimeZone("GMT")); -- cgit v1.2.3 From 0ed0a7702850b2001aaa8d5b194708a96e90dea3 Mon Sep 17 00:00:00 2001 From: Thomas Knall Date: Fri, 9 Jan 2015 11:25:10 +0100 Subject: Apply several fixes. - Disable erroneous IAIK PKI logger initialization (should be addressed by. - Remove redundant maven-dependency version declarations. - Fix maven/eclipse lifecyle warning problem. --- common/pom.xml | 1 - 1 file changed, 1 deletion(-) (limited to 'common') diff --git a/common/pom.xml b/common/pom.xml index 3d790d29b..bde3339d6 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -97,7 +97,6 @@ log4j log4j - 1.2.17 org.slf4j -- cgit v1.2.3 From 38ae8cb883ab73603f490d62b4cac38c51ac43e1 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Mon, 19 Jan 2015 12:10:48 +0100 Subject: update libraries -> joda-time 2.7 -> slf4j 2.7.10 -> struts2 2.3.20 -> commons-codec 1.10 -> hibernate 4.3.8.Final -> mySQL-connector 5.1.34 -> opensaml 2.6.4 -> xmltooling 2.6.4 --- common/pom.xml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'common') diff --git a/common/pom.xml b/common/pom.xml index 3d790d29b..e702c5e66 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -67,12 +67,12 @@ joda-time joda-time - 2.4 + 2.7 org.slf4j slf4j-api - 1.7.7 + 1.7.10 org.slf4j jcl-over-slf4j @@ -86,28 +81,18 @@ org.slf4j - slf4j-api + jul-to-slf4j 1.7.10 - + + org.slf4j + slf4j-log4j12 + 1.7.10 + log4j log4j - - org.slf4j - slf4j-log4j12 - 1.7.10 - - - org.slf4j - jul-to-slf4j - 1.7.10 - diff --git a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java index 184be20cb..6999656ab 100644 --- a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java +++ b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java @@ -50,22 +50,22 @@ public class Logger { /** The Constant instances. */ - private static final Map instances = new HashMap(); + private static final Map instances = new HashMap(); /** * Gets the logger. * * @return the logger */ - private static synchronized org.apache.log4j.Logger getLogger() { + private static synchronized org.slf4j.Logger getLogger() { String className = Thread.currentThread().getStackTrace()[3].getClassName(); - org.apache.log4j.Logger logger = instances.get(className); + org.slf4j.Logger logger = instances.get(className); if (logger != null) { return logger; } - logger = org.apache.log4j.Logger.getLogger(className); + logger = org.slf4j.LoggerFactory.getLogger(className); instances.put(className, logger); return logger; @@ -78,7 +78,7 @@ public class Logger { * false otherwise. */ public static boolean isTraceEnabled() { - org.apache.log4j.Logger logger = getLogger(); + org.slf4j.Logger logger = getLogger(); return logger.isTraceEnabled(); } @@ -90,7 +90,7 @@ public class Logger { * false otherwise. */ public static boolean isTraceEnabled(String hierarchy) { - org.apache.log4j.Logger logger = getLogger(); + org.slf4j.Logger logger = getLogger(); return logger.isTraceEnabled(); } @@ -100,8 +100,8 @@ public class Logger { * @param message The message to trace. */ public static void trace(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.trace(message); + org.slf4j.Logger logger = getLogger(); + logger.trace(message.toString()); } /** @@ -111,7 +111,7 @@ public class Logger { * false otherwise. */ public static boolean isDebugEnabled() { - org.apache.log4j.Logger logger = getLogger(); + org.slf4j.Logger logger = getLogger(); return logger.isDebugEnabled(); } @@ -123,7 +123,7 @@ public class Logger { * false otherwise. */ public static boolean isDebugEnabled(String hierarchy) { - org.apache.log4j.Logger logger = getLogger(); + org.slf4j.Logger logger = getLogger(); return logger.isDebugEnabled(); } @@ -133,8 +133,8 @@ public class Logger { * @param message The message to log. */ public static void debug(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.debug(message); + org.slf4j.Logger logger = getLogger(); + logger.debug(message.toString()); } /** @@ -143,8 +143,8 @@ public class Logger { * @param message The message to log. */ public static void info(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.info(message); + org.slf4j.Logger logger = getLogger(); + logger.info(message.toString()); } /** @@ -153,8 +153,8 @@ public class Logger { * @param message The message to log. */ public static void warn(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.warn(message); + org.slf4j.Logger logger = getLogger(); + logger.warn(message.toString()); } /** @@ -164,8 +164,8 @@ public class Logger { * @param t An exception that may be the cause of the warning. */ public static void warn(Object message, Throwable t) { - org.apache.log4j.Logger logger = getLogger(); - logger.warn(message, t); + org.slf4j.Logger logger = getLogger(); + logger.warn(message.toString(), t); } /** @@ -174,8 +174,8 @@ public class Logger { * @param message The message to log. */ public static void error(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.error(message); + org.slf4j.Logger logger = getLogger(); + logger.error(message.toString()); } /** @@ -185,8 +185,8 @@ public class Logger { * @param t An exception that may be the cause of the error. */ public static void error(Object message, Throwable t) { - org.apache.log4j.Logger logger = getLogger(); - logger.error(message, t); + org.slf4j.Logger logger = getLogger(); + logger.error(message.toString(), t); } /** @@ -195,8 +195,7 @@ public class Logger { * @param message The message to log. */ public static void fatal(Object message) { - org.apache.log4j.Logger logger = getLogger(); - logger.fatal(message); + error(message); } /** @@ -206,7 +205,6 @@ public class Logger { * @param t An exception that may be the cause of the error. */ public static void fatal(Object message, Throwable t) { - org.apache.log4j.Logger logger = getLogger(); - logger.fatal(message, t); + error(message, t); } } -- cgit v1.2.3 From 1bb5a7e0db70fb95343436155571f2037372c352 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Mon, 23 Mar 2015 13:41:33 +0100 Subject: made logging system more robust --- common/src/main/java/at/gv/egovernment/moa/logging/Logger.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java index 6999656ab..265ad026d 100644 --- a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java +++ b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java @@ -58,7 +58,14 @@ public class Logger { * @return the logger */ private static synchronized org.slf4j.Logger getLogger() { - String className = Thread.currentThread().getStackTrace()[3].getClassName(); + StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace(); + + int i; + for(i = 2; i < stacktrace.length; i++) + if(!stacktrace[i].getClassName().equals(Logger.class.getName())) + break; + + String className = stacktrace[i].getClassName(); org.slf4j.Logger logger = instances.get(className); if (logger != null) { -- cgit v1.2.3 From d28e5b6e0d0793558f3328c5a420c17bdd606104 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Thu, 16 Apr 2015 13:48:50 +0200 Subject: update library versions --- common/pom.xml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'common') diff --git a/common/pom.xml b/common/pom.xml index 72cf702bc..8f18a1b92 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -67,28 +67,24 @@ joda-time joda-time - 2.7 + ${jodatime.version} org.slf4j slf4j-api - 1.7.10 org.slf4j jcl-over-slf4j - 1.7.10 org.slf4j jul-to-slf4j - 1.7.10 - org.slf4j - slf4j-log4j12 - 1.7.10 - + org.slf4j + slf4j-log4j12 + log4j log4j -- cgit v1.2.3 From 2db59d0b99e6ca3bc9139b72fedfd9356be7e898 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Tue, 5 May 2015 12:55:56 +0200 Subject: fixed NullPointerException in Logger class triggered by empty message --- .../java/at/gv/egovernment/moa/logging/Logger.java | 31 +++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'common') diff --git a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java index 265ad026d..7cb2e7daf 100644 --- a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java +++ b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java @@ -78,6 +78,19 @@ public class Logger { return logger; } + /** + * Prepare the message for printing it as string. + *

Mainly introduce because the message might be null. + * + * @param message the message + * @return the string + */ + private static String prepareMessage(Object message) { + if(null == message) + return "no message given"; + return message.toString(); + } + /** * Test, if the trace log level is enabled. * @@ -108,7 +121,7 @@ public class Logger { */ public static void trace(Object message) { org.slf4j.Logger logger = getLogger(); - logger.trace(message.toString()); + logger.trace(prepareMessage(message)); } /** @@ -141,17 +154,17 @@ public class Logger { */ public static void debug(Object message) { org.slf4j.Logger logger = getLogger(); - logger.debug(message.toString()); + logger.debug(prepareMessage(message)); } - - /** + +/** * Log an info message. * * @param message The message to log. */ public static void info(Object message) { org.slf4j.Logger logger = getLogger(); - logger.info(message.toString()); + logger.info(prepareMessage(message)); } /** @@ -161,7 +174,7 @@ public class Logger { */ public static void warn(Object message) { org.slf4j.Logger logger = getLogger(); - logger.warn(message.toString()); + logger.warn(prepareMessage(message)); } /** @@ -172,7 +185,7 @@ public class Logger { */ public static void warn(Object message, Throwable t) { org.slf4j.Logger logger = getLogger(); - logger.warn(message.toString(), t); + logger.warn(prepareMessage(message), t); } /** @@ -182,7 +195,7 @@ public class Logger { */ public static void error(Object message) { org.slf4j.Logger logger = getLogger(); - logger.error(message.toString()); + logger.error(prepareMessage(message)); } /** @@ -193,7 +206,7 @@ public class Logger { */ public static void error(Object message, Throwable t) { org.slf4j.Logger logger = getLogger(); - logger.error(message.toString(), t); + logger.error(prepareMessage(message), t); } /** -- cgit v1.2.3