commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kate Butler (JIRA)" <>
Subject [jira] [Created] (CONFIGURATION-497) PropertiesConfiguration.setProperty() with auto-save returns before file handle is closed
Date Sun, 13 May 2012 01:40:48 GMT
Kate Butler created CONFIGURATION-497:

             Summary: PropertiesConfiguration.setProperty() with auto-save returns before
file handle is closed
                 Key: CONFIGURATION-497
             Project: Commons Configuration
          Issue Type: Bug
          Components: File reloading
    Affects Versions: 1.8, 1.6
            Reporter: Kate Butler
            Priority: Minor

I have an application which stores some counters in a PropertiesConfiguration with auto-save
enabled. These counters are incremented regularly - during peak load the PropertiesConfiguration
object will be updated every 5 milliseconds on average, and there will also be threads reading
from it at the same time. All access to the PropertiesConfiguration is made through a wrapper
class which enforces synchronization.
About one in every 8,000 calls to setProperty() will fail, seemingly because the file handle
is still open from the previous call. I have a single-threaded test case which can reproduce
this by writing continuously to a PropertiesConfiguration object - it usually fails within
10,000 iterations and has never successfully completed 500,000 iterations.

{code:title=Test Case|borderStyle=solid}
  public void testHeavyLoadWritingToConf() throws ConfigurationException {
    PropertiesConfiguration conf = new PropertiesConfiguration(new;
    for (int i = 0; i < NUM_WRITES; i++) {
      if (i % 100 == 0 && i > 0) {
        System.out.println("Test has completed " + i + " iterations");
      conf.setProperty("my.counter", i);
    System.out.println("All writes successful");

{code:title=Stack trace|borderStyle=solid}
org.apache.commons.configuration.ConfigurationRuntimeException: Failed to auto-save
	at org.apache.commons.configuration.AbstractFileConfiguration.possiblySave(
	at org.apache.commons.configuration.AbstractFileConfiguration.clearProperty(
	at org.apache.commons.configuration.AbstractConfiguration.setProperty(
	at org.apache.commons.configuration.AbstractFileConfiguration.setProperty(
	at com.magicmemories.spike.PersistenceLockingTest.testHeavyLoadWritingToConf(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at junit.framework.TestCase.runTest(
	at junit.framework.TestCase.runBare(
	at junit.framework.TestResult$1.protect(
	at junit.framework.TestResult.runProtected(
	at junit.framework.TestSuite.runTest(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
Caused by: org.apache.commons.configuration.ConfigurationException: Unable to save to file
	at org.apache.commons.configuration.DefaultFileSystem.getOutputStream(
	at org.apache.commons.configuration.DefaultFileSystem.getOutputStream(
	at org.apache.commons.configuration.AbstractFileConfiguration.possiblySave(
	... 23 more
Caused by: C:\testarea\ (The process cannot
access the file because it is being used by another process)
	at Method)
	at org.apache.commons.configuration.DefaultFileSystem.getOutputStream(
	... 27 more

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message