calum.org:~#

Cross-border Java development

Tags:

Added: 2016-07-11T20:55:07

Cross-border Java development

My first Java development job taught me a lot about international Java development.

I was working on a large back-end system ....

I'd write code and tests, run the tests locally, push, and run the integration tests on the Jenkins server. All would pass. I'd feel good about myself and go home.

The next morning I'd get in, and there'd be emails asking why I'd pushed tests that had failed. I'd be surprised, and run all my tests again. They'd all pass. There'd be some head-scratching, and eventually, we discovered what the problems were.

These are all tests that pass in English, in GMT, on Linux

Slashes


The most well known one is that you shouldn't use / or \ in file names. You should use File.pathSeparator.

Timezones



Locales



Character encoding


    @Rule
    public TemporaryFolder temp = new TemporaryFolder();

    @Test
    public void testCharacterEncoding() throws IOException {
        File tempFile = temp.newFile();

        byte[] outBytes = "Hello, Мир".getBytes();

        try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
            fileOutputStream.write(outBytes);
        }

        byte[] inBytes = new byte[outBytes.length];
        try (FileInputStream fileInputStream = new FileInputStream(tempFile)) {
            fileInputStream.read(inBytes);
        }

        assertArrayEquals("This will fail on Windows", outBytes, inBytes);
    }


Other things that can potentially trip you up.

File/directory path length



File/directory path characters

posted by Calum on 2099-07-11T12:00 under

Add a comment

Your IP:
Please enter 2702623 here: