Adds flush() to ensure the file contents are available in the following procedure.

This commit is contained in:
Robert van der Spek 2018-07-16 13:25:07 +02:00
parent 4e84a7cfe8
commit ab87227014
2 changed files with 5 additions and 1 deletions

View File

@ -260,8 +260,10 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
} else {
out = new OutputStreamWriter(new FileOutputStream(outFile), Charset.forName("UTF-8").newEncoder());
}
writeSiteMap(out);
out.flush();
if (autoValidate) SitemapValidator.validateWebSitemap(outFile);
} catch (IOException e) {
throw new RuntimeException("Problem writing sitemap file " + outFile, e);

View File

@ -228,6 +228,8 @@ public class SitemapIndexGenerator {
// TODO gzip? is that legal for a sitemap index?
out = new FileWriter(outFile);
writeSiteMap(out);
out.flush();
if (autoValidate) SitemapValidator.validateSitemapIndex(outFile);
} catch (IOException e) {
throw new RuntimeException("Problem writing sitemap index file " + outFile, e);