dbmdz / iiif-apis

Java Domain Models for all IIIF APIs
MIT License
26 stars 9 forks source link

The mime.types file is a root-level resource and may cause unexpected behaviors in the class loader #270

Open francescopioscognamiglio opened 4 months ago

francescopioscognamiglio commented 4 months ago

Problem The mime.types file is placed at the root level of the resources. So, to load it we will use the class loader passing the file name (without any package) - as you can see here https://github.com/dbmdz/iif-apis/blob/main/src/main/java/de/digitalcollections/iif/model/MimeType.java#L45. This means that, depending on the class loader implementation, if you have multiple jars containing the same mime.type file at the root level, you may load the wrong file from another library.

Resolution A simple solution could be to move the mime.types to a specific package. Then, to load the resource, we can specify the package (for example de/digitalcollections/iiif/utils/mime.types).