OH2 Rule Loading suggestion

Every time I edit a rule via Samba it is loaded twice, the first time usually with an error such as

2017-08-16 09:20:27.517 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'Heatpumps1.rules' has errors, therefore ignoring it: [178,60]: mismatched input '<EOF>' expecting ')'

Reading the forum it seems this is down to OpenHAB reading the rule before it has been fully written and then throwing an error before reloading it later when it is complete. In my case the rule loading correctly around 25 seconds later after pegging the CPU just over 100% and [178,60] was the first character after a ‘(’ and there is no error in the rule file. Whilst longer rules seem to hit this more problem often, smaller ones are not immune.

Is there a way of entering a delay into OpenHAB so it reads the rule file after write has finished. If not can this be added as an extra feature or bug fix?

This is due to Samba. I don’t think that you can modify the behaviour of the smarthome.model.core.internal.ModelRepositoryImpl which loads the files…

On the other hand… @triller-telekom is describing that the first file entry will appear as empty to OH2.
In your case, it seems that OH2 reads some content from the first file event…

Thanks for the reply, I just wish it wouldn’t make the system unresponsive whilst it tried to load the incomplete file. OH1 had a configurable delay before it read the file, so it didn’t usually have this problem, perhaps OH2 could return to a configurable delay before a changed rules file is read in?
In my case after every file read attempt there is a corresponding rule error suggesting that it DOES read part of the rule file

OH 1 didn’t have a delay before loading a file. The value you are referring too was a polling period. OH 1 would look for new files too load every polling period.

Programmers HATE polling for things so this part was rewritten to use file system events to know when to load new files. On samba shares (and some others as well) two for events get generated when a file is written, one when the file is started and another when it is done being written. OH you’re to read the file on both events but the file is basically empty on the first event, hence the error.

It could be the case on your system that part of the file gets written before OH reacts to the first event.

That explains it. Given that a lot will use Samba to write the rules files I wonder whether its feasible for the OH programmers to create a Samba compatibility mode that waits for 2 file system events before it loads the file, or perhaps waits for no file system events for a configurable delay before it loads the file