Skip to content

Commit 0a71297

Browse files
authored
Fix bug with schema jar files (#733)
When using schemaJarFilesFromDependencies, the ZipFile was closed before the reader had read the actual schema file, resulting in an IOException being thrown.
1 parent 69f01a1 commit 0a71297

File tree

1 file changed

+7
-8
lines changed
  • graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen

1 file changed

+7
-8
lines changed

graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/CodeGen.kt

+7-8
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,13 @@ class CodeGen(private val config: CodeGenConfig) {
131131
loadSchemaReaders(readerBuilder, debugReaderBuilder)
132132
// process schema from dependencies
133133
config.schemaJarFilesFromDependencies.forEach { file ->
134-
ZipFile(file).use { zipFile ->
135-
for (entry in zipFile.entries()) {
136-
if (!entry.isDirectory && entry.name.startsWith("META-INF") &&
137-
(entry.name.endsWith(".graphqls") || entry.name.endsWith(".graphql"))
138-
) {
139-
logger.info("Generating schema from {}: {}", file.name, entry.name)
140-
readerBuilder.reader(zipFile.getInputStream(entry).reader(), "codegen")
141-
}
134+
val zipFile = ZipFile(file)
135+
for (entry in zipFile.entries()) {
136+
if (!entry.isDirectory && entry.name.startsWith("META-INF") &&
137+
(entry.name.endsWith(".graphqls") || entry.name.endsWith(".graphql"))
138+
) {
139+
logger.info("Generating schema from {}: {}", file.name, entry.name)
140+
readerBuilder.reader(zipFile.getInputStream(entry).reader(), "codegen")
142141
}
143142
}
144143
}

0 commit comments

Comments
 (0)