gdcc / xoai

OAI-PMH Java Toolkit
BSD 3-Clause "New" or "Revised" License
4 stars 3 forks source link

Refactor service-provider parsers handling streams #17

Open poikilotherm opened 2 years ago

poikilotherm commented 2 years ago

Currently parsers in package io.gdcc.xoai.serviceprovider.parsers are handed over an InputStream as constructor arguments. They build and save a XmlReader from this as class variable. This is bad, as the reader does not get burned (closed) after reading.

Two ways to refactor:

  1. Provide a reader instance, so the stream control is in the hand of the calling code.
  2. Provide the stream, but create the reader on the fly when calling code comes for parse(), using a try-with-resources.

Preferred approach: Do 2. Plus: make the parsing static. No need for instances. Make the stream be passed on then, to make it more explicit where the action happens.

poikilotherm commented 1 year ago

@landreev would this help?

poikilotherm commented 1 year ago

THis might be related to #141, as it could touch on reading the metadata response.