[java-identity-provider COMMIT] in /trunk/idp-core/src/main/java/net/shibboleth/idp: log/LogbackLoggingService.java s...

noreply at shibboleth.net noreply at shibboleth.net
Tue Dec 3 09:38:38 EST 2013


Author: rdw
Date: Tue Dec  3 09:38:38 2013
New Revision: 4976

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=4976&view=rev
Log:
IDP-330 Start to deconstruct the existing Service interface so we can fit the spring realdoing one on top.  Enough changes to the Old spring code to make things work and fix up logback service to match the new code.  Also fix multiple bugs in logback service 

Modified:
    trunk/idp-core/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java
    trunk/idp-core/src/main/java/net/shibboleth/idp/service/AbstractReloadableService.java
    trunk/idp-core/src/main/java/net/shibboleth/idp/service/AbstractSpringReloadableService.java
    trunk/idp-core/src/main/java/net/shibboleth/idp/service/AbstractSpringService.java
    trunk/idp-core/src/main/java/net/shibboleth/idp/service/ReloadableService.java

Modified: trunk/idp-core/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-core/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java?rev=4976&r1=4975&r2=4976&view=diff
==============================================================================
--- trunk/idp-core/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java (original)
+++ trunk/idp-core/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java Tue Dec  3 09:38:38 2013
@@ -19,15 +19,15 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
 
 import net.shibboleth.idp.service.AbstractReloadableService;
 import net.shibboleth.idp.service.ServiceException;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 import net.shibboleth.utilities.java.support.component.ComponentValidationException;
 
+import org.joda.time.DateTime;
 import org.slf4j.LoggerFactory;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
 
 import ch.qos.logback.classic.LoggerContext;
@@ -51,7 +51,7 @@
     private StatusManager statusManager;
 
     /** URL to the fallback logback configuration found in the IdP jar. */
-    private URL fallbackConfiguration;
+    private Resource fallbackConfiguration;
 
     /** Logging configuration resource. */
     private Resource configurationResource;
@@ -88,9 +88,13 @@
     }
 
     /** {@inheritDoc} */
-    protected boolean shouldReload() {
+    protected synchronized boolean shouldReload() {
         try {
-            return configurationResource.lastModified() > getLastSuccessfulReloadInstant().getMillis();
+            final DateTime lastReload = getLastSuccessfulReloadInstant();
+            if (null == lastReload) {
+                return true;
+            }
+            return configurationResource.lastModified() > lastReload.getMillis();
         } catch (IOException e) {
             statusManager.add(new ErrorStatus(
                     "Error checking last modified time of logging service configuration resource "
@@ -100,8 +104,7 @@
     }
 
     /** {@inheritDoc} */
-    protected void doReload(HashMap context) throws ServiceException {
-        super.doReload(context);
+    protected synchronized void doReload() throws ServiceException {
 
         loadLoggingConfiguration();
     }
@@ -119,22 +122,38 @@
             ins = configurationResource.getInputStream();
             loadLoggingConfiguration(ins);
         } catch (Exception e) {
-            Closeables.closeQuietly(ins);
+            try {
+                Closeables.close(ins, true);
+            } catch (IOException e1) {
+                // swallowed && logged by Closeables but...
+                throw new ServiceException(e1);
+            }
             statusManager.add(new ErrorStatus("Error loading logging configuration file: "
                     + configurationResource.getDescription(), this, e));
             try {
                 statusManager.add(new InfoStatus("Loading fallback logging configuration", this));
-                ins = fallbackConfiguration.openStream();
+                ins = fallbackConfiguration.getInputStream();
                 loadLoggingConfiguration(ins);
             } catch (IOException ioe) {
-                Closeables.closeQuietly(ins);
+                try {
+                    Closeables.close(ins, true);
+                } catch (IOException e1) {
+                    // swallowed && logged by Closeables
+                    throw new ServiceException(e1);
+                }
                 statusManager.add(new ErrorStatus("Error loading fallback logging configuration", this, e));
                 throw new ServiceException("Unable to load fallback logging configuration");
             }
         } finally {
-            Closeables.closeQuietly(ins);
+            try {
+                Closeables.close(ins, true);
+            } catch (IOException e) {
+                // swallowed && logged by Closeables
+                throw new ServiceException(e);
+            }
         }
     }
+    // Checkstyle: EmtpyBlock ON
 
     /**

[... 777 lines stripped ...]


More information about the commits mailing list