You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Pavel Tiunov (JIRA)" <ji...@apache.org> on 2009/01/27 17:16:59 UTC

[jira] Created: (FELIX-902) Empty bundle.state file produces NPE

Empty bundle.state file produces NPE
------------------------------------

                 Key: FELIX-902
                 URL: https://issues.apache.org/jira/browse/FELIX-902
             Project: Felix
          Issue Type: Bug
          Components: Framework
    Affects Versions: felix-1.0.4
            Reporter: Pavel Tiunov
            Priority: Critical


If I have empty bundle.state file in Felix cache then exception is thrown while bundle start:
java.lang.NullPointerException
            at org.apache.felix.framework.cache.BundleArchive.getPersistentState(BundleArchive.java:315)
            at org.apache.felix.framework.Felix.start(Felix.java:776)

But if i delete bundle.state then no exception is thrown and org.apache.felix.framework.cache.BundleArchive#getPersistentState returns 'Installed' state.
The exception is thrown because string comparsions in org.apache.felix.framework.cache.BundleArchive#getPersistentState do not respect java.io.BufferedReader#readLine's null return value if file is empty. Also there is a bug in org.apache.felix.framework.cache.BundleArchive#setPersistentState that can produce not persistent state of cache by creation of empty bundle.state file.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-902) Empty bundle.state file produces NPE

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard S. Hall updated FELIX-902:
----------------------------------

    Fix Version/s: felix-1.6.0

> Empty bundle.state file produces NPE
> ------------------------------------
>
>                 Key: FELIX-902
>                 URL: https://issues.apache.org/jira/browse/FELIX-902
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.0.4
>            Reporter: Pavel Tiunov
>            Assignee: Richard S. Hall
>            Priority: Critical
>             Fix For: felix-1.6.0
>
>
> If I have empty bundle.state file in Felix cache then exception is thrown while bundle start:
> java.lang.NullPointerException
>             at org.apache.felix.framework.cache.BundleArchive.getPersistentState(BundleArchive.java:315)
>             at org.apache.felix.framework.Felix.start(Felix.java:776)
> But if i delete bundle.state then no exception is thrown and org.apache.felix.framework.cache.BundleArchive#getPersistentState returns 'Installed' state.
> The exception is thrown because string comparsions in org.apache.felix.framework.cache.BundleArchive#getPersistentState do not respect java.io.BufferedReader#readLine's null return value if file is empty. Also there is a bug in org.apache.felix.framework.cache.BundleArchive#setPersistentState that can produce not persistent state of cache by creation of empty bundle.state file.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-902) Empty bundle.state file produces NPE

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12668134#action_12668134 ] 

Richard S. Hall commented on FELIX-902:
---------------------------------------

Still, shouldn't the second issue be resolved by the first issue? Now, if for some reason there is an empty file created, it will be interpreted as being the INSTALLED state. Said another way, there is really only one bug here, which is under some circumstances an empty state file might be created, so we need to handle that when we read the state file. Would you agree?

> Empty bundle.state file produces NPE
> ------------------------------------
>
>                 Key: FELIX-902
>                 URL: https://issues.apache.org/jira/browse/FELIX-902
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.0.4
>            Reporter: Pavel Tiunov
>            Assignee: Richard S. Hall
>            Priority: Critical
>
> If I have empty bundle.state file in Felix cache then exception is thrown while bundle start:
> java.lang.NullPointerException
>             at org.apache.felix.framework.cache.BundleArchive.getPersistentState(BundleArchive.java:315)
>             at org.apache.felix.framework.Felix.start(Felix.java:776)
> But if i delete bundle.state then no exception is thrown and org.apache.felix.framework.cache.BundleArchive#getPersistentState returns 'Installed' state.
> The exception is thrown because string comparsions in org.apache.felix.framework.cache.BundleArchive#getPersistentState do not respect java.io.BufferedReader#readLine's null return value if file is empty. Also there is a bug in org.apache.felix.framework.cache.BundleArchive#setPersistentState that can produce not persistent state of cache by creation of empty bundle.state file.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-902) Empty bundle.state file produces NPE

Posted by "Pavel Tiunov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12667998#action_12667998 ] 

Pavel Tiunov commented on FELIX-902:
------------------------------------

