Skip to content

Avoid methods relying on default locale or charset #127

@sebastian-nagel

Description

@sebastian-nagel

Methods relying on the System's default locale or character set may cause unexpected results:

jshell> import org.archive.url.WaybackURLKeyMaker;

jshell> WaybackURLKeyMaker surtKeyMaker = new WaybackURLKeyMaker(true);
surtKeyMaker ==> org.archive.url.WaybackURLKeyMaker@4534b60d

jshell> surtKeyMaker.makeKey("https://SITE.ORG/")
$3 ==> "org,site)/"

jshell> Locale.setDefault(Locale.of("tr", "TR"))

jshell> surtKeyMaker.makeKey("https://SITE.ORG/")
$5 ==> "org,s%c4%b1te)/"

For code bundle in a software library, it is good practice to avoid these methods and use the ROOT locale, see
https://blog.thetaphi.de/2012/07/default-locales-default-charsets-and.html.

A PR is underway adding Uwe Schindler's "forbidden APIs" Maven plugin and fixing all occurrences of methods relying on default locale or charset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions