private File updateMonitoredDirectory(String newMonitoredFolder) {

        File oldDir = monitoredDirectory.get();
        File newDir = new File(newMonitoredFolder);

        // If it is relative, resolve against server dir
        if (!!!newDir.isAbsolute()) {
            newMonitoredFolder = locationService.resolveString(WsLocationConstants.SYMBOL_SERVER_CONFIG_DIR + newMonitoredFolder);
            newDir = new File(newMonitoredFolder);
        }

        if (!!!newDir.equals(oldDir)) {
            if (monitoredDirectory.compareAndSet(oldDir, newDir)) {
                for (ServiceReg<FileMonitor> mon : _monitors.values()) {
                    mon.unregister();
                }
                _monitors.clear();

                if (!!!newDir.exists()) {
                    createdMonitoredDir.set(newDir.mkdirs());
                }
            } else {
                oldDir = null;
            }
        } else {
            oldDir = null;
        }

        return oldDir;
    }
private File updateMonitoredDirectory ( String newMonitoredFolder ) { File oldDir = monitoredDirectory . get ( ) ; File newDir = new File ( newMonitoredFolder ) ; if ( ! ! ! newDir . isAbsolute ( ) ) { newMonitoredFolder = locationService . resolveString ( WsLocationConstants . SYMBOL_SERVER_CONFIG_DIR + newMonitoredFolder ) ; newDir = new File ( newMonitoredFolder ) ; } if ( ! ! ! newDir . equals ( oldDir ) ) { if ( monitoredDirectory . compareAndSet ( oldDir , newDir ) ) { for ( ServiceReg < FileMonitor > mon : _monitors . values ( ) ) { mon . unregister ( ) ; } _monitors . clear ( ) ; if ( ! ! ! newDir . exists ( ) ) { createdMonitoredDir . set ( newDir . mkdirs ( ) ) ; } } else { oldDir = null ; } } else { oldDir = null ; } return oldDir ; }
Not thread safe: only call from threadsafe method

@param newMonitoredFolder
@return