[ 
https://issues.apache.org/jira/browse/CONFIGURATION-788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17071675#comment-17071675
 ] 

Michael Noack commented on CONFIGURATION-788:
---------------------------------------------

To clarify: I've resorted to monkey patching because I was unable to get the 
workspace to build without deleting some other unrelated features which were 
using dependencies which aren't declared in the pom. From the name of the 
missing classes and some googling I suspect that the missing dependencies are 
actually classes introduced in commons-configuration 2.x. Since I've only 
touched four files I've decided to use the 1.10 release as is and to only 
update the classes in question.

I was able to get the unit tests testing the files I've changed to work and 
have been able to add working unit tests for the new feature. I've then build a 
jar file ignoring the tests during the build process. After building this jar 
I've extracted the classes created by those four changed files and repackaged 
the 1.10-release jar with those new files as a 1.11 version manually updating 
the Manifests and pom files. After manually injecting them into our internal 
Artifactory I was able to use this monkey patched version in our product and 
able to verify it still works as expected.

If there was a way to get the old branch to compile in its entirety and to run 
all unit tests successfully this would of course be the preferred way to build 
a new release. So far I've been unsuccessful to do this with the 
RELEASE_1_10_BRANCH and it looks like the public build system used by Apache 
isn't able to run all unit tests either. If I'm not mistaken it reports 37 
failed unit tests.

> AbstractHierarchicalFileConfiguration can lose data when #save() is 
> interrupted by JVM abort/power failure
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: CONFIGURATION-788
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-788
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: File reloading
>    Affects Versions: 1.10
>         Environment: This occurs in any environment with any use of 
> AbstractFileConfiguration#save(), AbstractFileConfiguration#save(URL) or 
> AbstractFileConfiguration#save(File).
>            Reporter: Michael Noack
>            Priority: Major
>              Labels: newbie
>         Attachments: 
> 0001-Implemented-keep-backup-feature-for-file-configurati.patch, 
> 0002-CHANGED-AbstractFileConfiguration-Fixed-potential-NP.patch
>
>
> When saving the current configuration, either using any of the #save() 
> Methods or when setting a property while auto-save is enabled the method 
> AbstractFileConfiguration#save(URL) effectively wipes the file content when 
> opening the OutputStream.
> If the JVM gets destroyed or the machine powered down before the new 
> configuration has been serialized to the file an empty file remains with no 
> configuration at all.
>  
> I've created a patch on top of the RELEASE_1_10_BRANCH which introduces a 
> mitigation. The mitigation consists of a "keep backup" flag in 
> AbstractFileConfiguration which, if set, creates a copy of the current 
> configuration file before writing into it.
> When a configuration exception occurs upon loading the configuration again 
> the exception will be caught and loading of the backup is attempted first 
> before rethrowing the exception when this fails as well.
> To allow existing implementations to profit from this without touching all 
> instances a global flag has been added to 
> AbstractHierarchicalFileConfiguration which is then inherited by all future 
> delegates added to any instance of AbstractHierarchicalFileConfiguration.
> Four unit tests for this mitigation feature have been added to 
> TestHierarchicalXMLConfiguration.
> I've uploaded a repository with the commit to github: 
> https://github.com/noamik/commons-configuration/tree/RELEASE_1_11_BRANCH



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to