marschall / memoryfilesystem

An in memory implementation of a JSR-203 file system
282 stars 36 forks source link

Wrong index referenced in exception message for subpath #158

Closed mgrafl closed 5 months ago

mgrafl commented 6 months ago

The checkNameRange method (e.g., call by subpath), incorrectly uses beginIndex in https://github.com/marschall/memoryfilesystem/blob/4527dcd3efb68371bf781f701120061dfd250f54/src/main/java/com/github/marschall/memoryfilesystem/NonEmptyPath.java#L118 and https://github.com/marschall/memoryfilesystem/blob/4527dcd3efb68371bf781f701120061dfd250f54/src/main/java/com/github/marschall/memoryfilesystem/NonEmptyPath.java#L121 when it should use endIndex.

marschall commented 5 months ago

Good catch! How did you find it?

mgrafl commented 5 months ago

Good catch! How did you find it?

Thanks for the quick resolution!

I wrote a unit test that used Path#subpath(...) but accidentally used the wrong endIndex, so I saw that the exception message parameters were mixed up.