-
-
Notifications
You must be signed in to change notification settings - Fork 732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception running InspectCode and then directly after TeamCity.ImportData #805
Comments
Yeah that stream should be wrapped in a using statement so it's disposed directly. |
Or, should the FileAccess be changed to FileAccess.Read, so it doesn't lock the file? |
i.e.
|
or it could even be |
Well it could be read, but important part probably the dispose part, on phone now, but should be something like. XDocument xmlDoc;
using(var stream = resultsFile.OpenRead())
{
xmlDoc = XDocument.Load(stream);
} |
I would go with the using! |
Perhaps xml load alias so it can be reused 😉 |
Why not simply |
@lionelplessis Not possible to write unit tests for that path so stream is preferred. |
Thanks @patriksvensson, I had the feeling I was missing something but still I had to ask just in case 😃. Makes sense. |
- Rather than opening the File, thus locking it, use a Stream to dispose of the lock on the file when working with it has completed.
(GH-805) Correcting issue with locked file
- Rather than opening the File, thus locking it, use a Stream to dispose of the lock on the file when working with it has completed.
@laurentkempe @lionelplessis can you please give the 0.10.1 version of Cake a run, and confirm that the issue that you raised has been resolved? Thanks! |
@gep13 I will and let you know asap. Currently I am rebuilding our whole build infrastructure. But that should be done till tonight |
@laurentkempe perfect, thank you! |
👍 Works perfectly! well done @gep13 |
@laurentkempe glad to hear it! Please let us know if you run into any other issues, or if you have further questions! |
@gep13 don't worry I will do so 😃 |
Here is the exception
This is due to this line which does
resultsFile.Open(FileMode.Open)
Looks like there is the same problem here https://github.com/cake-build/cake/blob/develop/src/Cake.Common/Tools/DupFinder/DupFinderRunner.cs#L193 cc @gep13
The text was updated successfully, but these errors were encountered: