incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r910503 - in /sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl: OsgiInstallerTask.java OsgiInstallerThread.java tasks/BundleUpdateTask.java
Date Tue, 16 Feb 2010 12:43:26 GMT
Author: bdelacretaz
Date: Tue Feb 16 12:43:26 2010
New Revision: 910503

URL: http://svn.apache.org/viewvc?rev=910503&view=rev
Log:
SLING-1381 - BundleUpdateTask should stop retrying if RegisteredResource provides no InputStream

Modified:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java?rev=910503&r1=910502&r2=910503&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java
Tue Feb 16 12:43:26 2010
@@ -42,6 +42,11 @@
 	public boolean isExecutable(OsgiInstallerContext ctx) throws Exception {
 	    return true;
 	}
+	
+	/** Can the task be retried after {@link execute} failed? */
+	public boolean canRetry(OsgiInstallerContext ctx) {
+		return true;
+	}
 
 	@Override
 	public final boolean equals(Object o) {

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=910503&r1=910502&r2=910503&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
Tue Feb 16 12:43:26 2010
@@ -352,15 +352,30 @@
             synchronized (tasks) {
                 t = tasks.first();
             }
-            t.execute(ctx);
-            counter++;
-            synchronized (tasks) {
-                tasks.remove(t);
+            try {
+                t.execute(ctx);
+                removeTask(t);
+                counter++;
+            } catch(Exception e) {
+            	if(!t.canRetry(ctx)) {
+            		if(ctx.getLogService() != null) {
+            			ctx.getLogService().log(LogService.LOG_INFO, 
+            					"Task cannot be retried, removing from list:" + t);
+            		}
+                    removeTask(t);
+            	}
+            	throw e;
             }
         }
         return counter;
     }
     
+    private void removeTask(OsgiInstallerTask t) {
+        synchronized (tasks) {
+            tasks.remove(t);
+        }
+    }
+    
     private void cleanupInstallableResources() throws IOException {
         // Cleanup resources that are not marked installable,
         // they have been processed by now

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java?rev=910503&r1=910502&r2=910503&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java
Tue Feb 16 12:43:26 2010
@@ -36,6 +36,7 @@
 public class BundleUpdateTask extends OsgiInstallerTask {
 
     private final RegisteredResource resource;
+    private boolean canRetry = true;
     
     public BundleUpdateTask(RegisteredResource r) {
         this.resource = r;
@@ -96,6 +97,7 @@
         b.stop();
         final InputStream is = resource.getInputStream(ctx.getBundleContext());
         if(is == null) {
+        	canRetry = false;
             throw new IllegalStateException(
                     "RegisteredResource provides null InputStream, cannot update bundle:
"
                     + resource);
@@ -108,6 +110,11 @@
         }
         ctx.incrementCounter(OsgiInstaller.OSGI_TASKS_COUNTER);
     }
+    
+    @Override
+    public boolean canRetry(OsgiInstallerContext ctx) {
+    	return canRetry;
+    }
 
     @Override
     public String getSortKey() {



Mime
View raw message