felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r904011 - in /felix/trunk/karaf/webconsole: admin/src/main/java/org/apache/felix/karaf/webconsole/admin/ features/src/main/java/org/apache/felix/karaf/webconsole/features/ gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/
Date Thu, 28 Jan 2010 09:33:16 GMT
Author: ffang
Date: Thu Jan 28 09:33:15 2010
New Revision: 904011

URL: http://svn.apache.org/viewvc?rev=904011&view=rev
Log:
[FELIX-1994]improve fix to handle more generic case

Modified:
    felix/trunk/karaf/webconsole/admin/src/main/java/org/apache/felix/karaf/webconsole/admin/AdminPlugin.java
    felix/trunk/karaf/webconsole/features/src/main/java/org/apache/felix/karaf/webconsole/features/FeaturesPlugin.java
    felix/trunk/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java

Modified: felix/trunk/karaf/webconsole/admin/src/main/java/org/apache/felix/karaf/webconsole/admin/AdminPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/webconsole/admin/src/main/java/org/apache/felix/karaf/webconsole/admin/AdminPlugin.java?rev=904011&r1=904010&r2=904011&view=diff
==============================================================================
--- felix/trunk/karaf/webconsole/admin/src/main/java/org/apache/felix/karaf/webconsole/admin/AdminPlugin.java
(original)
+++ felix/trunk/karaf/webconsole/admin/src/main/java/org/apache/felix/karaf/webconsole/admin/AdminPlugin.java
Thu Jan 28 09:33:15 2010
@@ -174,24 +174,28 @@
 
     protected URL getResource(String path) {
         path = path.substring(NAME.length() + 1);
-        if (path.length() == 0) {
-            //it means input parameter path is just plugin name like /admin but not real
resource path.
-            //on felix the return url would be null in this case, which is correct expected
behavior.
-            //but on equinox the return url is like bundleresource://184.fwk1674485910/,
-            //which cause NPE in AbstractWebConsolePlugin.spoolResource
-            //so just return null ensure it works both with felix and equinox
-            return null;
-        }
-
         URL url = this.classLoader.getResource(path);
-        try {
-            InputStream ins = url.openStream();
-            if (ins == null) {
-                this.log.error("failed to open " + url);
+        if (url != null) {
+            InputStream ins = null;
+            try {
+                ins = url.openStream();
+                if (ins == null) {
+                    this.log.error("failed to open " + url);
+                    url = null;
+                }
+            } catch (IOException e) {
+                this.log.error(e.getMessage(), e);
+                url = null;
+            } finally {
+                if (ins != null) {
+                    try {
+                        ins.close();
+                    } catch (IOException e) {
+                        this.log.error(e.getMessage(), e);
+                    }
+                }
             }
-        } catch (IOException e) {
-            this.log.error(e.getMessage(), e);
-        }
+        } 
         return url;
     }
 

Modified: felix/trunk/karaf/webconsole/features/src/main/java/org/apache/felix/karaf/webconsole/features/FeaturesPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/webconsole/features/src/main/java/org/apache/felix/karaf/webconsole/features/FeaturesPlugin.java?rev=904011&r1=904010&r2=904011&view=diff
==============================================================================
--- felix/trunk/karaf/webconsole/features/src/main/java/org/apache/felix/karaf/webconsole/features/FeaturesPlugin.java
(original)
+++ felix/trunk/karaf/webconsole/features/src/main/java/org/apache/felix/karaf/webconsole/features/FeaturesPlugin.java
Thu Jan 28 09:33:15 2010
@@ -195,28 +195,29 @@
     protected URL getResource( String path )
     {
         path = path.substring( NAME.length() + 1 );
-        if (path.length() == 0) {
-            //it means input parameter path is just plugin name like /features but not real
resource path.
-            //on felix the return url would be null in this case, which is correct expected
behavior.
-            //but on equinox the return url is like bundleresource://184.fwk1674485910/,
-            //which cause NPE in AbstractWebConsolePlugin.spoolResource
-            //so just return null ensure it works both with felix and equinox
-            return null;
-        }
-
         URL url = this.classLoader.getResource( path );
-        try
-        {
-            InputStream ins = url.openStream();
-            if ( ins == null )
-            {
-                this.log.error( "failed to open " + url );
+        if (url != null) {
+            InputStream ins = null;
+            try {
+                ins = url.openStream();
+                if (ins == null) {
+                    this.log.error("failed to open " + url);
+                    url = null;
+                }
+            } catch (IOException e) {
+                this.log.error(e.getMessage(), e);
+                url = null;
+            } finally {
+                if (ins != null) {
+                    try {
+                        ins.close();
+                    } catch (IOException e) {
+                        this.log.error(e.getMessage(), e);
+                    }
+                }
             }
         }
-        catch ( IOException e )
-        {
-            this.log.error( e.getMessage(), e );
-        }
+
         return url;
     }
 

Modified: felix/trunk/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java?rev=904011&r1=904010&r2=904011&view=diff
==============================================================================
--- felix/trunk/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java
(original)
+++ felix/trunk/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java
Thu Jan 28 09:33:15 2010
@@ -135,28 +135,28 @@
     protected URL getResource( String path )
     {
         path = path.substring( NAME.length() + 1 );
-        if (path.length() == 0) {
-            //it means input parameter path is just plugin name like /gogo but not real resource
path.
-            //on felix the return url would be null in this case, which is correct expected
behavior.
-            //but on equinox the return url is like bundleresource://184.fwk1674485910/,
-            //which cause NPE in AbstractWebConsolePlugin.spoolResource
-            //so just return null ensure it works both with felix and equinox
-            return null;
-        }
-
         URL url = this.getClass().getClassLoader().getResource( path );
-        try
-        {
-            InputStream ins = url.openStream();
-            if ( ins == null )
-            {
-                this.log.error( "failed to open " + url );
+        if (url != null) {
+            InputStream ins = null;
+            try {
+                ins = url.openStream();
+                if (ins == null) {
+                    this.log.error("failed to open " + url);
+                    url = null;
+                }
+            } catch (IOException e) {
+                this.log.error(e.getMessage(), e);
+                url = null;
+            } finally {
+                if (ins != null) {
+                    try {
+                        ins.close();
+                    } catch (IOException e) {
+                        this.log.error(e.getMessage(), e);
+                    }
+                }
             }
         }
-        catch ( IOException e )
-        {
-            this.log.error( e.getMessage(), e );
-        }
         return url;
     }
 



Mime
View raw message