OpenLiberty / liberty-language-server

The Liberty Config Language Server provides language server features for Liberty server configuration files through any of the supported client IDEs.
Eclipse Public License 2.0
5 stars 11 forks source link

LCLS locks openliberty.properties preventing `mvn clean` when server.xml open in editor #216

Closed scottkurz closed 11 months ago

scottkurz commented 11 months ago

So I wanted to at least raise this for awareness...not sure what can easily be done...

But if I have my server.xml file open in Liberty Tools Eclipse and need to do a clean mvn clean (FWIW, Liberty Tools Eclipse doesn't offer a clean function but that's kind of besides the point here), it sometimes fails because the file is locked.

I assume this is locked by the LCLS lemminx ext:

[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ batch-bonuspayout-application --- [INFO] Deleting C:\git\sample.batch.bonuspayout\target [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.240 s [INFO] Finished at: 2023-10-04T14:46:28-04:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project batch-bonuspayout-application: Failed to clean project: Failed to delete C:\git\sample.batch.bonuspayout\target\liberty\wlp\lib\versions\openliberty.properties -> [Help 1]

And...the workaround is just to try again until it works, which is a pretty obvious a thing to try as well. so not a huge deal. Just noting.

cherylking commented 11 months ago

@scottkurz LCLS does read that file, but we don't "lock" it. I see things like this all the time on Windows though. When our tests run for the plugins, we see failures on clean because some Liberty file cannot be deleted. Not sure there is anything we can do about it.

cherylking commented 11 months ago

Found a potential spot of code to change. The properties are read in the constructor in io.openliberty.tools.langserver.lemminx.data.LibertyRuntime(Path). The FileInputStream is not closed in the constructor. Should use a try-with-resources statement when processing the properties file instead.

scottkurz commented 11 months ago

Yeah I know saying LCLS "locks" it is oversimplifying and not entirely accurate. I just tried it again and I failed repeatedly and had to open a different editor (besides the server.xml one) to get the clean to work. OK, nice to know we have something to look at.