Commit 7c0d2d1
authored
fix(core): prevent Stream closed on concurrent JAR access in TemplateManager (#23596)
When two Gradle tasks run concurrently in isolated classloaders that both
point to the same generator JAR, the JVM's JarFileFactory shares a single
JarFile between both classloaders. If one classloader is closed/GC'd while
the other is still copying a non-template resource (e.g. README.md), the
shared JarFile is closed and the other worker's InflaterInputStream throws
'Stream closed'.
Two fixes in TemplateManager:
1. getInputStream() now opens a fresh URLConnection with setUseCaches(false) for classpath resources, preventing the underlying JarFile from being shared across classloaders.
2. write() now wraps the InputStream in try-with-resources, fixing the pre-existing resource leak where the stream was never closed after the binary file copy.1 parent 20e3283 commit 7c0d2d1
File tree
1 file changed
+30
-15
lines changed- modules/openapi-generator/src/main/java/org/openapitools/codegen
1 file changed
+30
-15
lines changedLines changed: 30 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
149 | | - | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
154 | 156 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
163 | 171 | | |
164 | | - | |
| 172 | + | |
165 | 173 | | |
166 | 174 | | |
167 | 175 | | |
| |||
180 | 188 | | |
181 | 189 | | |
182 | 190 | | |
183 | | - | |
| 191 | + | |
184 | 192 | | |
185 | 193 | | |
186 | | - | |
187 | | - | |
| 194 | + | |
188 | 195 | | |
189 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
190 | 206 | | |
191 | | - | |
192 | 207 | | |
193 | 208 | | |
194 | 209 | | |
| |||
0 commit comments