[ 
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.

Reply via email to