Bukkit/Bukkit — pull request #457 by Qala (2011-12-14 19:45:32+00:00)
Title: Fixed whitespace appearing at the top of .yml files on Windows

This was a PR against 1.9 (https://github.com/Bukkit/Bukkit/pull/407) which i thought resolved itself. Turns out i was wrong. Thanks @codename-b and @sleaker for pointing it out again!

The first and most important: *It doesn't occur in Linux!* I can reproduce it now on Win 7 with Java 1.6 and 1.7.0_01 but not in Debian with 1.6.0_26!

All of the the following were tested with own builds of the current master of Bukkit and 2d430c131bac7697778a62baf2f09d5569187a00 and Craftbukkit: 1e6a083075616c006395724694a3f9c2360b1a37 and also with Jenkins' b1602 on Windows 7.

The simplest possible plugin to reproduce the bug (I am testing with this):

public class testplugin1 extends JavaPlugin {
public void onEnable() {
FileConfiguration config = getConfig();
config.set("Key", "Value");
saveConfig();
}
}

I am starting with an empty config at first. With every server reload, onEnable is hit and rewrites the config.yml. I will check file size and look at its hexdump after every iteration.

After starting up CB: 13 bytes - some whitespace at the top of the file but no huge problem.
$ dump config.yml
config.yml:
00000000 0a0a 4b65 793a 2056 616c 7565 0a ..Key: Value.

After using "reload" command once in CB: 14 bytes - it added an LF (0x0a) to the beginning of the file.
$ dump config.yml
config.yml:
00000000 0a0a 0a4b 6579 3a20 5661 6c75 650a ...Key: Value.

After using "reload" once more: 15 bytes
$ dump config.yml
config.yml:
00000000 0a0a 0a0a 4b65 793a 2056 616c 7565 0a ....Key: Value.