Author: bdelacretaz
Date: Thu Jan 14 14:17:04 2010
New Revision: 899208

URL: http://svn.apache.org/viewvc?rev=899208&view=rev
Log:
SLING-1285 - Launchpad did not start under Windows

Modified:
    
sling/trunk/bundles/commons/osgi/src/main/java/org/apache/sling/commons/osgi/bundleversion/FileBundleVersionInfo.java
    
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/Loader.java

Modified: 
sling/trunk/bundles/commons/osgi/src/main/java/org/apache/sling/commons/osgi/bundleversion/FileBundleVersionInfo.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/commons/osgi/src/main/java/org/apache/sling/commons/osgi/bundleversion/FileBundleVersionInfo.java?rev=899208&r1=899207&r2=899208&view=diff
==============================================================================
--- 
sling/trunk/bundles/commons/osgi/src/main/java/org/apache/sling/commons/osgi/bundleversion/FileBundleVersionInfo.java
 (original)
+++ 
sling/trunk/bundles/commons/osgi/src/main/java/org/apache/sling/commons/osgi/bundleversion/FileBundleVersionInfo.java
 Thu Jan 14 14:17:04 2010
@@ -37,26 +37,33 @@
     
     public FileBundleVersionInfo(File bundle) throws IOException {
         source = bundle;
-        final Manifest m = new JarFile(bundle).getManifest();
-        if(m == null) {
-            symbolicName = null;
-            version = null;
-            isSnapshot = false;
-            lastModified = BND_LAST_MODIFIED_MISSING;
-        } else {
-            symbolicName = 
m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
-            final String v = 
m.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
-            version = v == null ? null : new Version(v);
-            isSnapshot = v != null && v.contains(SNAPSHOT_MARKER);
-            final String last = 
m.getMainAttributes().getValue(BND_LAST_MODIFIED);
-            long lastMod = BND_LAST_MODIFIED_MISSING;
-            if(last != null) {
-                try {
-                    lastMod = Long.parseLong(last);
-                } catch(NumberFormatException ignore) {
+        final JarFile f = new JarFile(bundle);
+        try {
+            final Manifest m = f.getManifest();
+            if(m == null) {
+                symbolicName = null;
+                version = null;
+                isSnapshot = false;
+                lastModified = BND_LAST_MODIFIED_MISSING;
+            } else {
+                symbolicName = 
m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
+                final String v = 
m.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
+                version = v == null ? null : new Version(v);
+                isSnapshot = v != null && v.contains(SNAPSHOT_MARKER);
+                final String last = 
m.getMainAttributes().getValue(BND_LAST_MODIFIED);
+                long lastMod = BND_LAST_MODIFIED_MISSING;
+                if(last != null) {
+                    try {
+                        lastMod = Long.parseLong(last);
+                    } catch(NumberFormatException ignore) {
+                    }
                 }
+                lastModified = lastMod;
+            }
+        } finally {
+            if(f != null) {
+                f.close();
             }
-            lastModified = lastMod;
         }
     }
     

Modified: 
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/Loader.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/Loader.java?rev=899208&r1=899207&r2=899208&view=diff
==============================================================================
--- 
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/Loader.java
 (original)
+++ 
sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/Loader.java
 Thu Jan 14 14:17:04 2010
@@ -187,7 +187,9 @@
 
             if(installNewLauncher) {
                 final File f = new File(tmp.getParentFile(), 
SharedConstants.LAUNCHER_JAR_REL_PATH + "." + System.currentTimeMillis());
-                tmp.renameTo(f);
+                if(!tmp.renameTo(f)) {
+                    throw new IllegalStateException("Failed to rename " + 
tmp.getName() + " to " + f.getName());
+                }
                 info("Installing new launcher: " + launcherJar  + ", " + 
getBundleInfo(newVi) + " (" + f.getName() + ")");
             }
         } finally {


Reply via email to