Yes, org.apache.felix.framework.cache.BundleArchive#setPersistentState looks pretty secure but there is some magic about what it performs just after output stream is created. What if BufferedWriter, OutputStreamWriter or anything else that surrounded by try...catch throws exception if stream is created? The answer is simple: stream should be closed in finally block and we have an empty bundle.state file (This is may be platform dependent behavior. Reproduced on Windows).
But this is just my opinion, because at the moment i can't catch what excactly breaks bundle.state file. Our application runs under Applet environment and i expect that this situation may occur when we closing Applet while OSGi is still in startup state.

> Empty bundle.state file produces NPE
> ------------------------------------
>
>                 Key: FELIX-902
>                 URL: https://issues.apache.org/jira/browse/FELIX-902
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.0.4
>            Reporter: Pavel Tiunov
>            Assignee: Richard S. Hall
>            Priority: Critical
>
> If I have empty bundle.state file in Felix cache then exception is thrown while bundle start:
> java.lang.NullPointerException
>             at org.apache.felix.framework.cache.BundleArchive.getPersistentState(BundleArchive.java:315)
>             at org.apache.felix.framework.Felix.start(Felix.java:776)
> But if i delete bundle.state then no exception is thrown and org.apache.felix.framework.cache.BundleArchive#getPersistentState returns 'Installed' state.
> The exception is thrown because string comparsions in org.apache.felix.framework.cache.BundleArchive#getPersistentState do not respect java.io.BufferedReader#readLine's null return value if file is empty. Also there is a bug in org.apache.felix.framework.cache.BundleArchive#setPersistentState that can produce not persistent state of cache by creation of empty bundle.state file.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (FELIX-902) Empty bundle.state file produces NPE

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard S. Hall resolved FELIX-902.
-----------------------------------

    Resolution: Fixed

This has been fixed in trunk and will be included in the next release. Please close if satisfied. Thanks.

> Empty bundle.state file produces NPE
> ------------------------------------
>
>                 Key: FELIX-902
>                 URL: https://issues.apache.org/jira/browse/FELIX-902
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.0.4
>            Reporter: Pavel Tiunov
>            Assignee: Richard S. Hall
>            Priority: Critical
>             Fix For: felix-1.6.0
>
>
> If I have empty bundle.state file in Felix cache then exception is thrown while bundle start:
> java.lang.NullPointerException
>             at org.apache.felix.framework.cache.BundleArchive.getPersistentState(BundleArchive.java:315)
>             at org.apache.felix.framework.Felix.start(Felix.java:776)
> But if i delete bundle.state then no exception is thrown and org.apache.felix.framework.cache.BundleArchive#getPersistentState returns 'Installed' state.
> The exception is thrown because string comparsions in org.apache.felix.framework.cache.BundleArchive#getPersistentState do not respect java.io.BufferedReader#readLine's null return value if file is empty. Also there is a bug in org.apache.felix.framework.cache.BundleArchive#setPersistentState that can produce not persistent state of cache by creation of empty bundle.state file.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (FELIX-902) Empty bundle.state file produces NPE

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard S. Hall reassigned FELIX-902:
-------------------------------------

    Assignee: Richard S. Hall

> Empty bundle.state file produces NPE
> ------------------------------------
>
>                 Key: FELIX-902
>                 URL: https://issues.apache.org/jira/browse/FELIX-902
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.0.4
>            Reporter: Pavel Tiunov
>            Assignee: Richard S. Hall
>            Priority: Critical
>
> If I have empty bundle.state file in Felix cache then exception is thrown while bundle start:
> java.lang.NullPointerException
>             at org.apache.felix.framework.cache.BundleArchive.getPersistentState(BundleArchive.java:315)
>             at org.apache.felix.framework.Felix.start(Felix.java:776)
> But if i delete bundle.state then no exception is thrown and org.apache.felix.framework.cache.BundleArchive#getPersistentState returns 'Installed' state.
> The exception is thrown because string comparsions in org.apache.felix.framework.cache.BundleArchive#getPersistentState do not respect java.io.BufferedReader#readLine's null return value if file is empty. Also there is a bug in org.apache.felix.framework.cache.BundleArchive#setPersistentState that can produce not persistent state of cache by creation of empty bundle.state file.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-902) Empty bundle.state file produces NPE

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12668512#action_12668512 ] 

Richard S. Hall commented on FELIX-902:
---------------------------------------

Ok, good to understand. I just committed a fix for the empty state file. Unfortunately, I don't expect a release for a little while, since the trunk is undergoing some major refactoring. I would recommend rolling your own release with the fix if it is impacting you.

