Thierry Danard created NETBEANS-934: ---------------------------------------
Summary: A lock is kept on window settings file Key: NETBEANS-934 URL: https://issues.apache.org/jira/browse/NETBEANS-934 Project: NetBeans Issue Type: Bug Components: platform - Window System Affects Versions: 9.0 Reporter: Thierry Danard Fix For: 9.0 I have an application that is based upon the NetBeans platform. In this application, we have a session mechanism where users can save and restore the state of the windows. The way this session mechanism works is: To save: * force a serialization of the window state (calling org.netbeans.core.WindowSystem.save) * save the content of all files in Windows2Local in a "session" file * save the content of the tracker.properties file in the same "session" file To restore: * wipe out the content of the Windows2Local directory and replace it with the saved content, then * replace the content of the tracker.properties file * force a clear/reload using reflection: // load netbeans state from disk System.gc(); System.gc(); FileUtil.refreshAll(); // needed to discard any caches copy of the setting files Class windowSystemClass = Thread.currentThread().getContextClassLoader().loadClass("org.netbeans.core.WindowSystem"); Class windowManagerClass = Thread.currentThread().getContextClassLoader().loadClass("org.netbeans.core.windows.WindowManagerImpl"); Class persistenceHandlerClass = Thread.currentThread().getContextClassLoader().loadClass("org.netbeans.core.windows.PersistenceHandler"); Class persistenceManagerClass = Thread.currentThread().getContextClassLoader().loadClass("org.netbeans.core.windows.persistence.PersistenceManager"); Object windowSystem = Lookup.getDefault().lookup(windowSystemClass); Method method = windowSystemClass.getMethod("hide"); method.invoke(windowSystem); method = windowManagerClass.getMethod("getInstance"); Object windowManager = method.invoke(windowManagerClass); windowManager.getClass().getMethod("resetModel").invoke(windowManager); windowManagerClass.getMethod("setRecentViewList", String[].class).invoke(windowManager, new Object[]\{new String[0]}); method = persistenceManagerClass.getMethod("getDefault"); Object persistenceManager = method.invoke(persistenceManagerClass); persistenceManager.getClass().getMethod("clear").invoke(persistenceManager); method = persistenceHandlerClass.getMethod("getDefault"); Object persistenceHandler = method.invoke(persistenceHandlerClass); persistenceHandler.getClass().getMethod("clear").invoke(persistenceHandler); method = windowSystemClass.getMethod("load"); method.invoke(windowSystem); method = windowSystemClass.getMethod("show"); method.invoke(windowSystem); This used to work in versions 8.x, but no longer. Some ".settings" files are locked. The files that stay locked vary, which points to a garbage collection issue. File.canWrite() actually returns false for some files, which also makes me think that the Data Objects underlying these objects are opening streams but don't close them? Running from source, I can't find the issue. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists