You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2017/03/11 13:54:36 UTC
asterixdb git commit: Read & Write License Files As UTF-8
Repository: asterixdb
Updated Branches:
refs/heads/master a7fad1993 -> 61401f980
Read & Write License Files As UTF-8
Change-Id: I167fbcf4cb913dc00ebdb84b406397ee412b4f1e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1570
Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
BAD: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <im...@apache.org>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/61401f98
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/61401f98
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/61401f98
Branch: refs/heads/master
Commit: 61401f980b66b117c522883b4884d16ec09ea1e6
Parents: a7fad19
Author: Michael Blow <mb...@apache.org>
Authored: Fri Mar 10 17:05:59 2017 -0500
Committer: Michael Blow <mb...@apache.org>
Committed: Sat Mar 11 05:54:12 2017 -0800
----------------------------------------------------------------------
.../hyracks/maven/license/DownloadLicensesMojo.java | 12 ++++++++----
.../apache/hyracks/maven/license/GenerateFileMojo.java | 9 ++++++---
.../org/apache/hyracks/maven/license/LicenseUtil.java | 7 +++++--
.../hyracks/maven/license/SupplementalModelHelper.java | 10 +++++++---
.../maven/license/freemarker/LoadFileDirective.java | 10 ++++++----
5 files changed, 32 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/61401f98/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/DownloadLicensesMojo.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/DownloadLicensesMojo.java b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/DownloadLicensesMojo.java
index 8219dfc..7d0e77d 100644
--- a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/DownloadLicensesMojo.java
+++ b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/DownloadLicensesMojo.java
@@ -19,11 +19,14 @@
package org.apache.hyracks.maven.license;
import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -77,9 +80,10 @@ public class DownloadLicensesMojo extends LicenseMojo {
final File outFile = new File(downloadDir, fileName);
getLog().info("[" + id + "] " + url + " -> " + outFile);
final InputStream is = conn.getInputStream();
- FileWriter writer = new FileWriter(outFile);
- IOUtils.copy(is, writer, conn.getContentEncoding());
- writer.close();
+ try (FileOutputStream fos = new FileOutputStream(outFile);
+ Writer writer = new OutputStreamWriter(fos, StandardCharsets.UTF_8)) {
+ IOUtils.copy(is, writer, conn.getContentEncoding());
+ }
getLog().info("[" + id + "] ...done!");
} catch (IOException e) {
getLog().warn("[" + id + "] ...error downloading " + url + ": " + e);
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/61401f98/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/GenerateFileMojo.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/GenerateFileMojo.java b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/GenerateFileMojo.java
index 262979a..387d18e 100644
--- a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/GenerateFileMojo.java
+++ b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/GenerateFileMojo.java
@@ -19,9 +19,11 @@
package org.apache.hyracks.maven.license;
import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStreamWriter;
import java.io.StringWriter;
+import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Comparator;
@@ -175,7 +177,7 @@ public class GenerateFileMojo extends LicenseMojo {
Configuration config = new Configuration();
config.setTemplateLoader(new FileTemplateLoader(templateRootDir));
for (GeneratedFile generation : generatedFiles) {
- Template template = config.getTemplate(generation.getTemplate());
+ Template template = config.getTemplate(generation.getTemplate(), StandardCharsets.UTF_8.name());
if (template == null) {
throw new IOException("Could not load template " + generation.getTemplate());
@@ -184,7 +186,8 @@ public class GenerateFileMojo extends LicenseMojo {
outputDir.mkdirs();
final File file = new File(outputDir, generation.getOutputFile());
getLog().info("Writing " + file + "...");
- try (final FileWriter writer = new FileWriter(file)) {
+ try (final FileOutputStream fos = new FileOutputStream(file);
+ final Writer writer = new OutputStreamWriter(fos, StandardCharsets.UTF_8)) {
template.process(props, writer);
}
}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/61401f98/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/LicenseUtil.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/LicenseUtil.java b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/LicenseUtil.java
index 8983160..30588d4 100644
--- a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/LicenseUtil.java
+++ b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/LicenseUtil.java
@@ -20,11 +20,13 @@ package org.apache.hyracks.maven.license;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
+import java.nio.charset.StandardCharsets;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@@ -65,7 +67,8 @@ public class LicenseUtil {
}
public static void readAndTrim(Writer out, File file) throws IOException {
- try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
+ try (FileInputStream fis = new FileInputStream(file);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(fis, StandardCharsets.UTF_8))) {
reader.mark((int) file.length() * 2);
trim(out, reader);
}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/61401f98/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/SupplementalModelHelper.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/SupplementalModelHelper.java b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/SupplementalModelHelper.java
index 5ba525a..7f33b46 100644
--- a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/SupplementalModelHelper.java
+++ b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/SupplementalModelHelper.java
@@ -19,8 +19,10 @@
package org.apache.hyracks.maven.license;
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collections;
@@ -73,8 +75,10 @@ public class SupplementalModelHelper {
log.debug("Loading supplemental models from " + f.getAbsolutePath());
SupplementalDataModelXpp3Reader reader = new SupplementalDataModelXpp3Reader();
- SupplementalDataModel supplementalModel = reader.read(new FileReader(f));
- supplements.addAll(supplementalModel.getSupplement());
+ try (FileInputStream fis = new FileInputStream(f); Reader fileReader = new InputStreamReader(fis)) {
+ SupplementalDataModel supplementalModel = reader.read(fileReader);
+ supplements.addAll(supplementalModel.getSupplement());
+ }
} catch (Exception e) {
String msg = "Error loading supplemental data models: " + e.getMessage();
log.error(msg, e);
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/61401f98/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/freemarker/LoadFileDirective.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/freemarker/LoadFileDirective.java b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/freemarker/LoadFileDirective.java
index 61d84f1..67da23f 100644
--- a/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/freemarker/LoadFileDirective.java
+++ b/hyracks-fullstack/hyracks/hyracks-maven-plugins/license-automation-plugin/src/main/java/org/apache/hyracks/maven/license/freemarker/LoadFileDirective.java
@@ -19,11 +19,15 @@
package org.apache.hyracks.maven.license.freemarker;
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.Writer;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
+import org.apache.commons.io.IOUtils;
+import org.apache.hyracks.maven.license.LicenseUtil;
+
import freemarker.cache.FileTemplateLoader;
import freemarker.core.Environment;
import freemarker.template.Configuration;
@@ -34,8 +38,6 @@ import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import freemarker.template.TemplateScalarModel;
-import org.apache.hyracks.maven.license.LicenseUtil;
-import org.apache.commons.io.IOUtils;
public class LoadFileDirective implements TemplateDirectiveModel {
@@ -104,7 +106,7 @@ public class LoadFileDirective implements TemplateDirectiveModel {
LicenseUtil.readAndTrim(out, file);
out.write('\n');
} else {
- IOUtils.copy(new FileReader(file), out);
+ IOUtils.copy(new FileInputStream(file), out, StandardCharsets.UTF_8);
}
} else if (defaultParam != null ) {
out.append(defaultParam).append("\n");