Since you can apparently reproduce the root cause, it would be excellent if you could look into what is going on a little bit to see if that is something we could fix too. Or if you can create an example to reproduce it, I will look into it. Thanks for your help.

> Empty bundle.state file produces NPE
> ------------------------------------
>
>                 Key: FELIX-902
>                 URL: https://issues.apache.org/jira/browse/FELIX-902
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.0.4
>            Reporter: Pavel Tiunov
>            Assignee: Richard S. Hall
>            Priority: Critical
>
> If I have empty bundle.state file in Felix cache then exception is thrown while bundle start:
> java.lang.NullPointerException
>             at org.apache.felix.framework.cache.BundleArchive.getPersistentState(BundleArchive.java:315)
>             at org.apache.felix.framework.Felix.start(Felix.java:776)
> But if i delete bundle.state then no exception is thrown and org.apache.felix.framework.cache.BundleArchive#getPersistentState returns 'Installed' state.
> The exception is thrown because string comparsions in org.apache.felix.framework.cache.BundleArchive#getPersistentState do not respect java.io.BufferedReader#readLine's null return value if file is empty. Also there is a bug in org.apache.felix.framework.cache.BundleArchive#setPersistentState that can produce not persistent state of cache by creation of empty bundle.state file.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-902) Empty bundle.state file produces NPE

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12667753#action_12667753 ] 

Richard S. Hall commented on FELIX-902:
---------------------------------------

Thanks for the feedback.

Regarding your first issue, I added a null check to make sure we will default to INSTALLED.

As for the second issue in setPersistentState(), I do not understand what you are saying. The method is quite simple, it opens a file, writes a value, then closes the file. What is the bug? It defaults to INSTALLED and seems there could only be an issue if it had difficulty writing to the disk. If that is the case, there isn't much we can do. Am I missing something?

> Empty bundle.state file produces NPE
> ------------------------------------
>
>                 Key: FELIX-902
>                 URL: https://issues.apache.org/jira/browse/FELIX-902
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.0.4
>            Reporter: Pavel Tiunov
>            Priority: Critical
>
> If I have empty bundle.state file in Felix cache then exception is thrown while bundle start:
> java.lang.NullPointerException
>             at org.apache.felix.framework.cache.BundleArchive.getPersistentState(BundleArchive.java:315)
>             at org.apache.felix.framework.Felix.start(Felix.java:776)
> But if i delete bundle.state then no exception is thrown and org.apache.felix.framework.cache.BundleArchive#getPersistentState returns 'Installed' state.
> The exception is thrown because string comparsions in org.apache.felix.framework.cache.BundleArchive#getPersistentState do not respect java.io.BufferedReader#readLine's null return value if file is empty. Also there is a bug in org.apache.felix.framework.cache.BundleArchive#setPersistentState that can produce not persistent state of cache by creation of empty bundle.state file.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-902) Empty bundle.state file produces NPE

Posted by "Pavel Tiunov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-902?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12668468#action_12668468 ] 

Pavel Tiunov commented on FELIX-902:
------------------------------------

Yes, you are completely right. The fix is to handle empty state files. But i just thought that you wil be interested in root cause of problem, because it can bring cache into not persistent state.
P.S. And when this fix will be released? :) It's really important for us, because this bug reproduces very often in our environment.

> Empty bundle.state file produces NPE
> ------------------------------------
>
>                 Key: FELIX-902
>                 URL: https://issues.apache.org/jira/browse/FELIX-902
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.0.4
>            Reporter: Pavel Tiunov
>            Assignee: Richard S. Hall
>            Priority: Critical
>
> If I have empty bundle.state file in Felix cache then exception is thrown while bundle start:
> java.lang.NullPointerException
>             at org.apache.felix.framework.cache.BundleArchive.getPersistentState(BundleArchive.java:315)
>             at org.apache.felix.framework.Felix.start(Felix.java:776)
> But if i delete bundle.state then no exception is thrown and org.apache.felix.framework.cache.BundleArchive#getPersistentState returns 'Installed' state.
> The exception is thrown because string comparsions in org.apache.felix.framework.cache.BundleArchive#getPersistentState do not respect java.io.BufferedReader#readLine's null return value if file is empty. Also there is a bug in org.apache.felix.framework.cache.BundleArchive#setPersistentState that can produce not persistent state of cache by creation of empty bundle.state file.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.