Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1715

Compiling a schema leaves the schema file open

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.7, 1.8.0
    • 1.8.0
    • java
    • None

    Description

      The schema compiler leaves the schema file open. This is demonstrated on the following code:

      File schemaFile = new File("schema.avsc");
      SpecificCompiler.compileSchema(new File[]

      { schemaFile }

      , new File("output"));
      Files.delete(schemaFile.toPath());

      On Windows I get "java.nio.file.FileSystemException: schema.avsc: The process cannot access the file because it is being used by another process."

      The problem is in Schema.java, method parse(File). This method creates a JsonParser for the schema file but never closes it, so the parser stays open together with the FileInputStream created by it. Closing the parser fixes the problem. I believe the same should be done for the other types of inputs as the json parsers do use more resources that should be freed. So I propose to close the parser in the parse(JsonParser) method. I will attach the patch.

      This is almost a blocker for our project and I would really appreciate if we can have this resolved for 1.8. Please let me know if that's possible and whether I should go ahead with merging the change myself (it's my first contribution here).

      Attachments

        1. Schema_close_parser.patch
          0.5 kB
          Pavel Safrata
        2. Schema_close_parser_v3.patch
          1 kB
          Pavel Safrata
        3. Schema_close_parser_v2.patch
          1 kB
          Pavel Safrata
        4. AVRO-1715.5.diff
          5 kB
          Pavel Safrata
        5. AVRO-1715.4.diff
          5 kB
          Ryan Blue

        Activity

          People

            pavel.safrata Pavel Safrata
            pavel.safrata Pavel Safrata
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: