Skip to content

[Ephemeris] core implementation's getUrl() fails with windows path notations #5472

@UdoKrie

Description

@UdoKrie

Expected Behavior

Calls to getBankHolidayName(ZonedDateTime, String) shall return.

Current Behavior

When the ephemeris binding calls this core function, an exception is thrown.
Working hypothesis is that getUrl() creates a malformed URL from the string passed, especially when windows paths are passed, starting with a drive letter, e.g. C:\.

Possible Solution

Change

            try {
                return new URL("file:" + filename);
            } catch (MalformedURLException e) {
                throw new FileNotFoundException(e.getMessage());
            }

to

            try {
                return filename.toURI().toURL();
            } catch (MalformedURLException e) {
                throw new FileNotFoundException(e.getMessage());
            }

Steps to Reproduce (for Bugs)

Discussions in thread https://community.openhab.org/t/ephemeris-custom-file-not-found/167428/4
0. have openHAB on Windows

  1. Use ephemeris binding
  2. create a custom thing
  3. Apply an ephemeris XML file
  4. See error message File is absent: ...

Context

Blocking for using custom ephemeris on windows installations

Your Environment

  • Version used: V5.1.3
  • Environment name and version openJDK 21
  • Operating System and version Windows Server 2019 / Windows 10 / Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn unexpected problem or unintended behavior of the Core

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions