rolang / dumbo

Simple database migration tool for Postgres with skunk on JVM and Native
MIT License
26 stars 3 forks source link

Loading migration files from resources doesn't work on windows #31

Closed lhns closed 5 months ago

lhns commented 6 months ago

Hi! I just noticed that loading the migration files from the resources directory doesn't work on windows. In ResourcesReader getClass().getResourceAsStream(path.toString) it uses the platform path separators which turns the resource path into \\db\migration\V001__init.sql but java only understands /db/migration/V001__init.sql so I get a NPE on getResourceAsStream.

fs2.CompositeFailure: Multiple exceptions were thrown (2), first java.lang.NullPointerException: Cannot invoke "java.io.InputStream.read(byte[], int, int)" because "is$1" is null
    at fs2.CompositeFailure$.apply(CompositeFailure.scala:58)
    at fs2.CompositeFailure$.apply(CompositeFailure.scala:45)
    at fs2.Pull$.addError$1(Pull.scala:1173)
    at fs2.Pull$.viewCont$1(Pull.scala:1180)
    at fs2.Pull$.$anonfun$compile$22(Pull.scala:1217)
    at get @ skunk.util.Pool$.free$1(Pool.scala:171)
    at flatMap @ fs2.Compiler$Target.flatMap(Compiler.scala:163)
    at flatMap @ fs2.Pull$.$anonfun$compile$21(Pull.scala:1215)
    at update @ skunk.util.StatementCache$$anon$2.put(StatementCache.scala:48)
    at flatMap @ fs2.Compiler$Target.flatMap(Compiler.scala:163)
    at flatMap @ fs2.Compiler$Target.flatMap(Compiler.scala:163)
    at flatMap @ fs2.Compiler$Target.flatMap(Compiler.scala:163)
    at flatMap @ fs2.Compiler$Target.flatMap(Compiler.scala:163)
    at update @ skunk.util.StatementCache$$anon$2.put(StatementCache.scala:48)
    at flatMap @ fs2.Compiler$Target.flatMap(Compiler.scala:163)
    at flatMap @ fs2.Compiler$Target.flatMap(Compiler.scala:163)
    at fromSync @ de.bitmarck.bms.zpc.datahub.Main$.applicationResource(Main.scala:75)
    at uncancelable @ fs2.Compiler$Target.uncancelable(Compiler.scala:165)
    at flatMap @ fs2.Compiler$Target.flatMap(Compiler.scala:163)
    at handleErrorWith @ fs2.Compiler$Target.handleErrorWith(Compiler.scala:161)
    at modify @ skunk.util.Pool$.$anonfun$ofF$2(Pool.scala:100)
Caused by: java.lang.NullPointerException: Cannot invoke "java.io.InputStream.read(byte[], int, int)" because "is$1" is null
    at fs2.io.package$.$anonfun$readInputStream$3(io.scala:48)
rolang commented 6 months ago

I see, thanks for reporting @lhns. Will fix that.