commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Bourg (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (CONFIGURATION-136) Reloading may corrupt the configuration
Date Sun, 21 Jun 2009 22:30:07 GMT

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

Emmanuel Bourg edited comment on CONFIGURATION-136 at 6/21/09 3:28 PM:
-----------------------------------------------------------------------

This issue has been on the todo list for quite some time. It could be quickly
fixed by changing the reload() method in AbstractFileConfiguration, it may look
like this :

{code:java}
    public void reload()
    {
        synchronized (reloadLock)
        {
            if (noReload == 0 && strategy.reloadingRequired())
            {
                // save the properties
                Map previousProperties = new LinkedMap(store);

                try
                {
                    clear();
                    load();

                    // notify the strategy
                    strategy.reloadingPerformed();
                }
                catch (Exception e)
                {
                    e.printStackTrace();

                    // rollback the changes
                    store = previousProperties;
                }
            }
        }
    }
{code}

I'm not sure it's the best way to rollback the changes though, copying the
properties seems expensive. Any idea ? Should we add a safeReload flag to
enable/disable this feature ?


      was (Author: ebourg):
    This issue has been on the todo list for quite some time. It could be quickly
fixed by changing the reload() method in AbstractFileConfiguration, it may look
like this :

    public void reload()
    {
        synchronized (reloadLock)
        {
            if (noReload == 0 && strategy.reloadingRequired())
            {
                // save the properties
                Map previousProperties = new LinkedMap(store);

                try
                {
                    clear();
                    load();

                    // notify the strategy
                    strategy.reloadingPerformed();
                }
                catch (Exception e)
                {
                    e.printStackTrace();

                    // rollback the changes
                    store = previousProperties;
                }
            }
        }
    }

I'm not sure it's the best way to rollback the changes though, copying the
properties seems expensive. Any idea ? Should we add a safeReload flag to
enable/disable this feature ?

  
> Reloading may corrupt the configuration
> ---------------------------------------
>
>                 Key: CONFIGURATION-136
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-136
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: File reloading
>    Affects Versions: 1.1
>            Reporter: nicolas de loof
>             Fix For: 1.7
>
>
> Current reloading process clears current properties and load updated values from
> resource reader. If an IO error occurs (or invalid format), the configuration
> gets corrupted and the application becomes unstable.
> It may be better for hot-reload to put loaded values into a temporary Properties
> and replace previous values only when reloading is successful. 
> It may also allow to use a 'currentlty-reloading' flag in the synchronized
> 'reload' block to avoid blocking threads during a reload (they could access
> safelly the 'old' properties until reload is finished)

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


Mime
View raw message