swaggerwcf icon indicating copy to clipboard operation
swaggerwcf copied to clipboard

ZIPArchive API use in StaticContent.cs is not thread safe

Open ghost opened this issue 6 years ago • 1 comments

We use this component and experienced deadlocks with multiple threads calling ZipArchive.Entries.get(). The code using ZipArchive in StaticContent.cs is not thread safe (non-static members of ZipArchive/ZipArchiveEntry are not thread safe) nor is enumerating the collection of ZipArchiveEntry's. We fixed by putting a lock around:

ZipArchiveEntry file = _archiveCustom.Entries.FirstOrDefault(entry => entry.FullName == filename); file.Open();

We also copy the stream from file.open() into a MemoryStream and return that instead of the underlying stream.

ghost avatar Aug 15 '18 19:08 ghost

here is my advice: there are two methods in ServiceContract ISwaggerWcfEndpoint, remove the second (StaticContent), host the index.html by yourself, keep the first which provider the swagger.json content.

justin0522 avatar Aug 17 '18 08:08 justin0522