Skip to content

Commit

Permalink
Don't close URLClassLoader
Browse files Browse the repository at this point in the history
Closing the URLClassLoader seems to create an issue due to concurrency
nature of sbt. When another ClassLoader accesses a resource, the stream
is closed unexpectedly.

Change schema logging to better represent concurrent execution.
  • Loading branch information
RustedBones committed Jan 15, 2025
1 parent 2407602 commit ae2931b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
11 changes: 3 additions & 8 deletions bridge/src/main/java/com/github/sbt/avro/AvroCompilerBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,11 @@ public void compileIdls(File[] idls, File target) throws Exception {

@Override
public void compileAvscs(File[] avscs, File target) throws Exception {
List<File> files = new ArrayList<>(avscs.length);
for (File schema : avscs) {
System.out.println("Compiling Avro schema: " + schema);
files.add(schema);
}
Map<File, Schema> schemas = parser.parseFiles(files);

Map<File, Schema> schemas = parser.parseFiles(Arrays.asList(avscs));
for (Map.Entry<File, Schema> entry: schemas.entrySet()) {
File file = entry.getKey();
Schema schema = entry.getValue();
System.out.println("Compiling Avro schema: " + file + ":" + schema.getFullName());
SpecificCompiler compiler = new SpecificCompiler(schema);
configureCompiler(compiler);
compiler.compileToDestination(file, target);
Expand All @@ -119,7 +114,7 @@ public void compileAvprs(File[] avprs, File target) throws Exception {
Protocol protocol = Protocol.parse(avpr);
SpecificCompiler compiler = new SpecificCompiler(protocol);
configureCompiler(compiler);
compiler.compileToDestination(null, target);
compiler.compileToDestination(avpr, target);
}
}
}
1 change: 0 additions & 1 deletion plugin/src/main/scala/com/github/sbt/avro/SbtAvro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ object SbtAvro extends AutoPlugin {
throw new AvroGenerateFailedException
} finally {
Thread.currentThread().setContextClassLoader(initLoader)
avroClassLoader.close()
}
} else {
outReport.checked
Expand Down

0 comments on commit ae2931b

Please sign in to comment.