From commits-return-6552-apmail-sling-commits-archive=sling.apache.org@sling.apache.org Tue Dec 15 15:25:53 2009 Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 62343 invoked from network); 15 Dec 2009 15:25:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Dec 2009 15:25:53 -0000 Received: (qmail 25045 invoked by uid 500); 15 Dec 2009 15:25:53 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 24987 invoked by uid 500); 15 Dec 2009 15:25:52 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 24976 invoked by uid 99); 15 Dec 2009 15:25:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Dec 2009 15:25:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Dec 2009 15:25:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 752DB23889D7; Tue, 15 Dec 2009 15:25:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r890825 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java Date: Tue, 15 Dec 2009 15:25:29 -0000 To: commits@sling.apache.org From: bdelacretaz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091215152529.752DB23889D7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bdelacretaz Date: Tue Dec 15 15:25:29 2009 New Revision: 890825 URL: http://svn.apache.org/viewvc?rev=890825&view=rev Log: SLING-1239 - OSGi installer shouldn't remove bundles that it didn't install Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java?rev=890825&r1=890824&r2=890825&view=diff ============================================================================== --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java Tue Dec 15 15:25:29 2009 @@ -85,8 +85,17 @@ if(toActivate == null) { // None of our resources are installable, remove corresponding bundle if present + // and if we installed it if(getBundleInfo(ctx, resources.first()) != null) { - tasks.add(new BundleRemoveTask(resources.first())); + if(ctx.getInstalledBundleVersion(symbolicName) == null) { + if(ctx.getLogService() != null) { + ctx.getLogService().log(LogService.LOG_INFO, + "Bundle " + symbolicName + + " was not installed by this module, not removed"); + } + } else { + tasks.add(new BundleRemoveTask(resources.first())); + } } } else { @@ -117,7 +126,7 @@ if(ctx.getLogService() != null) { ctx.getLogService().log(LogService.LOG_INFO, "Bundle " + info.symbolicName + " " + installedVersion - + " was not installed by this module, leaving as is"); + + " was not installed by this module, not downgraded"); } } } else if(compare == 0 && ctx.isSnapshot(newVersion)){ Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java?rev=890825&r1=890824&r2=890825&view=diff ============================================================================== --- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java (original) +++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java Tue Dec 15 15:25:29 2009 @@ -151,8 +151,9 @@ @Test public void testBundleRemoveSingle() throws IOException { + final String version = "1.0"; final RegisteredResource [] r = { - new MockBundleResource(SN, "1.0") + new MockBundleResource(SN, version) }; r[0].setInstallable(false); @@ -160,7 +161,15 @@ final MockBundleTaskCreator c = new MockBundleTaskCreator(); c.addBundleInfo(SN, "1.0", Bundle.ACTIVE); final SortedSet s = getTasks(r, c); - assertEquals("Expected one task", 1, s.size()); + assertEquals("Expected no tasks, bundle was not installed by us", 0, s.size()); + } + + { + ctx.saveInstalledBundleInfo(SN, r[0].getDigest(), version); + final MockBundleTaskCreator c = new MockBundleTaskCreator(); + c.addBundleInfo(SN, "1.0", Bundle.ACTIVE); + final SortedSet s = getTasks(r, c); + assertEquals("Expected one task, as we installed that bundle", 1, s.size()); assertTrue("Expected a BundleRemoveTask", s.first() instanceof BundleRemoveTask); } } @@ -180,7 +189,15 @@ final MockBundleTaskCreator c = new MockBundleTaskCreator(); c.addBundleInfo(SN, "1.1", Bundle.ACTIVE); final SortedSet s = getTasks(r, c); - assertEquals("Expected one task", 1, s.size()); + assertEquals("Expected no tasks, bundle was not installed by us", 0, s.size()); + } + + { + final MockBundleTaskCreator c = new MockBundleTaskCreator(); + c.addBundleInfo(SN, "1.1", Bundle.ACTIVE); + ctx.saveInstalledBundleInfo(SN, r[1].getDigest(), "1.1"); + final SortedSet s = getTasks(r, c); + assertEquals("Expected one task, as we installed that bundle", 1, s.size()); assertTrue("Expected a BundleRemoveTask", s.first() instanceof BundleRemoveTask); } }