You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by ni...@apache.org on 2016/05/02 17:36:25 UTC
[08/12] avro git commit: AVRO-1828: Add EditorConfig file and cleanup
of whitespace violations
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/LegacyBinaryEncoder.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/LegacyBinaryEncoder.java b/lang/java/avro/src/test/java/org/apache/avro/io/LegacyBinaryEncoder.java
index ea8d778..e8b1b0a 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/LegacyBinaryEncoder.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/LegacyBinaryEncoder.java
@@ -43,11 +43,11 @@ import org.apache.avro.util.Utf8;
*/
public class LegacyBinaryEncoder extends Encoder {
protected OutputStream out;
-
+
private interface ByteWriter {
void write(ByteBuffer bytes) throws IOException;
}
-
+
private static final class SimpleByteWriter implements ByteWriter {
private final OutputStream out;
@@ -61,7 +61,7 @@ public class LegacyBinaryEncoder extends Encoder {
out.write(bytes.array(), bytes.position(), bytes.remaining());
}
}
-
+
private final ByteWriter byteWriter;
/** Create a writer that sends its output to the underlying stream
@@ -80,7 +80,7 @@ public class LegacyBinaryEncoder extends Encoder {
@Override
public void writeNull() throws IOException { }
-
+
@Override
public void writeBoolean(boolean b) throws IOException {
out.write(b ? 1 : 0);
@@ -95,7 +95,7 @@ public class LegacyBinaryEncoder extends Encoder {
public void writeLong(long n) throws IOException {
encodeLong(n, out);
}
-
+
@Override
public void writeFloat(float f) throws IOException {
encodeFloat(f, out);
@@ -110,29 +110,29 @@ public class LegacyBinaryEncoder extends Encoder {
public void writeString(Utf8 utf8) throws IOException {
encodeString(utf8.getBytes(), 0, utf8.getByteLength());
}
-
+
@Override
public void writeString(String string) throws IOException {
byte[] bytes = Utf8.getBytesFor(string);
encodeString(bytes, 0, bytes.length);
}
-
+
private void encodeString(byte[] bytes, int offset, int length) throws IOException {
encodeLong(length, out);
out.write(bytes, offset, length);
}
-
+
@Override
public void writeBytes(ByteBuffer bytes) throws IOException {
byteWriter.write(bytes);
}
-
+
@Override
public void writeBytes(byte[] bytes, int start, int len) throws IOException {
encodeLong(len, out);
out.write(bytes, start, len);
}
-
+
@Override
public void writeFixed(byte[] bytes, int start, int len) throws IOException {
out.write(bytes, start, len);
@@ -153,7 +153,7 @@ public class LegacyBinaryEncoder extends Encoder {
writeLong(itemCount);
}
}
-
+
@Override
public void startItem() throws IOException {
}
@@ -176,7 +176,7 @@ public class LegacyBinaryEncoder extends Encoder {
public void writeIndex(int unionIndex) throws IOException {
encodeLong(unionIndex, out);
}
-
+
protected static void encodeLong(long n, OutputStream o) throws IOException {
n = (n << 1) ^ (n >> 63); // move sign to low-order bit
while ((n & ~0x7F) != 0) {
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/TestBinaryDecoder.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestBinaryDecoder.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestBinaryDecoder.java
index aa3e1d7..572be60 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/TestBinaryDecoder.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestBinaryDecoder.java
@@ -52,7 +52,7 @@ public class TestBinaryDecoder {
public TestBinaryDecoder(boolean useDirect) {
this.useDirect = useDirect;
}
-
+
@Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
@@ -60,7 +60,7 @@ public class TestBinaryDecoder {
{ false },
});
}
-
+
private Decoder newDecoderWithNoData() throws IOException {
return newDecoder(new byte[0]);
}
@@ -68,7 +68,7 @@ public class TestBinaryDecoder {
private Decoder newDecoder(byte[] bytes, int start, int len)
throws IOException {
return factory.binaryDecoder(bytes, start, len, null);
-
+
}
private Decoder newDecoder(InputStream in) {
@@ -89,37 +89,37 @@ public class TestBinaryDecoder {
public void testEOFBoolean() throws IOException {
newDecoderWithNoData().readBoolean();
}
-
+
@Test(expected=EOFException.class)
public void testEOFInt() throws IOException {
newDecoderWithNoData().readInt();
}
-
+
@Test(expected=EOFException.class)
public void testEOFLong() throws IOException {
newDecoderWithNoData().readLong();
}
-
+
@Test(expected=EOFException.class)
public void testEOFFloat() throws IOException {
newDecoderWithNoData().readFloat();
}
-
+
@Test(expected=EOFException.class)
public void testEOFDouble() throws IOException {
newDecoderWithNoData().readDouble();
}
-
+
@Test(expected=EOFException.class)
public void testEOFBytes() throws IOException {
newDecoderWithNoData().readBytes(null);
}
-
+
@Test(expected=EOFException.class)
public void testEOFString() throws IOException {
newDecoderWithNoData().readString(new Utf8("a"));
}
-
+
@Test(expected=EOFException.class)
public void testEOFFixed() throws IOException {
newDecoderWithNoData().readFixed(new byte[1]);
@@ -129,32 +129,32 @@ public class TestBinaryDecoder {
public void testEOFEnum() throws IOException {
newDecoderWithNoData().readEnum();
}
-
+
@Test
public void testReuse() throws IOException {
ByteBufferOutputStream bbo1 = new ByteBufferOutputStream();
ByteBufferOutputStream bbo2 = new ByteBufferOutputStream();
byte[] b1 = new byte[] { 1, 2 };
-
+
BinaryEncoder e1 = e_factory.binaryEncoder(bbo1, null);
e1.writeBytes(b1);
e1.flush();
-
+
BinaryEncoder e2 = e_factory.binaryEncoder(bbo2, null);
e2.writeBytes(b1);
e2.flush();
-
+
DirectBinaryDecoder d = new DirectBinaryDecoder(
new ByteBufferInputStream(bbo1.getBufferList()));
ByteBuffer bb1 = d.readBytes(null);
Assert.assertEquals(b1.length, bb1.limit() - bb1.position());
-
+
d.configure(new ByteBufferInputStream(bbo2.getBufferList()));
ByteBuffer bb2 = d.readBytes(null);
Assert.assertEquals(b1.length, bb2.limit() - bb2.position());
-
+
}
-
+
private static byte[] data = null;
private static int seed = -1;
private static Schema schema = null;
@@ -180,7 +180,7 @@ public class TestBinaryDecoder {
writer.setSchema(schema);
ByteArrayOutputStream baos = new ByteArrayOutputStream(8192);
BinaryEncoder encoder = e_factory.binaryEncoder(baos, null);
-
+
for (Object datum : new RandomData(schema, count, seed)) {
writer.write(datum, encoder);
records.add(datum);
@@ -193,14 +193,14 @@ public class TestBinaryDecoder {
public void testDecodeFromSources() throws IOException {
GenericDatumReader<Object> reader = new GenericDatumReader<Object>();
reader.setSchema(schema);
-
+
ByteArrayInputStream is = new ByteArrayInputStream(data);
ByteArrayInputStream is2 = new ByteArrayInputStream(data);
ByteArrayInputStream is3 = new ByteArrayInputStream(data);
Decoder fromInputStream = newDecoder(is);
Decoder fromArray = newDecoder(data);
-
+
byte[] data2 = new byte[data.length + 30];
Arrays.fill(data2, (byte)0xff);
System.arraycopy(data, 0, data2, 15, data.length);
@@ -213,7 +213,7 @@ public class TestBinaryDecoder {
BinaryDecoder initOnArray = factory.binaryDecoder(is3, null);
initOnArray = factory.binaryDecoder(
data, 0, data.length, initOnArray);
-
+
for (Object datum : records) {
Assert.assertEquals(
"InputStream based BinaryDecoder result does not match",
@@ -272,7 +272,7 @@ public class TestBinaryDecoder {
Assert.assertFalse(bad.read() == check2.read());
}
}
-
+
@Test
public void testInputStreamPartiallyUsed() throws IOException {
BinaryDecoder bd = factory.binaryDecoder(
@@ -281,7 +281,7 @@ public class TestBinaryDecoder {
InputStream check = new ByteArrayInputStream(data);
// triggers buffer fill if unused and tests isEnd()
try {
- Assert.assertFalse(bd.isEnd());
+ Assert.assertFalse(bd.isEnd());
} catch (UnsupportedOperationException e) {
// this is ok if its a DirectBinaryDecoder.
if (bd.getClass() != DirectBinaryDecoder.class) {
@@ -296,7 +296,7 @@ public class TestBinaryDecoder {
private void validateInputStreamReads(InputStream test, InputStream check)
throws IOException {
byte[] bt = new byte[7];
- byte[] bc = new byte[7];
+ byte[] bc = new byte[7];
while (true) {
int t = test.read();
int c = check.read();
@@ -318,7 +318,7 @@ public class TestBinaryDecoder {
Assert.assertFalse(test.getClass() != ByteArrayInputStream.class && test.markSupported());
test.close();
}
-
+
private void validateInputStreamSkips(InputStream test, InputStream check) throws IOException {
while(true) {
long t2 = test.skip(19);
@@ -383,7 +383,7 @@ public class TestBinaryDecoder {
Arrays.fill(badint, (byte)0xff);
newDecoder(badint).readLong();
}
-
+
@Test(expected=EOFException.class)
public void testFloatTooShort() throws IOException {
byte[] badint = new byte[3];
@@ -435,7 +435,7 @@ public class TestBinaryDecoder {
bd.skipFixed(8);
long leftover = bd.skipArray();
// booleans are one byte, array trailer is one byte
- bd.skipFixed((int)leftover + 1);
+ bd.skipFixed((int)leftover + 1);
bd.skipFixed(0);
bd.readLong();
}
@@ -447,14 +447,14 @@ public class TestBinaryDecoder {
}
Assert.assertTrue(null != eof);
}
-
+
@Test(expected = EOFException.class)
public void testEOF() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Encoder e = EncoderFactory.get().binaryEncoder(baos, null);
e.writeLong(0x10000000000000l);
e.flush();
-
+
Decoder d = newDecoder(new ByteArrayInputStream(baos.toByteArray()));
Assert.assertEquals(0x10000000000000l, d.readLong());
d.readInt();
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/TestBinaryEncoderFidelity.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestBinaryEncoderFidelity.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestBinaryEncoderFidelity.java
index 997ab94..505798a 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/TestBinaryEncoderFidelity.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestBinaryEncoderFidelity.java
@@ -28,7 +28,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
public class TestBinaryEncoderFidelity {
-
+
static byte[] legacydata;
static byte[] complexdata;
EncoderFactory factory = EncoderFactory.get();
@@ -116,7 +116,7 @@ public class TestBinaryEncoderFidelity {
}
e.flush();
}
-
+
static void generateComplexData(Encoder e) throws IOException {
e.writeArrayStart();
e.setItemCount(1);
@@ -136,7 +136,7 @@ public class TestBinaryEncoderFidelity {
e.writeMapEnd();
e.flush();
}
-
+
@BeforeClass
public static void generateLegacyData() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -147,7 +147,7 @@ public class TestBinaryEncoderFidelity {
generateComplexData(e);
complexdata = baos.toByteArray();
}
-
+
@Test
public void testBinaryEncoder() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -162,7 +162,7 @@ public class TestBinaryEncoderFidelity {
Assert.assertEquals(complexdata.length, result2.length);
Assert.assertArrayEquals(complexdata, result2);
}
-
+
@Test
public void testDirectBinaryEncoder() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -178,7 +178,7 @@ public class TestBinaryEncoderFidelity {
Assert.assertArrayEquals(complexdata, result2);
}
-
+
@Test
public void testBlockingBinaryEncoder() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/TestBlockingIO.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestBlockingIO.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestBlockingIO.java
index 95729fe..f6cb76b 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/TestBlockingIO.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestBlockingIO.java
@@ -47,33 +47,33 @@ public class TestBlockingIO {
this.iDepth = dp;
this.sInput = inp;
}
-
+
private static class Tests {
private final JsonParser parser;
private final Decoder input;
private final int depth;
public Tests(int bufferSize, int depth, String input)
throws IOException {
-
+
this.depth = depth;
byte[] in = input.getBytes("UTF-8");
JsonFactory f = new JsonFactory();
JsonParser p = f.createJsonParser(
new ByteArrayInputStream(input.getBytes("UTF-8")));
-
+
ByteArrayOutputStream os = new ByteArrayOutputStream();
EncoderFactory factory = new EncoderFactory()
.configureBlockSize(bufferSize);
Encoder cos = factory.blockingBinaryEncoder(os, null);
serialize(cos, p, os);
cos.flush();
-
+
byte[] bb = os.toByteArray();
// dump(bb);
this.input = DecoderFactory.get().binaryDecoder(bb, null);
this.parser = f.createJsonParser(new ByteArrayInputStream(in));
}
-
+
public void scan() throws IOException {
Stack<S> countStack = new Stack<S>();
long count = 0;
@@ -208,7 +208,7 @@ public class TestBlockingIO {
private static class S {
public final long count;
public final boolean isArray;
-
+
public S(long count, boolean isArray) {
this.count = count;
this.isArray = isArray;
@@ -270,7 +270,7 @@ public class TestBlockingIO {
}
parser.skipChildren();
}
-
+
private static void checkString(String s, Decoder input, int n)
throws IOException {
ByteBuffer buf = input.readBytes(null);
@@ -279,14 +279,14 @@ public class TestBlockingIO {
buf.remaining(), UTF_8);
assertEquals(s, s2);
}
-
+
private static void serialize(Encoder cos, JsonParser p,
ByteArrayOutputStream os)
throws IOException {
boolean[] isArray = new boolean[100];
int[] counts = new int[100];
int stackTop = -1;
-
+
while (p.nextToken() != null) {
switch (p.getCurrentToken()) {
case END_ARRAY:
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/TestBlockingIO2.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestBlockingIO2.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestBlockingIO2.java
index 6438a60..5bb6c84 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/TestBlockingIO2.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestBlockingIO2.java
@@ -38,7 +38,7 @@ public class TestBlockingIO2 {
private final Decoder decoder;
private final String calls;
private Object[] values;
-
+
public TestBlockingIO2 (int bufferSize, int skipLevel, String calls)
throws IOException {
@@ -50,13 +50,13 @@ public class TestBlockingIO2 {
TestValidatingIO.generate(encoder, calls, values);
encoder.flush();
-
+
byte[] bb = os.toByteArray();
-
+
decoder = DecoderFactory.get().binaryDecoder(bb, null);
this.calls = calls;
}
-
+
@Test
public void testScan() throws IOException {
TestValidatingIO.check(decoder, calls, values, -1);
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java
index 46a9025..4d16f16 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestEncoders.java
@@ -41,7 +41,7 @@ public class TestEncoders {
BinaryEncoder enc = factory.binaryEncoder(out, null);
Assert.assertTrue(enc == factory.binaryEncoder(out, enc));
}
-
+
@Test(expected=NullPointerException.class)
public void testBadBinaryEncoderInit() {
factory.binaryEncoder(null, null);
@@ -53,21 +53,21 @@ public class TestEncoders {
BinaryEncoder reuse = null;
reuse = factory.blockingBinaryEncoder(out, reuse);
Assert.assertTrue(reuse == factory.blockingBinaryEncoder(out, reuse));
- // comparison
+ // comparison
}
-
+
@Test(expected=NullPointerException.class)
public void testBadBlockintBinaryEncoderInit() {
factory.binaryEncoder(null, null);
}
-
+
@Test
public void testDirectBinaryEncoderInit() throws IOException {
OutputStream out = new ByteArrayOutputStream();
BinaryEncoder enc = factory.directBinaryEncoder(out, null);
Assert.assertTrue(enc == factory.directBinaryEncoder(out, enc));
}
-
+
@Test(expected=NullPointerException.class)
public void testBadDirectBinaryEncoderInit() {
factory.directBinaryEncoder(null, null);
@@ -82,12 +82,12 @@ public class TestEncoders {
new JsonFactory().createJsonGenerator(out, JsonEncoding.UTF8));
enc.configure(out);
}
-
+
@Test(expected=NullPointerException.class)
public void testBadJsonEncoderInitOS() throws IOException {
factory.jsonEncoder(Schema.create(Type.INT), (OutputStream)null);
}
-
+
@Test(expected=NullPointerException.class)
public void testBadJsonEncoderInit() throws IOException {
factory.jsonEncoder(Schema.create(Type.INT), (JsonGenerator)null);
@@ -119,7 +119,7 @@ public class TestEncoders {
String value = "{\"b\": 2, \"a\": 1}";
Schema schema = new Schema.Parser().parse("{\"type\": \"record\", \"name\": \"ab\", \"fields\": [" +
"{\"name\": \"a\", \"type\": \"int\"}, {\"name\": \"b\", \"type\": \"int\"}" +
- "]}");
+ "]}");
GenericDatumReader<Object> reader = new GenericDatumReader<Object>(schema);
Decoder decoder = DecoderFactory.get().jsonDecoder(schema, value);
Object o = reader.read(null, decoder);
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/TestJsonDecoder.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestJsonDecoder.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestJsonDecoder.java
index 7946beb..4ac07eb 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/TestJsonDecoder.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestJsonDecoder.java
@@ -26,7 +26,7 @@ import org.junit.Test;
import org.junit.Assert;
public class TestJsonDecoder {
-
+
@Test public void testInt() throws Exception {
checkNumeric("int", 1);
}
@@ -44,7 +44,7 @@ public class TestJsonDecoder {
}
private void checkNumeric(String type, Object value) throws Exception {
- String def =
+ String def =
"{\"type\":\"record\",\"name\":\"X\",\"fields\":"
+"[{\"type\":\""+type+"\",\"name\":\"n\"}]}";
Schema schema = Schema.parse(def);
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIO.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIO.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIO.java
index d5f1b06..3cdc7e5 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIO.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIO.java
@@ -51,7 +51,7 @@ public class TestResolvingIO {
this.sJsRdrSchm = jsonReaderSchema;
this.sRdrCls = readerCalls;
}
-
+
@Test
public void testIdentical() throws IOException {
performTest(eEnc, iSkipL, sJsWrtSchm, sWrtCls, sJsWrtSchm, sWrtCls);
@@ -66,7 +66,7 @@ public class TestResolvingIO {
private void performTest(Encoding encoding,
int skipLevel, String jsonWriterSchema,
- String writerCalls,
+ String writerCalls,
String jsonReaderSchema, String readerCalls)
throws IOException {
for (int i = 0; i < COUNT; i++) {
@@ -74,7 +74,7 @@ public class TestResolvingIO {
jsonReaderSchema, readerCalls, encoding, skipLevel);
}
}
-
+
private void testOnce(String jsonWriterSchema,
String writerCalls,
String jsonReaderSchema,
@@ -83,7 +83,7 @@ public class TestResolvingIO {
int skipLevel) throws IOException {
Object[] values = TestValidatingIO.randomValues(writerCalls);
Object[] expected = TestValidatingIO.randomValues(readerCalls);
-
+
Schema writerSchema = new Schema.Parser().parse(jsonWriterSchema);
byte[] bytes = TestValidatingIO.make(writerSchema, writerCalls,
values, encoding);
@@ -114,7 +114,7 @@ public class TestResolvingIO {
Decoder vi = new ResolvingDecoder(wsc, rsc, bvi);
TestValidatingIO.check(vi, calls, values, skipLevel);
}
-
+
@Parameterized.Parameters
public static Collection<Object[]> data2() {
return Arrays.asList(TestValidatingIO.convertTo2dArray(encodings, skipLevels, testSchemas()));
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java
index e6377b5..b722e76 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java
@@ -190,8 +190,8 @@ public class TestResolvingIOResolving {
+ "{\"name\":\"f3\", \"type\":\"double\"}]}", "BLD",
new Object[] { true, 100L, 10.75d } },
// Array of record with arrays.
- { "{ \"type\": \"array\", \"items\":" +
- "{\"type\":\"record\",\"name\":\"r\",\"fields\":["
+ { "{ \"type\": \"array\", \"items\":" +
+ "{\"type\":\"record\",\"name\":\"r\",\"fields\":["
+ "{\"name\":\"f0\", \"type\":\"boolean\"},"
+ "{\"name\":\"f1\", \"type\": {\"type\":\"array\", \"items\": \"boolean\" }}"
+ "]}}", "[c2sB[c2sBsB]sB[c3sBsBsB]]",
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/TestValidatingIO.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/TestValidatingIO.java b/lang/java/avro/src/test/java/org/apache/avro/io/TestValidatingIO.java
index bfec06d..792a987 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/TestValidatingIO.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/TestValidatingIO.java
@@ -48,10 +48,10 @@ public class TestValidatingIO {
BLOCKING_BINARY,
JSON,
}
-
+
private static final Logger LOG =
LoggerFactory.getLogger(TestValidatingIO.class);
-
+
private Encoding eEnc;
private int iSkipL;
private String sJsSch;
@@ -64,7 +64,7 @@ public class TestValidatingIO {
this.sCl = cls;
}
private static final int COUNT = 1;
-
+
@Test
public void testMain() throws IOException {
for (int i = 0; i < COUNT; i++) {
@@ -98,7 +98,7 @@ public class TestValidatingIO {
bvo = factory.jsonEncoder(sc, ba);
break;
}
-
+
Encoder vo = factory.validatingEncoder(sc, bvo);
generate(vo, calls, values);
vo.flush();
@@ -108,22 +108,22 @@ public class TestValidatingIO {
public static class InputScanner {
private final char[] chars;
private int cpos = 0;
-
+
public InputScanner(char[] chars) {
this.chars = chars;
}
-
+
public boolean next() {
if (cpos < chars.length) {
cpos++;
}
return cpos != chars.length;
}
-
+
public char cur() {
return chars[cpos];
}
-
+
public boolean isDone() {
return cpos == chars.length;
}
@@ -319,7 +319,7 @@ public class TestValidatingIO {
Decoder vi = new ValidatingDecoder(sc, bvi);
check(vi, calls, values, skipLevel);
}
-
+
public static void check(Decoder vi, String calls,
Object[] values, final int skipLevel) throws IOException {
InputScanner cs = new InputScanner(calls.toCharArray());
@@ -523,16 +523,16 @@ public class TestValidatingIO {
public static Collection<Object[]> data() {
return Arrays.asList(convertTo2dArray(encodings, skipLevels, testSchemas()));
}
-
+
private static Object[][] encodings = new Object[][] {
{ Encoding.BINARY }, { Encoding.BLOCKING_BINARY },
{ Encoding.JSON }
- };
+ };
private static Object[][] skipLevels = new Object[][] {
{ -1 }, { 0 }, { 1 }, { 2 },
};
-
+
public static Object[][] convertTo2dArray(final Object[][]... values) {
ArrayList<Object[]> ret = new ArrayList<Object[]>();
@@ -582,7 +582,7 @@ public class TestValidatingIO {
}
};
}
-
+
/**
* Concatenates the input sequences in order and forms a longer sequence.
*/
@@ -730,7 +730,7 @@ public class TestValidatingIO {
+ "{\"name\":\"f6\", \"type\":\"string\"},"
+ "{\"name\":\"f7\", \"type\":\"bytes\"}]}",
"NBILFDS10b25" },
-
+
// record of records
{ "{\"type\":\"record\",\"name\":\"outer\",\"fields\":["
+ "{\"name\":\"f1\", \"type\":{\"type\":\"record\", "
@@ -796,14 +796,14 @@ public class TestValidatingIO {
{ "[\"boolean\", {\"type\":\"array\", \"items\":\"int\"} ]",
"U1[c1sI]" },
-
+
// Recursion
{ "{\"type\": \"record\", \"name\": \"Node\", \"fields\": ["
+ "{\"name\":\"label\", \"type\":\"string\"},"
+ "{\"name\":\"children\", \"type\":"
+ "{\"type\": \"array\", \"items\": \"Node\" }}]}",
"S10[c1sS10[]]" },
-
+
{ "{\"type\": \"record\", \"name\": \"Lisp\", \"fields\": ["
+ "{\"name\":\"value\", \"type\":[\"null\", \"string\","
+ "{\"type\": \"record\", \"name\": \"Cons\", \"fields\": ["
@@ -822,16 +822,16 @@ public class TestValidatingIO {
+ "{\"name\":\"car\", \"type\":\"Lisp\"},"
+ "{\"name\":\"cdr\", \"type\":\"Lisp\"}]}]}]}",
"U2U1S10U0N"},
-
+
// Deep recursion
{ "{\"type\": \"record\", \"name\": \"Node\", \"fields\": ["
+ "{\"name\":\"children\", \"type\":"
+ "{\"type\": \"array\", \"items\": \"Node\" }}]}",
"[c1s[c1s[c1s[c1s[c1s[c1s[c1s[c1s[c1s[c1s[c1s[]]]]]]]]]]]]" },
-
+
};
}
-
+
static void dump(byte[] bb) {
int col = 0;
for (byte b : bb) {
@@ -844,17 +844,17 @@ public class TestValidatingIO {
System.out.println();
}
- static void print(Encoding encoding, int skipLevel, Schema writerSchema,
+ static void print(Encoding encoding, int skipLevel, Schema writerSchema,
Schema readerSchema, Object[] writtenValues, Object[] expectedValues) {
- LOG.debug("{} Skip Level {}", encoding, skipLevel);
+ LOG.debug("{} Skip Level {}", encoding, skipLevel);
printSchemaAndValues("Writer", writerSchema, writtenValues);
printSchemaAndValues("Reader", readerSchema, expectedValues);
}
private static void printSchemaAndValues(String schemaType, Schema schema, Object[] values) {
- LOG.debug("{} Schema {}", schemaType, schema);
+ LOG.debug("{} Schema {}", schemaType, schema);
for (Object value : values) {
LOG.debug("{} -> {}", value, value.getClass().getSimpleName());
}
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/parsing/TestResolvingGrammarGenerator.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/parsing/TestResolvingGrammarGenerator.java b/lang/java/avro/src/test/java/org/apache/avro/io/parsing/TestResolvingGrammarGenerator.java
index 142d104..2d9a83e 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/parsing/TestResolvingGrammarGenerator.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/parsing/TestResolvingGrammarGenerator.java
@@ -47,7 +47,7 @@ import org.junit.runners.Parameterized;
public class TestResolvingGrammarGenerator {
private final Schema schema;
private final JsonNode data;
-
+
public TestResolvingGrammarGenerator(String jsonSchema, String jsonData)
throws IOException {
this.schema = Schema.parse(jsonSchema);
@@ -61,9 +61,9 @@ public class TestResolvingGrammarGenerator {
public void test() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
EncoderFactory factory = EncoderFactory.get();
- Encoder e = factory.validatingEncoder(schema,
+ Encoder e = factory.validatingEncoder(schema,
factory.binaryEncoder(baos, null));
-
+
ResolvingGrammarGenerator.encode(e, schema, data);
e.flush();
}
@@ -91,7 +91,7 @@ public class TestResolvingGrammarGenerator {
"Found ns.MyRecord, expecting ns.MyRecord, missing required field field2", typeException.getMessage());
}
}
-
+
@Parameterized.Parameters
public static Collection<Object[]> data() {
Collection<Object[]> ret = Arrays.asList(
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/io/parsing/TestResolvingGrammarGenerator2.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/io/parsing/TestResolvingGrammarGenerator2.java b/lang/java/avro/src/test/java/org/apache/avro/io/parsing/TestResolvingGrammarGenerator2.java
index 1b5ac6f..ea9ed1a 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/io/parsing/TestResolvingGrammarGenerator2.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/io/parsing/TestResolvingGrammarGenerator2.java
@@ -26,7 +26,7 @@ import org.junit.Assert;
import org.junit.Test;
/** ResolvingGrammarGenerator tests that are not Parameterized.*/
-public class TestResolvingGrammarGenerator2 {
+public class TestResolvingGrammarGenerator2 {
@Test public void testFixed() throws java.io.IOException {
new ResolvingGrammarGenerator().generate
(Schema.createFixed("MyFixed", null, null, 10),
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/reflect/TestByteBuffer.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/reflect/TestByteBuffer.java b/lang/java/avro/src/test/java/org/apache/avro/reflect/TestByteBuffer.java
index e48fd14..602d39e 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/reflect/TestByteBuffer.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/reflect/TestByteBuffer.java
@@ -67,9 +67,9 @@ public class TestByteBuffer {
@Test public void test() throws Exception{
Schema schema = ReflectData.get().getSchema(X.class);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
- writeOneXAsAvro(schema, bout);
+ writeOneXAsAvro(schema, bout);
X record = readOneXFromAvro(schema, bout);
-
+
String expected = getmd5(content);
String actual = getmd5(record.content);
assertEquals("md5 for result differed from input",expected,actual);
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/reflect/TestNonStringMapKeys.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/reflect/TestNonStringMapKeys.java b/lang/java/avro/src/test/java/org/apache/avro/reflect/TestNonStringMapKeys.java
index 41f508c..3267529 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/reflect/TestNonStringMapKeys.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/reflect/TestNonStringMapKeys.java
@@ -59,7 +59,7 @@ public class TestNonStringMapKeys {
String testType = "NonStringKeysTest";
Company [] entityObjs = {entityObj1, entityObj2};
byte[] bytes = testSerialization(testType, entityObj1, entityObj2);
- List<GenericRecord> records =
+ List<GenericRecord> records =
(List<GenericRecord>) testGenericDatumRead(testType, bytes, entityObjs);
GenericRecord record = records.get(0);
@@ -76,7 +76,7 @@ public class TestNonStringMapKeys {
Object id = ((GenericRecord)key).get("id");
Object name = ((GenericRecord)value).get("name").toString();
assertTrue (
- (id.equals(1) && name.equals("Foo")) ||
+ (id.equals(1) && name.equals("Foo")) ||
(id.equals(2) && name.equals("Bar"))
);
@@ -92,7 +92,7 @@ public class TestNonStringMapKeys {
id = e.getKey().getId();
name = e.getValue().getName();
assertTrue (
- (id.equals(1) && name.equals("Foo")) ||
+ (id.equals(1) && name.equals("Foo")) ||
(id.equals(2) && name.equals("Bar"))
);
}
@@ -103,7 +103,7 @@ public class TestNonStringMapKeys {
GenericRecord jsonRecord = testJsonDecoder(testType, jsonBytes, entityObj1);
assertEquals ("JSON decoder output not same as Binary Decoder", record, jsonRecord);
}
-
+
@Test
public void testNonStringMapKeysInNestedMaps() throws Exception {
@@ -119,7 +119,7 @@ public class TestNonStringMapKeys {
Object employees = record.get("employees");
assertTrue ("Unable to read 'employees' map", employees instanceof GenericArray);
GenericArray employeesMapArray = ((GenericArray)employees);
-
+
Object employeeMapElement = employeesMapArray.get(0);
assertTrue (employeeMapElement instanceof GenericRecord);
Object key = ((GenericRecord)employeeMapElement).get(ReflectData.NS_MAP_KEY);
@@ -129,11 +129,11 @@ public class TestNonStringMapKeys {
GenericRecord employeeInfo = (GenericRecord)value;
Object name = employeeInfo.get("name").toString();
assertEquals ("Foo", name);
-
+
Object companyMap = employeeInfo.get("companyMap");
assertTrue (companyMap instanceof GenericArray);
GenericArray companyMapArray = (GenericArray)companyMap;
-
+
Object companyMapElement = companyMapArray.get(0);
assertTrue (companyMapElement instanceof GenericRecord);
key = ((GenericRecord)companyMapElement).get(ReflectData.NS_MAP_KEY);
@@ -142,7 +142,7 @@ public class TestNonStringMapKeys {
if (value instanceof Utf8)
value = ((Utf8)value).toString();
assertEquals ("CompanyFoo", value);
-
+
List<Company2> records2 =
(List<Company2>) testReflectDatumRead(testType, bytes, entityObjs);
Company2 co = records2.get(0);
@@ -180,7 +180,7 @@ public class TestNonStringMapKeys {
Object map1obj = record.get("map1");
assertTrue ("Unable to read map1", map1obj instanceof GenericArray);
GenericArray map1array = ((GenericArray)map1obj);
-
+
Object map1element = map1array.get(0);
assertTrue (map1element instanceof GenericRecord);
Object key = ((GenericRecord)map1element).get(ReflectData.NS_MAP_KEY);
@@ -190,7 +190,7 @@ public class TestNonStringMapKeys {
Object map2obj = record.get("map2");
assertEquals (map1obj, map2obj);
-
+
List<SameMapSignature> records2 =
(List<SameMapSignature>) testReflectDatumRead(testType, bytes, entityObjs);
SameMapSignature entity = records2.get(0);
@@ -221,9 +221,9 @@ public class TestNonStringMapKeys {
byte[] jsonBytes = testJsonEncoder (testType, entityObj1);
assertNotNull ("Unable to serialize using jsonEncoder", jsonBytes);
GenericRecord jsonRecord = testJsonDecoder(testType, jsonBytes, entityObj1);
- assertEquals ("JSON decoder output not same as Binary Decoder",
+ assertEquals ("JSON decoder output not same as Binary Decoder",
record.get("map1"), jsonRecord.get("map1"));
- assertEquals ("JSON decoder output not same as Binary Decoder",
+ assertEquals ("JSON decoder output not same as Binary Decoder",
record.get("map2"), jsonRecord.get("map2"));
}
@@ -280,7 +280,7 @@ public class TestNonStringMapKeys {
/**
* Test that non-string map-keys are readable through ReflectDatumReader
* This methoud should form the original map and should not return any
- * array of {key, value} as done by {@link #testGenericDatumRead()}
+ * array of {key, value} as done by {@link #testGenericDatumRead()}
*/
private <T> List<T> testReflectDatumRead
(String testType, byte[] bytes, T ... entityObjs) throws IOException {
@@ -349,15 +349,15 @@ public class TestNonStringMapKeys {
Company2 co = new Company2 ();
HashMap<Integer, EmployeeInfo2> employees = new HashMap<Integer, EmployeeInfo2>();
co.setEmployees(employees);
-
+
EmployeeId2 empId = new EmployeeId2(1);
EmployeeInfo2 empInfo = new EmployeeInfo2("Foo");
HashMap<Integer, String> companyMap = new HashMap<Integer, String>();
empInfo.setCompanyMap(companyMap);
companyMap.put(14, "CompanyFoo");
-
+
employees.put(11, empInfo);
-
+
return co;
}
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java b/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java
index 6c29ccc..a281a06 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java
@@ -50,9 +50,9 @@ import org.codehaus.jackson.node.NullNode;
import org.junit.Test;
public class TestReflect {
-
+
EncoderFactory factory = new EncoderFactory();
-
+
// test primitive type inference
@Test public void testVoid() {
check(Void.TYPE, "\"null\"");
@@ -154,13 +154,13 @@ public class TestReflect {
mapField.put("foo", "bar");
listField.add("foo");
}
-
+
@Override
public boolean equals(Object o) {
if (!(o instanceof R1)) return false;
R1 that = (R1)o;
return mapField.equals(that.mapField)
- && Arrays.equals(this.arrayField, that.arrayField)
+ && Arrays.equals(this.arrayField, that.arrayField)
&& listField.equals(that.listField);
}
}
@@ -179,7 +179,7 @@ public class TestReflect {
"{\"type\":\"array\",\"items\":\"string\""
+",\"java-class\":\"java.util.List\"}");
}
-
+
@Test public void testR1() throws Exception {
checkReadWrite(new R1());
}
@@ -188,12 +188,12 @@ public class TestReflect {
public static class R2 {
private String[] arrayField;
private Collection<String> collectionField;
-
+
@Override
public boolean equals(Object o) {
if (!(o instanceof R2)) return false;
R2 that = (R2)o;
- return Arrays.equals(this.arrayField, that.arrayField)
+ return Arrays.equals(this.arrayField, that.arrayField)
&& collectionField.equals(that.collectionField);
}
}
@@ -209,7 +209,7 @@ public class TestReflect {
// test array i/o of unboxed type
public static class R3 {
private int[] intArray;
-
+
@Override
public boolean equals(Object o) {
if (!(o instanceof R3)) return false;
@@ -230,7 +230,7 @@ public class TestReflect {
public short[] shorts;
public byte b;
public char c;
-
+
@Override
public boolean equals(Object o) {
if (!(o instanceof R4)) return false;
@@ -335,7 +335,7 @@ public class TestReflect {
return this.text.equals(((R10)o).text);
}
}
-
+
@Test public void testR10() throws Exception {
Schema r10Schema = ReflectData.get().getSchema(R10.class);
assertEquals(Schema.Type.STRING, r10Schema.getType());
@@ -354,7 +354,7 @@ public class TestReflect {
return this.text.equals(that.text);
}
}
-
+
@Test public void testR11() throws Exception {
Schema r11Record = ReflectData.get().getSchema(R11.class);
assertEquals(Schema.Type.RECORD, r11Record.getType());
@@ -414,7 +414,7 @@ public class TestReflect {
("{\"type\":\"array\",\"items\":[\"null\",\"string\"]}"),
s.getField("strings").schema());
}
-
+
@AvroSchema("\"null\"") // record
public class R13 {}
@@ -422,7 +422,7 @@ public class TestReflect {
Schema s = ReflectData.get().getSchema(R13.class);
assertEquals(Schema.Type.NULL, s.getType());
}
-
+
public interface P4 {
@AvroSchema("\"int\"") // message value
Object foo(@AvroSchema("\"int\"")Object x); // message param
@@ -506,45 +506,45 @@ public class TestReflect {
+"{\"name\":\"a\",\"type\":\"int\"},"
+"{\"name\":\"b\",\"type\":\"long\"}]}");
}
-
+
public static class RAvroIgnore { @AvroIgnore int a; }
@Test public void testAnnotationAvroIgnore() throws Exception {
check(RAvroIgnore.class, "{\"type\":\"record\",\"name\":\"RAvroIgnore\",\"namespace\":"
+"\"org.apache.avro.reflect.TestReflect$\",\"fields\":[]}");
}
-
+
public static class RAvroMeta { @AvroMeta(key="K", value="V") int a; }
@Test public void testAnnotationAvroMeta() throws Exception {
check(RAvroMeta.class, "{\"type\":\"record\",\"name\":\"RAvroMeta\",\"namespace\":"
- +"\"org.apache.avro.reflect.TestReflect$\",\"fields\":["
+ +"\"org.apache.avro.reflect.TestReflect$\",\"fields\":["
+"{\"name\":\"a\",\"type\":\"int\",\"K\":\"V\"}]}");
}
-
+
public static class RAvroName { @AvroName("b") int a; }
@Test public void testAnnotationAvroName() throws Exception {
check(RAvroName.class, "{\"type\":\"record\",\"name\":\"RAvroName\",\"namespace\":"
- +"\"org.apache.avro.reflect.TestReflect$\",\"fields\":["
+ +"\"org.apache.avro.reflect.TestReflect$\",\"fields\":["
+"{\"name\":\"b\",\"type\":\"int\"}]}");
}
-
+
public static class RAvroNameCollide { @AvroName("b") int a; int b; }
@Test(expected=Exception.class)
public void testAnnotationAvroNameCollide() throws Exception {
check(RAvroNameCollide.class, "{\"type\":\"record\",\"name\":\"RAvroNameCollide\",\"namespace\":"
- +"\"org.apache.avro.reflect.TestReflect$\",\"fields\":["
- +"{\"name\":\"b\",\"type\":\"int\"},"
+ +"\"org.apache.avro.reflect.TestReflect$\",\"fields\":["
+ +"{\"name\":\"b\",\"type\":\"int\"},"
+"{\"name\":\"b\",\"type\":\"int\"}]}");
}
-
+
public static class RAvroStringableField { @Stringable int a; }
public void testAnnotationAvroStringableFields() throws Exception {
check(RAvroStringableField.class, "{\"type\":\"record\",\"name\":\"RAvroNameCollide\",\"namespace\":"
- +"\"org.apache.avro.reflect.TestReflect$\",\"fields\":["
+ +"\"org.apache.avro.reflect.TestReflect$\",\"fields\":["
+"{\"name\":\"a\",\"type\":\"String\"}]}");
}
-
-
-
+
+
+
private void check(Object o, String schemaJson) {
check(o.getClass(), schemaJson);
@@ -557,14 +557,14 @@ public class TestReflect {
@Test
public void testRecordIO() throws IOException {
Schema schm = ReflectData.get().getSchema(SampleRecord.class);
- ReflectDatumWriter<SampleRecord> writer =
+ ReflectDatumWriter<SampleRecord> writer =
new ReflectDatumWriter<SampleRecord>(schm);
ByteArrayOutputStream out = new ByteArrayOutputStream();
SampleRecord record = new SampleRecord();
record.x = 5;
record.y = 10;
writer.write(record, factory.directBinaryEncoder(out, null));
- ReflectDatumReader<SampleRecord> reader =
+ ReflectDatumReader<SampleRecord> reader =
new ReflectDatumReader<SampleRecord>(schm);
SampleRecord decoded =
reader.read(null, DecoderFactory.get().binaryDecoder(
@@ -575,19 +575,19 @@ public class TestReflect {
public static class AvroEncRecord {
@AvroEncode(using=DateAsLongEncoding.class)
java.util.Date date;
-
- @Override
+
+ @Override
public boolean equals(Object o) {
if (!(o instanceof AvroEncRecord)) return false;
return date.equals(((AvroEncRecord)o).date);
}
}
-
+
public static class multipleAnnotationRecord {
@AvroIgnore
@Stringable
Integer i1;
-
+
@AvroIgnore
@Nullable
Integer i2;
@@ -595,27 +595,27 @@ public class TestReflect {
@AvroIgnore
@AvroName("j")
Integer i3;
-
+
@AvroIgnore
@AvroEncode(using=DateAsLongEncoding.class)
java.util.Date i4;
-
+
@Stringable
@Nullable
Integer i5;
-
+
@Stringable
@AvroName("j6")
- Integer i6 = 6;
-
+ Integer i6 = 6;
+
@Stringable
@AvroEncode(using=DateAsLongEncoding.class)
java.util.Date i7 = new java.util.Date(7L);
-
+
@Nullable
@AvroName("j8")
- Integer i8;
-
+ Integer i8;
+
@Nullable
@AvroEncode(using=DateAsLongEncoding.class)
java.util.Date i9;
@@ -630,11 +630,11 @@ public class TestReflect {
@AvroEncode(using=DateAsLongEncoding.class)
java.util.Date i11;
}
-
+
@Test
public void testMultipleAnnotations() throws IOException {
Schema schm = ReflectData.get().getSchema(multipleAnnotationRecord.class);
- ReflectDatumWriter<multipleAnnotationRecord> writer =
+ ReflectDatumWriter<multipleAnnotationRecord> writer =
new ReflectDatumWriter<multipleAnnotationRecord>(schm);
ByteArrayOutputStream out = new ByteArrayOutputStream();
multipleAnnotationRecord record = new multipleAnnotationRecord();
@@ -649,9 +649,9 @@ public class TestReflect {
record.i9 = new java.util.Date(9L);
record.i10 = new java.util.Date(10L);
record.i11 = new java.util.Date(11L);
-
+
writer.write(record, factory.directBinaryEncoder(out, null));
- ReflectDatumReader<multipleAnnotationRecord> reader =
+ ReflectDatumReader<multipleAnnotationRecord> reader =
new ReflectDatumReader<multipleAnnotationRecord>(schm);
multipleAnnotationRecord decoded =
reader.read(new multipleAnnotationRecord(), DecoderFactory.get().binaryDecoder(
@@ -668,8 +668,8 @@ public class TestReflect {
assertTrue(decoded.i10.getTime() == 10);
assertTrue(decoded.i11.getTime() == 11);
}
-
-
+
+
@Test
public void testAvroEncodeInducing() throws IOException {
Schema schm = ReflectData.get().getSchema(AvroEncRecord.class);
@@ -677,29 +677,29 @@ public class TestReflect {
"\":\"org.apache.avro.reflect.TestReflect$\",\"fields\":[{\"name\":\"date\"," +
"\"type\":{\"type\":\"long\",\"CustomEncoding\":\"DateAsLongEncoding\"}}]}");
}
-
+
@Test
public void testAvroEncodeIO() throws IOException {
Schema schm = ReflectData.get().getSchema(AvroEncRecord.class);
- ReflectDatumWriter<AvroEncRecord> writer =
+ ReflectDatumWriter<AvroEncRecord> writer =
new ReflectDatumWriter<AvroEncRecord>(schm);
ByteArrayOutputStream out = new ByteArrayOutputStream();
AvroEncRecord record = new AvroEncRecord();
record.date = new java.util.Date(948833323L);
writer.write(record, factory.directBinaryEncoder(out, null));
- ReflectDatumReader<AvroEncRecord> reader =
+ ReflectDatumReader<AvroEncRecord> reader =
new ReflectDatumReader<AvroEncRecord>(schm);
AvroEncRecord decoded =
reader.read(new AvroEncRecord(), DecoderFactory.get().binaryDecoder(
out.toByteArray(), null));
assertEquals(record, decoded);
}
-
+
@Test
public void testRecordWithNullIO() throws IOException {
ReflectData reflectData = ReflectData.AllowNull.get();
Schema schm = reflectData.getSchema(AnotherSampleRecord.class);
- ReflectDatumWriter<AnotherSampleRecord> writer =
+ ReflectDatumWriter<AnotherSampleRecord> writer =
new ReflectDatumWriter<AnotherSampleRecord>(schm);
ByteArrayOutputStream out = new ByteArrayOutputStream();
// keep record.a null and see if that works
@@ -709,7 +709,7 @@ public class TestReflect {
AnotherSampleRecord b = new AnotherSampleRecord(10);
writer.write(b, e);
e.flush();
- ReflectDatumReader<AnotherSampleRecord> reader =
+ ReflectDatumReader<AnotherSampleRecord> reader =
new ReflectDatumReader<AnotherSampleRecord>(schm);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
Decoder d = DecoderFactory.get().binaryDecoder(in, null);
@@ -761,7 +761,7 @@ public class TestReflect {
return false;
return true;
}
-
+
public static class AnotherSampleRecord {
private Integer a = null;
private SampleRecord s = null;
@@ -823,7 +823,7 @@ public class TestReflect {
}
@Test(expected=AvroTypeException.class)
- public void testOverloadedMethod() {
+ public void testOverloadedMethod() {
ReflectData.get().getProtocol(P3.class);
}
@@ -860,17 +860,17 @@ public class TestReflect {
// test that this instance can be written & re-read
checkBinary(schema, record);
}
-
+
@Test
public void testPrimitiveArray() throws Exception {
testPrimitiveArrays(false);
}
-
+
@Test
public void testPrimitiveArrayBlocking() throws Exception {
testPrimitiveArrays(true);
}
-
+
private void testPrimitiveArrays(boolean blocking) throws Exception {
testPrimitiveArray(boolean.class, blocking);
testPrimitiveArray(byte.class, blocking);
@@ -984,7 +984,7 @@ public class TestReflect {
Object datum, boolean equals) throws IOException {
checkBinary(reflectData, schema, datum, equals, false);
}
-
+
private static void checkBinary(ReflectData reflectData, Schema schema,
Object datum, boolean equals, boolean blocking) throws IOException {
ReflectDatumWriter<Object> writer = new ReflectDatumWriter<Object>(schema);
@@ -1026,20 +1026,20 @@ public class TestReflect {
@AvroAlias(alias="a", space="")
private static class AliasB { }
@AvroAlias(alias="a")
- private static class AliasC { }
-
+ private static class AliasC { }
+
@Test
public void testAvroAlias() {
check(AliasA.class, "{\"type\":\"record\",\"name\":\"AliasA\",\"namespace\":\"org.apache.avro.reflect.TestReflect$\",\"fields\":[],\"aliases\":[\"b.a\"]}");
check(AliasB.class, "{\"type\":\"record\",\"name\":\"AliasB\",\"namespace\":\"org.apache.avro.reflect.TestReflect$\",\"fields\":[],\"aliases\":[\"a\"]}");
- check(AliasC.class, "{\"type\":\"record\",\"name\":\"AliasC\",\"namespace\":\"org.apache.avro.reflect.TestReflect$\",\"fields\":[],\"aliases\":[\"a\"]}");
+ check(AliasC.class, "{\"type\":\"record\",\"name\":\"AliasC\",\"namespace\":\"org.apache.avro.reflect.TestReflect$\",\"fields\":[],\"aliases\":[\"a\"]}");
}
private static class DefaultTest {
@AvroDefault("1")
int foo;
- }
-
+ }
+
@Test
public void testAvroDefault() {
check(DefaultTest.class,
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflectionUtil.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflectionUtil.java b/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflectionUtil.java
index 4414d20..9d017f2 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflectionUtil.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflectionUtil.java
@@ -35,13 +35,13 @@ public class TestReflectionUtil {
Class<?> testerClass = cl.loadClass(Tester.class.getName());
testerClass.getDeclaredMethod("checkUnsafe").invoke(testerClass.newInstance());
}
-
+
public static final class Tester {
public Tester() {}
public void checkUnsafe() {
ReflectionUtil.getFieldAccess();
}
-
+
}
private static final class NoUnsafe extends ClassLoader {
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/util/CaseFinder.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/util/CaseFinder.java b/lang/java/avro/src/test/java/org/apache/avro/util/CaseFinder.java
index ddfc2a8..2f24a74 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/util/CaseFinder.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/util/CaseFinder.java
@@ -187,7 +187,7 @@ public class CaseFinder {
// Determine if this is a single-line heredoc, and process if it is
String singleLineText = m.group(2);
if (singleLineText.length() != 0) {
- if (! singleLineText.startsWith(" "))
+ if (! singleLineText.startsWith(" "))
throw new IOException("Single-line heredoc missing initial space (\""+docStart+"\")");
return singleLineText.substring(1);
}
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/avro/src/test/java/org/apache/avro/util/TestUtf8.java
----------------------------------------------------------------------
diff --git a/lang/java/avro/src/test/java/org/apache/avro/util/TestUtf8.java b/lang/java/avro/src/test/java/org/apache/avro/util/TestUtf8.java
index 758e3e5..2c5e771 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/util/TestUtf8.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/util/TestUtf8.java
@@ -35,9 +35,9 @@ public class TestUtf8 {
assertEquals(bs[i], u.getBytes()[i]);
}
}
-
+
@Test public void testArrayReusedWhenLargerThanRequestedSize() throws UnsupportedEncodingException {
- byte[] bs = "55555".getBytes("UTF-8");
+ byte[] bs = "55555".getBytes("UTF-8");
Utf8 u = new Utf8(bs);
assertEquals(5, u.getByteLength());
byte[] content = u.getBytes();
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/ProtocolTask.java
----------------------------------------------------------------------
diff --git a/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/ProtocolTask.java b/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/ProtocolTask.java
index 23f8d7e..36bf67b 100644
--- a/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/ProtocolTask.java
+++ b/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/ProtocolTask.java
@@ -38,22 +38,22 @@ public class ProtocolTask extends Task {
private StringType stringType = StringType.CharSequence;
private final ArrayList<FileSet> filesets = new ArrayList<FileSet>();
-
+
/** Set the schema file. */
public void setFile(File file) { this.src = file; }
-
+
/** Set the output directory */
public void setDestdir(File dir) { this.dest = dir; }
-
+
/** Set the string type. */
public void setStringType(StringType type) { this.stringType = type; }
-
+
/** Get the string type. */
public StringType getStringType() { return this.stringType; }
-
+
/** Add a fileset. */
public void addFileset(FileSet set) { filesets.add(set); }
-
+
/** Run the compiler. */
@Override
public void execute() {
@@ -74,7 +74,7 @@ public class ProtocolTask extends Task {
}
}
}
-
+
protected void doCompile(File src, File dir) throws IOException {
Protocol protocol = Protocol.parse(src);
SpecificCompiler compiler = new SpecificCompiler(protocol);
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
----------------------------------------------------------------------
diff --git a/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java b/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
index 6faf368..823a2ef 100644
--- a/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
+++ b/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
@@ -103,7 +103,7 @@ public class SpecificCompiler {
}
/* Reserved words for accessor/mutator methods */
- private static final Set<String> ACCESSOR_MUTATOR_RESERVED_WORDS =
+ private static final Set<String> ACCESSOR_MUTATOR_RESERVED_WORDS =
new HashSet<String>(Arrays.asList(new String[] {
"class", "schema", "classSchema"
}));
@@ -111,7 +111,7 @@ public class SpecificCompiler {
// Add reserved words to accessor/mutator reserved words
ACCESSOR_MUTATOR_RESERVED_WORDS.addAll(RESERVED_WORDS);
}
-
+
/* Reserved words for error types */
private static final Set<String> ERROR_RESERVED_WORDS = new HashSet<String>(
Arrays.asList(new String[] { "message", "cause" }));
@@ -119,14 +119,14 @@ public class SpecificCompiler {
// Add accessor/mutator reserved words to error reserved words
ERROR_RESERVED_WORDS.addAll(ACCESSOR_MUTATOR_RESERVED_WORDS);
}
-
- private static final String FILE_HEADER =
+
+ private static final String FILE_HEADER =
"/**\n" +
" * Autogenerated by Avro\n" +
- " * \n" +
+ " *\n" +
" * DO NOT EDIT DIRECTLY\n" +
" */\n";
-
+
public SpecificCompiler(Protocol protocol) {
this();
// enqueue all types
@@ -141,7 +141,7 @@ public class SpecificCompiler {
enqueue(schema);
this.protocol = null;
}
-
+
SpecificCompiler() {
this.templateDir =
System.getProperty("org.apache.avro.specific.templates",
@@ -206,7 +206,7 @@ public class SpecificCompiler {
velocityEngine.addProperty("resource.loader", "class, file");
velocityEngine.addProperty("class.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
- velocityEngine.addProperty("file.resource.loader.class",
+ velocityEngine.addProperty("file.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.FileResourceLoader");
velocityEngine.addProperty("file.resource.loader.path", "/, .");
velocityEngine.setProperty("runtime.references.strict", true);
@@ -547,7 +547,7 @@ public class SpecificCompiler {
default: throw new RuntimeException("Unknown string type: "+stringType);
}
}
-
+
private static final Schema NULL_SCHEMA = Schema.create(Schema.Type.NULL);
/** Utility for template use. Returns the java type for a Schema. */
@@ -628,7 +628,7 @@ public class SpecificCompiler {
b.append("\""); // final quote
return b.toString();
}
-
+
/** Utility for template use. Escapes quotes and backslashes. */
public static String javaEscape(Object o) {
return o.toString().replace("\\","\\\\").replace("\"", "\\\"");
@@ -638,7 +638,7 @@ public class SpecificCompiler {
public static String escapeForJavadoc(String s) {
return s.replace("*/", "*/");
}
-
+
/** Utility for template use. Returns empty string for null. */
public static String nullToEmpty(String x) {
return x == null ? "" : x;
@@ -648,19 +648,19 @@ public class SpecificCompiler {
public static String mangle(String word) {
return mangle(word, false);
}
-
+
/** Utility for template use. Adds a dollar sign to reserved words. */
public static String mangle(String word, boolean isError) {
return mangle(word, isError ? ERROR_RESERVED_WORDS : RESERVED_WORDS);
}
-
+
/** Utility for template use. Adds a dollar sign to reserved words. */
public static String mangle(String word, Set<String> reservedWords) {
return mangle(word, reservedWords, false);
}
-
+
/** Utility for template use. Adds a dollar sign to reserved words. */
- public static String mangle(String word, Set<String> reservedWords,
+ public static String mangle(String word, Set<String> reservedWords,
boolean isMethod) {
if (word.contains(".")) {
// If the 'word' is really a full path of a class we must mangle just the classname
@@ -669,15 +669,15 @@ public class SpecificCompiler {
String className = word.substring(lastDot + 1);
return packageName + mangle(className, reservedWords, isMethod);
}
- if (reservedWords.contains(word) ||
+ if (reservedWords.contains(word) ||
(isMethod && reservedWords.contains(
- Character.toLowerCase(word.charAt(0)) +
+ Character.toLowerCase(word.charAt(0)) +
((word.length() > 1) ? word.substring(1) : "")))) {
return word + "$";
}
return word;
}
-
+
/** Utility for use by templates. Return schema fingerprint as a long. */
public static long fingerprint64(Schema schema) {
return SchemaNormalization.parsingFingerprint64(schema);
@@ -692,7 +692,7 @@ public class SpecificCompiler {
public static String generateGetMethod(Schema schema, Field field) {
return generateMethodName(schema, field, "get", "");
}
-
+
/**
* Generates the name of a field mutator method.
* @param schema the schema in which the field is defined.
@@ -702,7 +702,7 @@ public class SpecificCompiler {
public static String generateSetMethod(Schema schema, Field field) {
return generateMethodName(schema, field, "set", "");
}
-
+
/**
* Generates the name of a field "has" method.
* @param schema the schema in which the field is defined.
@@ -712,7 +712,7 @@ public class SpecificCompiler {
public static String generateHasMethod(Schema schema, Field field) {
return generateMethodName(schema, field, "has", "");
}
-
+
/**
* Generates the name of a field "clear" method.
* @param schema the schema in which the field is defined.
@@ -722,7 +722,7 @@ public class SpecificCompiler {
public static String generateClearMethod(Schema schema, Field field) {
return generateMethodName(schema, field, "clear", "");
}
-
+
/** Utility for use by templates. Does this schema have a Builder method? */
public static boolean hasBuilder(Schema schema) {
switch (schema.getType()) {
@@ -779,20 +779,20 @@ public class SpecificCompiler {
* @param postfix method name postfix, e.g. "" or "Builder".
* @return the generated method name.
*/
- private static String generateMethodName(Schema schema, Field field,
+ private static String generateMethodName(Schema schema, Field field,
String prefix, String postfix) {
- // Check for the special case in which the schema defines two fields whose
+ // Check for the special case in which the schema defines two fields whose
// names are identical except for the case of the first character:
char firstChar = field.name().charAt(0);
String conflictingFieldName = (Character.isLowerCase(firstChar) ?
Character.toUpperCase(firstChar) : Character.toLowerCase(firstChar)) +
(field.name().length() > 1 ? field.name().substring(1) : "");
boolean fieldNameConflict = schema.getField(conflictingFieldName) != null;
-
+
StringBuilder methodBuilder = new StringBuilder(prefix);
- String fieldName = mangle(field.name(),
- schema.isError() ? ERROR_RESERVED_WORDS :
+ String fieldName = mangle(field.name(),
+ schema.isError() ? ERROR_RESERVED_WORDS :
ACCESSOR_MUTATOR_RESERVED_WORDS, true);
boolean nextCharToUpper = true;
@@ -809,7 +809,7 @@ public class SpecificCompiler {
}
}
methodBuilder.append(postfix);
-
+
// If there is a field name conflict append $0 or $1
if (fieldNameConflict) {
if (methodBuilder.charAt(methodBuilder.length() - 1) != '$') {
@@ -820,7 +820,7 @@ public class SpecificCompiler {
return methodBuilder.toString();
}
-
+
/** Tests whether an unboxed Java type can be set to null */
public static boolean isUnboxedJavaTypeNullable(Schema schema) {
switch (schema.getType()) {
@@ -838,7 +838,7 @@ public class SpecificCompiler {
//compileSchema(new File(args[0]), new File(args[1]));
compileProtocol(new File(args[0]), new File(args[1]));
}
-
+
public static final class Slf4jLogChute implements LogChute {
private Logger logger = LoggerFactory.getLogger("AvroVelocityLogChute");
@Override
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm
----------------------------------------------------------------------
diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm
index 2056b1d..2117cd4 100644
--- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm
+++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/enum.vm
@@ -16,8 +16,8 @@
## limitations under the License.
##
#if ($schema.getNamespace())
-package $schema.getNamespace();
-#end
+package $schema.getNamespace();
+#end
@SuppressWarnings("all")
#if ($schema.getDoc())
/** $schema.getDoc() */
@@ -26,7 +26,7 @@ package $schema.getNamespace();
@$annotation
#end
@org.apache.avro.specific.AvroGenerated
-public enum ${this.mangle($schema.getName())} {
+public enum ${this.mangle($schema.getName())} {
#foreach ($symbol in ${schema.getEnumSymbols()})${this.mangle($symbol)}#if ($velocityHasNext), #end#end
;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("${this.javaEscape($schema.toString())}");
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/fixed.vm
----------------------------------------------------------------------
diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/fixed.vm b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/fixed.vm
index aff3597..b19e1b1 100644
--- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/fixed.vm
+++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/fixed.vm
@@ -16,7 +16,7 @@
## limitations under the License.
##
#if ($schema.getNamespace())
-package $schema.getNamespace();
+package $schema.getNamespace();
#end
@SuppressWarnings("all")
#if ($schema.getDoc())
@@ -32,22 +32,22 @@ public class ${this.mangle($schema.getName())} extends org.apache.avro.specific.
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("${this.javaEscape($schema.toString())}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
-
+
/** Creates a new ${this.mangle($schema.getName())} */
public ${this.mangle($schema.getName())}() {
super();
}
-
+
/**
* Creates a new ${this.mangle($schema.getName())} with the given bytes.
- * @param bytes The bytes to create the new ${this.mangle($schema.getName())}.
+ * @param bytes The bytes to create the new ${this.mangle($schema.getName())}.
*/
public ${this.mangle($schema.getName())}(byte[] bytes) {
super(bytes);
}
private static final org.apache.avro.io.DatumWriter
- WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
+ WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
@@ -55,7 +55,7 @@ public class ${this.mangle($schema.getName())} extends org.apache.avro.specific.
}
private static final org.apache.avro.io.DatumReader
- READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
+ READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
----------------------------------------------------------------------
diff --git a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
index d0c1968..3e26df5 100644
--- a/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
+++ b/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
@@ -16,7 +16,7 @@
## limitations under the License.
##
#if ($schema.getNamespace())
-package $schema.getNamespace();
+package $schema.getNamespace();
#end
import org.apache.avro.specific.SpecificData;
@@ -47,7 +47,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
public ${this.mangle($schema.getName())}() {
super();
}
-
+
public ${this.mangle($schema.getName())}(Object value) {
super(value);
}
@@ -59,14 +59,14 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
public ${this.mangle($schema.getName())}(Object value, Throwable cause) {
super(value, cause);
}
-
+
#else
-#if ($schema.getFields().size() > 0)
+#if ($schema.getFields().size() > 0)
/**
* Default constructor. Note that this does not initialize fields
* to their default values from the schema. If that is desired then
- * one should use <code>newBuilder()</code>.
+ * one should use <code>newBuilder()</code>.
*/
public ${this.mangle($schema.getName())}() {}
#if ($this.isCreateAllArgsConstructor())
@@ -96,7 +96,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
#end
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
- // Used by DatumWriter. Applications should not call.
+ // Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
#set ($i = 0)
@@ -107,7 +107,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
- // Used by DatumReader. Applications should not call.
+ // Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
@@ -151,7 +151,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
public static #if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder newBuilder() {
return new #if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder();
}
-
+
/**
* Creates a new ${this.mangle($schema.getName())} RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
@@ -160,7 +160,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
public static #if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder newBuilder(#if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder other) {
return new #if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder(other);
}
-
+
/**
* Creates a new ${this.mangle($schema.getName())} RecordBuilder by copying an existing $this.mangle($schema.getName()) instance.
* @param other The existing instance to copy.
@@ -169,7 +169,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
public static #if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder newBuilder(#if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())} other) {
return new #if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder(other);
}
-
+
/**
* RecordBuilder for ${this.mangle($schema.getName())} instances.
*/
@@ -191,7 +191,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
private Builder() {
super(SCHEMA$);
}
-
+
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
@@ -210,7 +210,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
#end
#end
}
-
+
/**
* Creates a Builder by copying an existing $this.mangle($schema.getName()) instance
* @param other The existing instance to copy.
@@ -235,7 +235,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
super.setValue(value);
return this;
}
-
+
@Override
public #if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder clearValue() {
super.clearValue();
@@ -247,7 +247,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
super.setCause(cause);
return this;
}
-
+
@Override
public #if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder clearCause() {
super.clearCause();
@@ -280,7 +280,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
#end
this.${this.mangle($field.name(), $schema.isError())} = value;
fieldSetFlags()[$field.pos()] = true;
- return this;
+ return this;
}
/**
@@ -376,7 +376,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
}
private static final org.apache.avro.io.DatumWriter
- WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
+ WRITER$ = new org.apache.avro.specific.SpecificDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
@@ -384,7 +384,7 @@ public class ${this.mangle($schema.getName())}#if ($schema.isError()) extends or
}
private static final org.apache.avro.io.DatumReader
- READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
+ READER$ = new org.apache.avro.specific.SpecificDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/compiler/src/test/idl/putOnClassPath/OnTheClasspath.avdl
----------------------------------------------------------------------
diff --git a/lang/java/compiler/src/test/idl/putOnClassPath/OnTheClasspath.avdl b/lang/java/compiler/src/test/idl/putOnClassPath/OnTheClasspath.avdl
index 4533c54..233c0f6 100644
--- a/lang/java/compiler/src/test/idl/putOnClassPath/OnTheClasspath.avdl
+++ b/lang/java/compiler/src/test/idl/putOnClassPath/OnTheClasspath.avdl
@@ -18,7 +18,7 @@
@namespace("org.on.the.classpath")
protocol OnTheClasspath {
- import idl "nestedtypes.avdl";
- record FromAfar {
- }
+ import idl "nestedtypes.avdl";
+ record FromAfar {
+ }
}
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/compiler/src/test/idl/putOnClassPath/nestedtypes.avdl
----------------------------------------------------------------------
diff --git a/lang/java/compiler/src/test/idl/putOnClassPath/nestedtypes.avdl b/lang/java/compiler/src/test/idl/putOnClassPath/nestedtypes.avdl
index a8aafe4..6d2e1da 100644
--- a/lang/java/compiler/src/test/idl/putOnClassPath/nestedtypes.avdl
+++ b/lang/java/compiler/src/test/idl/putOnClassPath/nestedtypes.avdl
@@ -18,6 +18,6 @@
@namespace("org.on.the.classpath")
protocol OnTheClasspathTypes {
- record NestedType {
- }
+ record NestedType {
+ }
}
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/compiler/src/test/java/org/apache/avro/compiler/idl/TestIdl.java
----------------------------------------------------------------------
diff --git a/lang/java/compiler/src/test/java/org/apache/avro/compiler/idl/TestIdl.java b/lang/java/compiler/src/test/java/org/apache/avro/compiler/idl/TestIdl.java
index 7e4f686..52403a2 100644
--- a/lang/java/compiler/src/test/java/org/apache/avro/compiler/idl/TestIdl.java
+++ b/lang/java/compiler/src/test/java/org/apache/avro/compiler/idl/TestIdl.java
@@ -89,7 +89,7 @@ public class TestIdl {
if (! "run".equals(TEST_MODE)) return;
int passed = 0, failed = 0;
-
+
for (GenTest t : tests) {
try {
t.run();
@@ -136,7 +136,7 @@ public class TestIdl {
String newPath = currentWorkPath + "src" + File.separator + "test"
+ File.separator + "idl" + File.separator
+ "putOnClassPath" + File.separator;
- URL[] newPathURL = new URL[]{new URL(newPath)};
+ URL[] newPathURL = new URL[]{new URL(newPath)};
URLClassLoader ucl = new URLClassLoader(newPathURL, cl);
Idl parser = new Idl(in, ucl);
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/ipc/src/main/java/org/apache/avro/ipc/CallFuture.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/main/java/org/apache/avro/ipc/CallFuture.java b/lang/java/ipc/src/main/java/org/apache/avro/ipc/CallFuture.java
index 77561d3..588ea7d 100644
--- a/lang/java/ipc/src/main/java/org/apache/avro/ipc/CallFuture.java
+++ b/lang/java/ipc/src/main/java/org/apache/avro/ipc/CallFuture.java
@@ -32,14 +32,14 @@ public class CallFuture<T> implements Future<T>, Callback<T> {
private final Callback<T> chainedCallback;
private T result = null;
private Throwable error = null;
-
+
/**
* Creates a CallFuture.
*/
public CallFuture() {
this(null);
}
-
+
/**
* Creates a CallFuture with a chained Callback which will be invoked
* when this CallFuture's Callback methods are invoked.
@@ -48,9 +48,9 @@ public class CallFuture<T> implements Future<T>, Callback<T> {
public CallFuture(Callback<T> chainedCallback) {
this.chainedCallback = chainedCallback;
}
-
+
/**
- * Sets the RPC response, and unblocks all threads waiting on {@link #get()}
+ * Sets the RPC response, and unblocks all threads waiting on {@link #get()}
* or {@link #get(long, TimeUnit)}.
* @param result the RPC result to set.
*/
@@ -62,9 +62,9 @@ public class CallFuture<T> implements Future<T>, Callback<T> {
chainedCallback.handleResult(result);
}
}
-
+
/**
- * Sets an error thrown during RPC execution, and unblocks all threads waiting
+ * Sets an error thrown during RPC execution, and unblocks all threads waiting
* on {@link #get()} or {@link #get(long, TimeUnit)}.
* @param error the RPC error to set.
*/
@@ -79,21 +79,21 @@ public class CallFuture<T> implements Future<T>, Callback<T> {
/**
* Gets the value of the RPC result without blocking.
- * Using {@link #get()} or {@link #get(long, TimeUnit)} is usually
- * preferred because these methods block until the result is available or
- * an error occurs.
- * @return the value of the response, or null if no result was returned or
+ * Using {@link #get()} or {@link #get(long, TimeUnit)} is usually
+ * preferred because these methods block until the result is available or
+ * an error occurs.
+ * @return the value of the response, or null if no result was returned or
* the RPC has not yet completed.
*/
public T getResult() {
return result;
}
-
+
/**
* Gets the error that was thrown during RPC execution. Does not block.
- * Either {@link #get()} or {@link #get(long, TimeUnit)} should be called
+ * Either {@link #get()} or {@link #get(long, TimeUnit)} should be called
* first because these methods block until the RPC has completed.
- * @return the RPC error that was thrown, or null if no error has occurred or
+ * @return the RPC error that was thrown, or null if no error has occurred or
* if the RPC has not yet completed.
*/
public Throwable getError() {
@@ -132,7 +132,7 @@ public class CallFuture<T> implements Future<T>, Callback<T> {
throw new TimeoutException();
}
}
-
+
/**
* Waits for the CallFuture to complete without returning the result.
* @throws InterruptedException if interrupted.
@@ -140,7 +140,7 @@ public class CallFuture<T> implements Future<T>, Callback<T> {
public void await() throws InterruptedException {
latch.await();
}
-
+
/**
* Waits for the CallFuture to complete without returning the result.
* @param timeout the maximum time to wait.
@@ -148,7 +148,7 @@ public class CallFuture<T> implements Future<T>, Callback<T> {
* @throws InterruptedException if interrupted.
* @throws TimeoutException if the wait timed out.
*/
- public void await(long timeout, TimeUnit unit)
+ public void await(long timeout, TimeUnit unit)
throws InterruptedException, TimeoutException {
if (!latch.await(timeout, unit)) {
throw new TimeoutException();
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/ipc/src/main/java/org/apache/avro/ipc/Callback.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/main/java/org/apache/avro/ipc/Callback.java b/lang/java/ipc/src/main/java/org/apache/avro/ipc/Callback.java
index fdad4a7..a099725 100644
--- a/lang/java/ipc/src/main/java/org/apache/avro/ipc/Callback.java
+++ b/lang/java/ipc/src/main/java/org/apache/avro/ipc/Callback.java
@@ -20,8 +20,8 @@ package org.apache.avro.ipc;
/**
* Interface for receiving asynchronous callbacks.
- * For each request with an asynchronous callback,
- * either {@link #handleResult(Object)} or {@link #handleError(Throwable)}
+ * For each request with an asynchronous callback,
+ * either {@link #handleResult(Object)} or {@link #handleError(Throwable)}
* will be invoked.
*/
public interface Callback<T> {
@@ -30,7 +30,7 @@ public interface Callback<T> {
* @param result the result returned in the callback.
*/
void handleResult(T result);
-
+
/**
* Receives an error.
* @param error the error returned in the callback.
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/ipc/src/main/java/org/apache/avro/ipc/DatagramServer.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/main/java/org/apache/avro/ipc/DatagramServer.java b/lang/java/ipc/src/main/java/org/apache/avro/ipc/DatagramServer.java
index f0a8f1b..4990bf0 100644
--- a/lang/java/ipc/src/main/java/org/apache/avro/ipc/DatagramServer.java
+++ b/lang/java/ipc/src/main/java/org/apache/avro/ipc/DatagramServer.java
@@ -66,7 +66,7 @@ public class DatagramServer extends Thread implements Server {
}
}
}
-
+
public void close() { this.interrupt(); }
public static void main(String[] arg) throws Exception {
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/ipc/src/main/java/org/apache/avro/ipc/HttpTransceiver.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/main/java/org/apache/avro/ipc/HttpTransceiver.java b/lang/java/ipc/src/main/java/org/apache/avro/ipc/HttpTransceiver.java
index 9f6572f..11c9ebb 100644
--- a/lang/java/ipc/src/main/java/org/apache/avro/ipc/HttpTransceiver.java
+++ b/lang/java/ipc/src/main/java/org/apache/avro/ipc/HttpTransceiver.java
@@ -31,13 +31,13 @@ import java.net.HttpURLConnection;
/** An HTTP-based {@link Transceiver} implementation. */
public class HttpTransceiver extends Transceiver {
- static final String CONTENT_TYPE = "avro/binary";
+ static final String CONTENT_TYPE = "avro/binary";
private URL url;
private Proxy proxy;
private HttpURLConnection connection;
private int timeout;
-
+
public HttpTransceiver(URL url) { this.url = url; }
public HttpTransceiver(URL url, Proxy proxy) {
@@ -49,7 +49,7 @@ public class HttpTransceiver extends Transceiver {
public void setTimeout(int timeout) { this.timeout = timeout; }
public String getRemoteName() { return this.url.toString(); }
-
+
public synchronized List<ByteBuffer> readBuffers() throws IOException {
InputStream in = connection.getInputStream();
try {
http://git-wip-us.apache.org/repos/asf/avro/blob/da22ffcb/lang/java/ipc/src/main/java/org/apache/avro/ipc/NettyServer.java
----------------------------------------------------------------------
diff --git a/lang/java/ipc/src/main/java/org/apache/avro/ipc/NettyServer.java b/lang/java/ipc/src/main/java/org/apache/avro/ipc/NettyServer.java
index a86ebbe..534f0bf 100644
--- a/lang/java/ipc/src/main/java/org/apache/avro/ipc/NettyServer.java
+++ b/lang/java/ipc/src/main/java/org/apache/avro/ipc/NettyServer.java
@@ -62,13 +62,13 @@ public class NettyServer implements Server {
"avro-netty-server");
private final ChannelFactory channelFactory;
private final CountDownLatch closed = new CountDownLatch(1);
- private final ExecutionHandler executionHandler;
-
+ private final ExecutionHandler executionHandler;
+
public NettyServer(Responder responder, InetSocketAddress addr) {
this(responder, addr, new NioServerSocketChannelFactory
(Executors .newCachedThreadPool(), Executors.newCachedThreadPool()));
}
-
+
public NettyServer(Responder responder, InetSocketAddress addr,
ChannelFactory channelFactory) {
this(responder, addr, channelFactory, null);
@@ -123,12 +123,12 @@ public class NettyServer implements Server {
}
}, executionHandler);
}
-
+
@Override
public void start() {
// No-op.
}
-
+
@Override
public void close() {
ChannelGroupFuture future = allChannels.close();
@@ -136,7 +136,7 @@ public class NettyServer implements Server {
channelFactory.releaseExternalResources();
closed.countDown();
}
-
+
@Override
public int getPort() {
return ((InetSocketAddress) serverChannel.getLocalAddress()).getPort();
@@ -146,7 +146,7 @@ public class NettyServer implements Server {
public void join() throws InterruptedException {
closed.await();
}
-
+
/**
*
* @return The number of clients currently connected to this server.
@@ -158,12 +158,12 @@ public class NettyServer implements Server {
}
/**
- * Avro server handler for the Netty transport
+ * Avro server handler for the Netty transport
*/
class NettyServerAvroHandler extends SimpleChannelUpstreamHandler {
private NettyTransceiver connectionMetadata = new NettyTransceiver();
-
+
@Override
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)
throws Exception {
@@ -189,7 +189,7 @@ public class NettyServer implements Server {
// response will be null for oneway messages.
if(res != null) {
dataPack.setDatas(res);
- e.getChannel().write(dataPack);
+ e.getChannel().write(dataPack);
}
} catch (IOException ex) {
LOG.warn("unexpect error");