Author: blue
Date: Tue Jan 12 17:07:59 2016
New Revision: 1724287
URL: http://svn.apache.org/viewvc?rev=1724287&view=rev
Log:
AVRO-1780: Java: Fix NPE in tools. Contributed by Tom White.
Changes for AVRO-1728 moved NOTICE, which was used to create the
no-argument output for Java's avro-tools. Using the new location fixed
the NPE and this also includes an update to show just the top of NOTICE
since it is now much longer.
Modified:
avro/trunk/lang/java/tools/src/main/java/org/apache/avro/tool/Main.java
Modified:
avro/trunk/lang/java/tools/src/main/java/org/apache/avro/tool/Main.java
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/java/tools/src/main/java/org/apache/avro/tool/Main.java?rev=1724287&r1=1724286&r2=1724287&view=diff
==============================================================================
--- avro/trunk/lang/java/tools/src/main/java/org/apache/avro/tool/Main.java
(original)
+++ avro/trunk/lang/java/tools/src/main/java/org/apache/avro/tool/Main.java Tue
Jan 12 17:07:59 2016
@@ -17,6 +17,8 @@
*/
package org.apache.avro.tool;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;
@@ -89,7 +91,7 @@ public class Main {
System.err.print("Version ");
printStream(Main.class.getClassLoader().getResourceAsStream("VERSION.txt"));
System.err.print(" of ");
- printStream(Main.class.getClassLoader().getResourceAsStream("NOTICE.txt"));
+
printHead(Main.class.getClassLoader().getResourceAsStream("META-INF/NOTICE"),
5);
System.err.println("----------------");
System.err.println("Available tools:");
@@ -106,4 +108,15 @@ public class Main {
System.err.write(buffer, 0, i);
}
+ private static void printHead(InputStream in, int lines) throws Exception {
+ BufferedReader r = new BufferedReader(new InputStreamReader(in));
+ for (int i = 0; i < lines; i++) {
+ String line = r.readLine();
+ if (line == null) {
+ break;
+ }
+ System.err.println(line);
+ }
+ }
+
}