This is an automated email from the ASF dual-hosted git repository.

opwvhk pushed a commit to branch branch-1.12
in repository https://gitbox.apache.org/repos/asf/avro.git

commit c48ba717346d6a0f76157b661af96cb0145280bd
Author: belugabehr <[email protected]>
AuthorDate: Mon May 19 22:06:03 2025 +0200

    AVRO-4068: Java Code Cleanup (#3192)
    
    (cherry picked from commit 6e3b8582ef44a56033f2dcddadf30c51129230ab)
---
 .../src/main/java/org/apache/avro/Conversions.java |  2 +-
 .../main/java/org/apache/avro/JsonProperties.java  | 12 ++--
 .../src/main/java/org/apache/avro/Protocol.java    | 11 ++--
 .../src/main/java/org/apache/avro/Resolver.java    |  2 +-
 .../main/java/org/apache/avro/file/BZip2Codec.java |  2 +-
 .../org/apache/avro/file/DataFileConstants.java    |  1 -
 .../java/org/apache/avro/file/DataFileStream.java  | 24 ++------
 .../java/org/apache/avro/file/DataFileWriter.java  | 15 +++--
 .../java/org/apache/avro/file/DeflateCodec.java    |  6 +-
 .../main/java/org/apache/avro/file/FileReader.java |  4 +-
 .../java/org/apache/avro/file/SnappyCodec.java     |  4 +-
 .../main/java/org/apache/avro/file/XZCodec.java    |  7 +--
 .../java/org/apache/avro/file/ZstandardCodec.java  |  3 +-
 .../java/org/apache/avro/generic/GenericData.java  | 14 ++---
 .../apache/avro/generic/GenericDatumReader.java    |  2 +-
 .../apache/avro/generic/GenericDatumWriter.java    |  6 +-
 .../org/apache/avro/generic/PrimitivesArrays.java  |  2 +-
 .../main/java/org/apache/avro/io/BinaryData.java   | 10 ++--
 .../java/org/apache/avro/io/BinaryDecoder.java     | 12 ++--
 .../org/apache/avro/io/BlockingBinaryEncoder.java  |  9 ++-
 .../avro/io/BlockingDirectBinaryEncoder.java       |  2 +-
 .../org/apache/avro/io/BufferedBinaryEncoder.java  |  6 +-
 .../src/main/java/org/apache/avro/io/Decoder.java  | 66 +++++++++++-----------
 .../org/apache/avro/io/DirectBinaryDecoder.java    |  2 +-
 .../src/main/java/org/apache/avro/io/Encoder.java  | 58 +++++++++----------
 .../java/org/apache/avro/io/EncoderFactory.java    |  4 +-
 .../java/org/apache/avro/io/FastReaderBuilder.java | 25 ++++----
 .../main/java/org/apache/avro/io/JsonDecoder.java  |  7 +--
 .../main/java/org/apache/avro/io/JsonEncoder.java  | 10 ++--
 .../java/org/apache/avro/io/ResolvingDecoder.java  |  6 +-
 .../java/org/apache/avro/io/ValidatingEncoder.java |  8 +--
 .../java/org/apache/avro/io/parsing/Parser.java    |  2 +-
 .../avro/io/parsing/ResolvingGrammarGenerator.java |  4 +-
 .../java/org/apache/avro/io/parsing/Symbol.java    | 20 +++----
 .../io/parsing/ValidatingGrammarGenerator.java     |  2 +-
 .../apache/avro/message/BinaryMessageDecoder.java  |  2 +-
 .../org/apache/avro/message/RawMessageDecoder.java |  4 +-
 .../org/apache/avro/message/RawMessageEncoder.java |  3 +-
 .../apache/avro/path/TracingAvroTypeException.java |  4 +-
 .../apache/avro/reflect/FieldAccessReflect.java    |  6 +-
 .../java/org/apache/avro/reflect/ReflectData.java  |  3 +-
 .../apache/avro/specific/ExternalizableInput.java  |  5 --
 .../org/apache/avro/specific/SpecificData.java     |  2 +-
 .../apache/avro/util/ByteBufferInputStream.java    |  4 +-
 44 files changed, 179 insertions(+), 224 deletions(-)

diff --git a/lang/java/avro/src/main/java/org/apache/avro/Conversions.java 
b/lang/java/avro/src/main/java/org/apache/avro/Conversions.java
index 99ad500647..2fa15eb959 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/Conversions.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/Conversions.java
@@ -192,7 +192,7 @@ public class Conversions {
         BigInteger bg = null;
         ByteBuffer buffer = decoder.readBytes(null);
         byte[] array = buffer.array();
-        if (array != null && array.length > 0) {
+        if (array.length > 0) {
           bg = new BigInteger(array);
         }
 
diff --git a/lang/java/avro/src/main/java/org/apache/avro/JsonProperties.java 
b/lang/java/avro/src/main/java/org/apache/avro/JsonProperties.java
index 0c100baa98..5384b8595f 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/JsonProperties.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/JsonProperties.java
@@ -150,9 +150,9 @@ public abstract class JsonProperties {
   // Also, we only ever ADD to the collection, never changing a value, so
   // putWithAbsent is the
   // only modifier
-  private ConcurrentMap<String, JsonNode> props = new 
ConcurrentHashMap<String, JsonNode>() {
+  private final ConcurrentMap<String, JsonNode> props = new 
ConcurrentHashMap<>() {
     private static final long serialVersionUID = 1L;
-    private Queue<MapEntry<String, JsonNode>> propOrder = new 
ConcurrentLinkedQueue<>();
+    private final Queue<MapEntry<String, JsonNode>> propOrder = new 
ConcurrentLinkedQueue<>();
 
     @Override
     public JsonNode putIfAbsent(String key, JsonNode value) {
@@ -170,10 +170,10 @@ public abstract class JsonProperties {
 
     @Override
     public Set<Map.Entry<String, JsonNode>> entrySet() {
-      return new AbstractSet<Map.Entry<String, JsonNode>>() {
+      return new AbstractSet<>() {
         @Override
         public Iterator<Map.Entry<String, JsonNode>> iterator() {
-          return new Iterator<Map.Entry<String, JsonNode>>() {
+          return new Iterator<>() {
             Iterator<MapEntry<String, JsonNode>> it = propOrder.iterator();
 
             @Override
@@ -196,7 +196,7 @@ public abstract class JsonProperties {
     }
   };
 
-  private Set<String> reserved;
+  private final Set<String> reserved;
 
   JsonProperties(Set<String> reserved) {
     this.reserved = reserved;
@@ -206,7 +206,7 @@ public abstract class JsonProperties {
     this.reserved = reserved;
     for (Entry<String, ?> a : propMap.entrySet()) {
       Object v = a.getValue();
-      JsonNode json = null;
+      JsonNode json;
       if (v instanceof String) {
         json = TextNode.valueOf((String) v);
       } else if (v instanceof JsonNode) {
diff --git a/lang/java/avro/src/main/java/org/apache/avro/Protocol.java 
b/lang/java/avro/src/main/java/org/apache/avro/Protocol.java
index 905f2778c6..3404b93d4a 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/Protocol.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/Protocol.java
@@ -25,7 +25,6 @@ import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
 import java.security.MessageDigest;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
@@ -71,11 +70,9 @@ public class Protocol extends JsonProperties {
   public static final long VERSION = 1;
 
   // Support properties for both Protocol and Message objects
-  private static final Set<String> MESSAGE_RESERVED = Collections
-      .unmodifiableSet(new HashSet<>(Arrays.asList("doc", "response", 
"request", "errors", "one-way")));
+  private static final Set<String> MESSAGE_RESERVED = Set.of("doc", 
"response", "request", "errors", "one-way");
 
-  private static final Set<String> FIELD_RESERVED = Collections
-      .unmodifiableSet(new HashSet<>(Arrays.asList("name", "type", "doc", 
"default", "aliases")));
+  private static final Set<String> FIELD_RESERVED = Set.of("name", "type", 
"doc", "default", "aliases");
 
   /** A protocol message. */
   public class Message extends JsonProperties {
@@ -255,8 +252,8 @@ public class Protocol extends JsonProperties {
   /** Union type for generating system errors. */
   public static final Schema SYSTEM_ERRORS = 
Schema.createUnion(Collections.singletonList(SYSTEM_ERROR));
 
-  private static final Set<String> PROTOCOL_RESERVED = Collections
-      .unmodifiableSet(new HashSet<>(Arrays.asList("namespace", "protocol", 
"doc", "messages", "types", "errors")));
+  private static final Set<String> PROTOCOL_RESERVED = Set.of("namespace", 
"protocol", "doc", "messages", "types",
+      "errors");
 
   private Protocol() {
     super(PROTOCOL_RESERVED);
diff --git a/lang/java/avro/src/main/java/org/apache/avro/Resolver.java 
b/lang/java/avro/src/main/java/org/apache/avro/Resolver.java
index 117c9e3911..8b62b24d75 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/Resolver.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/Resolver.java
@@ -435,7 +435,7 @@ public class Resolver {
      * fields that will be read from the writer: these <i>n</i> are in the 
order
      * dictated by writer's schema. The remaining <i>m</i> fields will be read 
from
      * default values (actions for these default values are found in
-     * {@link RecordAdjust#defaults}.
+     * {@link RecordAdjust#defaults}).
      */
     public final Field[] readerOrder;
 
diff --git a/lang/java/avro/src/main/java/org/apache/avro/file/BZip2Codec.java 
b/lang/java/avro/src/main/java/org/apache/avro/file/BZip2Codec.java
index fe90557fa2..8fd6b6a09b 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/BZip2Codec.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/BZip2Codec.java
@@ -64,7 +64,7 @@ public class BZip2Codec extends Codec {
 
     try (BZip2CompressorInputStream inputStream = new 
BZip2CompressorInputStream(bais)) {
 
-      int readCount = -1;
+      int readCount;
       while ((readCount = inputStream.read(buffer, compressedData.position(), 
buffer.length)) > 0) {
         baos.write(buffer, 0, readCount);
       }
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileConstants.java 
b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileConstants.java
index fe269ca06b..4664f5410d 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileConstants.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileConstants.java
@@ -27,7 +27,6 @@ public class DataFileConstants {
 
   public static final byte VERSION = 1;
   public static final byte[] MAGIC = new byte[] { (byte) 'O', (byte) 'b', 
(byte) 'j', VERSION };
-  public static final long FOOTER_BLOCK = -1;
   public static final int SYNC_SIZE = 16;
   public static final int DEFAULT_SYNC_INTERVAL = 4000 * SYNC_SIZE;
 
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileStream.java 
b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileStream.java
index aa45868463..2bb24b3fa1 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileStream.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileStream.java
@@ -63,7 +63,7 @@ public class DataFileStream<D> implements Iterator<D>, 
Iterable<D>, Closeable {
     }
   }
 
-  private DatumReader<D> reader;
+  private final DatumReader<D> reader;
   private long blockSize;
   private boolean availableBlock = false;
   private Header header;
@@ -94,7 +94,7 @@ public class DataFileStream<D> implements Iterator<D>, 
Iterable<D>, Closeable {
   /**
    * create an uninitialized DataFileStream
    */
-  protected DataFileStream(DatumReader<D> reader) throws IOException {
+  protected DataFileStream(DatumReader<D> reader) {
     this.reader = reader;
   }
 
@@ -147,7 +147,7 @@ public class DataFileStream<D> implements Iterator<D>, 
Iterable<D>, Closeable {
   }
 
   /** Initialize the stream without reading from it. */
-  void initialize(Header header) throws IOException {
+  void initialize(Header header) {
     this.header = header;
     this.codec = resolveCodec();
     reader.setSchema(header.schema);
@@ -303,7 +303,7 @@ public class DataFileStream<D> implements Iterator<D>, 
Iterable<D>, Closeable {
       blockRemaining = vin.readLong(); // read block count
       blockSize = vin.readLong(); // read block size
       if (blockSize > Integer.MAX_VALUE || blockSize < 0) {
-        throw new IOException("Block size invalid or too large for this " + 
"implementation: " + blockSize);
+        throw new IOException("Block size invalid or too large for this 
implementation: " + blockSize);
       }
       blockCount = blockRemaining;
       availableBlock = true;
@@ -366,22 +366,6 @@ public class DataFileStream<D> implements Iterator<D>, 
Iterable<D>, Closeable {
       this.numEntries = numEntries;
     }
 
-    byte[] getData() {
-      return data;
-    }
-
-    long getNumEntries() {
-      return numEntries;
-    }
-
-    int getBlockSize() {
-      return blockSize;
-    }
-
-    boolean isFlushOnWrite() {
-      return flushOnWrite;
-    }
-
     void setFlushOnWrite(boolean flushOnWrite) {
       this.flushOnWrite = flushOnWrite;
     }
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java 
b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java
index 58235da884..c4e031b75d 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/DataFileWriter.java
@@ -25,7 +25,7 @@ import org.apache.avro.io.BinaryEncoder;
 import org.apache.avro.io.DatumWriter;
 import org.apache.avro.io.EncoderFactory;
 import org.apache.avro.util.NonCopyingByteArrayOutputStream;
-import org.apache.commons.compress.utils.IOUtils;
+import org.apache.commons.io.IOUtils;
 
 import java.io.BufferedOutputStream;
 import java.io.Closeable;
@@ -56,7 +56,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
  */
 public class DataFileWriter<D> implements Closeable, Flushable {
   private Schema schema;
-  private DatumWriter<D> dout;
+  private final DatumWriter<D> dout;
 
   private OutputStream underlyingStream;
 
@@ -117,11 +117,10 @@ public class DataFileWriter<D> implements Closeable, 
Flushable {
    * is written. In this case, the {@linkplain #flush()} must be called to 
flush
    * the stream.
    *
-   * Invalid values throw IllegalArgumentException
-   *
    * @param syncInterval the approximate number of uncompressed bytes to write 
in
    *                     each block
    * @return this DataFileWriter
+   * @throws IllegalArgumentException if syncInterval is invalid
    */
   public DataFileWriter<D> setSyncInterval(int syncInterval) {
     if (syncInterval < 32 || syncInterval > (1 << 30)) {
@@ -193,7 +192,7 @@ public class DataFileWriter<D> implements Closeable, 
Flushable {
    * Set whether this writer should flush the block to the stream every time a
    * sync marker is written. By default, the writer will flush the buffer each
    * time a sync marker is written (if the block size limit is reached or the
-   * {@linkplain #sync()} is called.
+   * {@linkplain #sync()} is called).
    *
    * @param flushOnEveryBlock - If set to false, this writer will not flush the
    *                          block to the stream until {@linkplain #flush()} 
is
@@ -475,11 +474,11 @@ public class DataFileWriter<D> implements Closeable, 
Flushable {
     }
   }
 
-  private class BufferedFileOutputStream extends BufferedOutputStream {
+  private static class BufferedFileOutputStream extends BufferedOutputStream {
     private long position; // start of buffer
 
     private class PositionFilter extends FilterOutputStream {
-      public PositionFilter(OutputStream out) throws IOException {
+      public PositionFilter(OutputStream out) {
         super(out);
       }
 
@@ -490,7 +489,7 @@ public class DataFileWriter<D> implements Closeable, 
Flushable {
       }
     }
 
-    public BufferedFileOutputStream(OutputStream out) throws IOException {
+    public BufferedFileOutputStream(OutputStream out) {
       super(null);
       this.out = new PositionFilter(out);
     }
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/file/DeflateCodec.java 
b/lang/java/avro/src/main/java/org/apache/avro/file/DeflateCodec.java
index 87498d3ee8..e6d58e46a1 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/DeflateCodec.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/DeflateCodec.java
@@ -40,7 +40,7 @@ public class DeflateCodec extends Codec {
   private static final int DEFAULT_BUFFER_SIZE = 8192;
 
   static class Option extends CodecFactory {
-    private int compressionLevel;
+    private final int compressionLevel;
 
     Option(int compressionLevel) {
       this.compressionLevel = compressionLevel;
@@ -55,8 +55,8 @@ public class DeflateCodec extends Codec {
   private Deflater deflater;
   private Inflater inflater;
   // currently only do 'nowrap' -- RFC 1951, not zlib
-  private boolean nowrap = true;
-  private int compressionLevel;
+  private final boolean nowrap = true;
+  private final int compressionLevel;
 
   public DeflateCodec(int compressionLevel) {
     this.compressionLevel = compressionLevel;
diff --git a/lang/java/avro/src/main/java/org/apache/avro/file/FileReader.java 
b/lang/java/avro/src/main/java/org/apache/avro/file/FileReader.java
index 07229d59ee..9a54cf055e 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/FileReader.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/FileReader.java
@@ -31,7 +31,7 @@ public interface FileReader<D> extends Iterator<D>, 
Iterable<D>, Closeable {
 
   /**
    * Read the next datum from the file.
-   * 
+   *
    * @param reuse an instance to reuse.
    * @throws NoSuchElementException if no more remain in the file.
    */
@@ -39,7 +39,7 @@ public interface FileReader<D> extends Iterator<D>, 
Iterable<D>, Closeable {
 
   /**
    * Move to the next synchronization point after a position. To process a 
range
-   * of file entires, call this with the starting position, then check
+   * of file entries, call this with the starting position, then check
    * {@link #pastSync(long)} with the end point before each call to
    * {@link #next()}.
    */
diff --git a/lang/java/avro/src/main/java/org/apache/avro/file/SnappyCodec.java 
b/lang/java/avro/src/main/java/org/apache/avro/file/SnappyCodec.java
index 72bf0b7482..454d2925de 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/SnappyCodec.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/SnappyCodec.java
@@ -26,7 +26,7 @@ import org.xerial.snappy.Snappy;
 
 /** * Implements Snappy compression and decompression. */
 public class SnappyCodec extends Codec {
-  private CRC32 crc32 = new CRC32();
+  private final CRC32 crc32 = new CRC32();
 
   static class Option extends CodecFactory {
     static {
@@ -72,7 +72,7 @@ public class SnappyCodec extends Codec {
 
     crc32.reset();
     crc32.update(out.array(), 0, size);
-    if (in.getInt(((Buffer) in).limit() - 4) != (int) crc32.getValue())
+    if (in.getInt(in.limit() - 4) != (int) crc32.getValue())
       throw new IOException("Checksum failure");
 
     return out;
diff --git a/lang/java/avro/src/main/java/org/apache/avro/file/XZCodec.java 
b/lang/java/avro/src/main/java/org/apache/avro/file/XZCodec.java
index 3052f2a416..bc674b7346 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/XZCodec.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/XZCodec.java
@@ -26,7 +26,6 @@ import java.nio.ByteBuffer;
 import org.apache.avro.util.NonCopyingByteArrayOutputStream;
 import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
 import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream;
-import org.apache.commons.compress.utils.IOUtils;
 
 /** * Implements xz compression and decompression. */
 public class XZCodec extends Codec {
@@ -34,7 +33,7 @@ public class XZCodec extends Codec {
   private static final int DEFAULT_BUFFER_SIZE = 8192;
 
   static class Option extends CodecFactory {
-    private int compressionLevel;
+    private final int compressionLevel;
 
     Option(int compressionLevel) {
       this.compressionLevel = compressionLevel;
@@ -46,7 +45,7 @@ public class XZCodec extends Codec {
     }
   }
 
-  private int compressionLevel;
+  private final int compressionLevel;
 
   public XZCodec(int compressionLevel) {
     this.compressionLevel = compressionLevel;
@@ -72,7 +71,7 @@ public class XZCodec extends Codec {
     InputStream bytesIn = new ByteArrayInputStream(data.array(), 
computeOffset(data), data.remaining());
 
     try (InputStream ios = new XZCompressorInputStream(bytesIn)) {
-      IOUtils.copy(ios, baos);
+      ios.transferTo(baos);
     }
     return baos.asByteBuffer();
   }
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/file/ZstandardCodec.java 
b/lang/java/avro/src/main/java/org/apache/avro/file/ZstandardCodec.java
index f778b2fe35..0d4e31958d 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/file/ZstandardCodec.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/file/ZstandardCodec.java
@@ -24,7 +24,6 @@ import java.io.OutputStream;
 import java.nio.ByteBuffer;
 
 import org.apache.avro.util.NonCopyingByteArrayOutputStream;
-import org.apache.commons.compress.utils.IOUtils;
 
 public class ZstandardCodec extends Codec {
   public final static int DEFAULT_COMPRESSION = 3;
@@ -82,7 +81,7 @@ public class ZstandardCodec extends Codec {
     InputStream bytesIn = new ByteArrayInputStream(compressedData.array(), 
computeOffset(compressedData),
         compressedData.remaining());
     try (InputStream ios = ZstandardLoader.input(bytesIn, useBufferPool)) {
-      IOUtils.copy(ios, baos);
+      ios.transferTo(baos);
     }
     return baos.asByteBuffer();
   }
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java 
b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
index be5c7c422d..0a37811315 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
@@ -138,9 +138,9 @@ public class GenericData {
     }
   }
 
-  private Map<String, Conversion<?>> conversions = new HashMap<>();
+  private final Map<String, Conversion<?>> conversions = new HashMap<>();
 
-  private Map<Class<?>, Map<String, Conversion<?>>> conversionsByClass = new 
IdentityHashMap<>();
+  private final Map<Class<?>, Map<String, Conversion<?>>> conversionsByClass = 
new IdentityHashMap<>();
 
   public Collection<Conversion<?>> getConversions() {
     return conversions.values();
@@ -365,7 +365,7 @@ public class GenericData {
 
     @Override
     public Iterator<T> iterator() {
-      return new Iterator<T>() {
+      return new Iterator<>() {
         private int position = 0;
 
         @Override
@@ -552,8 +552,8 @@ public class GenericData {
 
   /** Default implementation of {@link GenericEnumSymbol}. */
   public static class EnumSymbol implements GenericEnumSymbol<EnumSymbol> {
-    private Schema schema;
-    private String symbol;
+    private final Schema schema;
+    private final String symbol;
 
     public EnumSymbol(Schema schema, String symbol) {
       this.schema = schema;
@@ -1260,9 +1260,7 @@ public class GenericData {
           }
         }
       }
-    } catch (ClassCastException unused) {
-      return 1;
-    } catch (NullPointerException unused) {
+    } catch (ClassCastException | NullPointerException unused) {
       return 1;
     }
 
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java 
b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java
index 3c5d1316cb..b818a070c1 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java
@@ -519,7 +519,7 @@ public class GenericDatumReader<D> implements 
DatumReader<D> {
 
     @Override
     public boolean equals(Object obj) {
-      if (obj == null || !(obj instanceof 
GenericDatumReader.IdentitySchemaKey)) {
+      if (!(obj instanceof GenericDatumReader.IdentitySchemaKey)) {
         return false;
       }
       IdentitySchemaKey key = (IdentitySchemaKey) obj;
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java 
b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java
index deeac0b1f2..20a856c4dc 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumWriter.java
@@ -219,9 +219,7 @@ public class GenericDatumWriter<D> implements 
DatumWriter<D> {
 
   /** Helper method for adding a message to an Avro Type Exception . */
   protected AvroTypeException addAvroTypeMsg(AvroTypeException e, String s) {
-    AvroTypeException result = new AvroTypeException(e.getMessage() + s);
-    result.initCause(e.getCause() == null ? e : e.getCause());
-    return result;
+    return new AvroTypeException(e.getMessage() + s, e.getCause() == null ? e 
: e.getCause());
   }
 
   /**
@@ -282,7 +280,7 @@ public class GenericDatumWriter<D> implements 
DatumWriter<D> {
     long actualSize = 0;
     out.writeArrayStart();
     out.setItemCount(size);
-    for (Iterator<? extends Object> it = getArrayElements(datum); 
it.hasNext();) {
+    for (Iterator<?> it = getArrayElements(datum); it.hasNext();) {
       out.startItem();
       try {
         write(element, it.next(), out);
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/generic/PrimitivesArrays.java 
b/lang/java/avro/src/main/java/org/apache/avro/generic/PrimitivesArrays.java
index 595cc1576e..87be036468 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/generic/PrimitivesArrays.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/generic/PrimitivesArrays.java
@@ -366,7 +366,7 @@ public class PrimitivesArrays {
       size++;
       for (int index = this.size / 8; index > (location / 8); index--) {
         elements[index] <<= 1;
-        if (index > 0 && (elements[index - 1] & (1 << Byte.SIZE)) > 0) {
+        if ((elements[index - 1] & (1 << Byte.SIZE)) > 0) {
           elements[index] |= 1;
         }
       }
diff --git a/lang/java/avro/src/main/java/org/apache/avro/io/BinaryData.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/BinaryData.java
index 99bc0b2acb..1254797455 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/BinaryData.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/BinaryData.java
@@ -261,11 +261,11 @@ public class BinaryData {
     case UNION:
       return hashCode(data, schema.getTypes().get(decoder.readInt()));
     case FIXED:
-      return hashBytes(1, data, schema.getFixedSize(), false);
+      return hashBytes(data, schema.getFixedSize(), false);
     case STRING:
-      return hashBytes(1, data, decoder.readInt(), false);
+      return hashBytes(data, decoder.readInt(), false);
     case BYTES:
-      return hashBytes(1, data, decoder.readInt(), true);
+      return hashBytes(data, decoder.readInt(), true);
     case NULL:
       return 0;
     default:
@@ -273,8 +273,8 @@ public class BinaryData {
     }
   }
 
-  private static int hashBytes(int init, HashData data, int len, boolean rev) 
throws IOException {
-    int hashCode = init;
+  private static int hashBytes(HashData data, int len, boolean rev) throws 
IOException {
+    int hashCode = 1;
     byte[] bytes = data.decoder.getBuf();
     int start = data.decoder.getPos();
     int end = start + len;
diff --git a/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java
index 7217be3add..69e0186c85 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java
@@ -199,7 +199,7 @@ public class BinaryDecoder extends Decoder {
           if (b > 0x7f) {
             // only the low 28 bits can be set, so this won't carry
             // the sign bit to the long
-            l = innerLongDecode((long) n);
+            l = innerLongDecode(n);
           } else {
             l = n;
           }
@@ -779,7 +779,7 @@ public class BinaryDecoder extends Decoder {
   }
 
   private static class InputStreamByteSource extends ByteSource {
-    private InputStream in;
+    private final InputStream in;
     protected boolean isEof = false;
 
     private InputStreamByteSource(InputStream in) {
@@ -909,7 +909,7 @@ public class BinaryDecoder extends Decoder {
    */
   private static class ByteArrayByteSource extends ByteSource {
     private static final int MIN_SIZE = 16;
-    private byte[] data;
+    private final byte[] data;
     private int position;
     private int max;
     private boolean compacted = false;
@@ -949,7 +949,7 @@ public class BinaryDecoder extends Decoder {
     }
 
     @Override
-    protected long trySkipBytes(long length) throws IOException {
+    protected long trySkipBytes(long length) {
       // the buffer is shared, so this should return 0
       max = ba.getLim();
       position = ba.getPos();
@@ -974,13 +974,13 @@ public class BinaryDecoder extends Decoder {
     }
 
     @Override
-    protected int tryReadRaw(byte[] data, int off, int len) throws IOException 
{
+    protected int tryReadRaw(byte[] data, int off, int len) {
       // the buffer is shared, nothing to read
       return 0;
     }
 
     @Override
-    protected void compactAndFill(byte[] buf, int pos, int minPos, int 
remaining) throws IOException {
+    protected void compactAndFill(byte[] buf, int pos, int minPos, int 
remaining) {
       // this implementation does not want to mutate the array passed in,
       // so it makes a new tiny buffer unless it has been compacted once before
       if (!compacted) {
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/BlockingBinaryEncoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/BlockingBinaryEncoder.java
index d0bfc8f075..9a0d9e414b 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/BlockingBinaryEncoder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/BlockingBinaryEncoder.java
@@ -89,7 +89,7 @@ public class BlockingBinaryEncoder extends 
BufferedBinaryEncoder {
        * this case, {@link BlockedValue#start} is zero. The header for such a 
block
        * has _already been written_ (we've written out a header indicating 
that the
        * block has a single item, and we put a "zero" down for the byte-count 
to
-       * indicate that we don't know the physical length of the buffer. Any 
blocks
+       * indicate that we don't know the physical length of the buffer). Any 
blocks
        * _containing_ this block must be in the {@link #OVERFLOW} state.
        */
       OVERFLOW
@@ -130,7 +130,7 @@ public class BlockingBinaryEncoder extends 
BufferedBinaryEncoder {
      * Check invariants of <code>this</code> and also the 
<code>BlockedValue</code>
      * containing <code>this</code>.
      */
-    public boolean check(BlockedValue prev, int pos) {
+    public void check(BlockedValue prev, int pos) {
       assert state != State.ROOT || type == null;
       assert (state == State.ROOT || type == Schema.Type.ARRAY || type == 
Schema.Type.MAP);
 
@@ -156,7 +156,6 @@ public class BlockingBinaryEncoder extends 
BufferedBinaryEncoder {
         assert prev.state == State.ROOT || prev.state == State.OVERFLOW;
         break;
       }
-      return false;
     }
   }
 
@@ -179,7 +178,7 @@ public class BlockingBinaryEncoder extends 
BufferedBinaryEncoder {
 
   // buffer large enough for up to two ints for a block header
   // rounded up to a multiple of 4 bytes.
-  private byte[] headerBuffer = new byte[12];
+  private final byte[] headerBuffer = new byte[12];
 
   private boolean check() {
     assert buf != null;
@@ -438,7 +437,7 @@ public class BlockingBinaryEncoder extends 
BufferedBinaryEncoder {
    * Called when we've finished writing the last item in an overflow buffer. 
When
    * this is finished, the top of the stack will be an empty block in the
    * "regular" state.
-   * 
+   *
    * @throws IOException
    */
   private void finishOverflow() throws IOException {
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/BlockingDirectBinaryEncoder.java
 
b/lang/java/avro/src/main/java/org/apache/avro/io/BlockingDirectBinaryEncoder.java
index 2ef2375e64..9f391a3192 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/io/BlockingDirectBinaryEncoder.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/io/BlockingDirectBinaryEncoder.java
@@ -60,7 +60,7 @@ public class BlockingDirectBinaryEncoder extends 
DirectBinaryEncoder {
    * Create a writer that sends its output to the underlying stream
    * <code>out</code>.
    *
-   * @param out The Outputstream to write to
+   * @param out The OutputStream to write to
    */
   public BlockingDirectBinaryEncoder(OutputStream out) {
     super(out);
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/BufferedBinaryEncoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/BufferedBinaryEncoder.java
index 376289ec88..054f306956 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/BufferedBinaryEncoder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/BufferedBinaryEncoder.java
@@ -41,7 +41,7 @@ import org.apache.avro.AvroRuntimeException;
  * <p/>
  * To change the buffer size, configure the factory instance used to create
  * instances with {@link EncoderFactory#configureBufferSize(int)}
- * 
+ *
  * @see Encoder
  * @see EncoderFactory
  * @see BlockingBinaryEncoder
@@ -105,8 +105,8 @@ public class BufferedBinaryEncoder extends BinaryEncoder {
    * current position and the end. This will not expand the buffer larger than 
its
    * current size, for writes larger than or near to the size of the buffer, we
    * flush the buffer and write directly to the output, bypassing the buffer.
-   * 
-   * @param num
+   *
+   * @param num the number of bytes to ensure are available
    * @throws IOException
    */
   private void ensureBounds(int num) throws IOException {
diff --git a/lang/java/avro/src/main/java/org/apache/avro/io/Decoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/Decoder.java
index a0f4049f02..11fc28d762 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/Decoder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/Decoder.java
@@ -30,11 +30,11 @@ import org.apache.avro.util.Utf8;
  * <p/>
  * The other type of methods support the reading of maps and arrays. These
  * methods are {@link #readArrayStart}, {@link #arrayNext}, and similar methods
- * for maps). See {@link #readArrayStart} for details on these methods.)
+ * for maps. See {@link #readArrayStart} for details on these methods.
  * <p/>
  * {@link DecoderFactory} contains Decoder construction and configuration
  * facilities.
- * 
+ *
  * @see DecoderFactory
  * @see Encoder
  */
@@ -44,7 +44,7 @@ public abstract class Decoder {
   /**
    * "Reads" a null value. (Doesn't actually read anything, but advances the 
state
    * of the parser if the implementation is stateful.)
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and null is not the
    *                           type of the next value to be read
    */
@@ -52,7 +52,7 @@ public abstract class Decoder {
 
   /**
    * Reads a boolean value written by {@link Encoder#writeBoolean}.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and boolean is not 
the
    *                           type of the next value to be read
    */
@@ -61,7 +61,7 @@ public abstract class Decoder {
 
   /**
    * Reads an integer written by {@link Encoder#writeInt}.
-   * 
+   *
    * @throws AvroTypeException If encoded value is larger than 32-bits
    * @throws AvroTypeException If this is a stateful reader and int is not the
    *                           type of the next value to be read
@@ -70,7 +70,7 @@ public abstract class Decoder {
 
   /**
    * Reads a long written by {@link Encoder#writeLong}.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and long is not the
    *                           type of the next value to be read
    */
@@ -78,7 +78,7 @@ public abstract class Decoder {
 
   /**
    * Reads a float written by {@link Encoder#writeFloat}.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and is not the 
type of
    *                           the next value to be read
    */
@@ -86,7 +86,7 @@ public abstract class Decoder {
 
   /**
    * Reads a double written by {@link Encoder#writeDouble}.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and is not the 
type of
    *                           the next value to be read
    */
@@ -94,7 +94,7 @@ public abstract class Decoder {
 
   /**
    * Reads a char-string written by {@link Encoder#writeString}.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and char-string is 
not
    *                           the type of the next value to be read
    */
@@ -102,7 +102,7 @@ public abstract class Decoder {
 
   /**
    * Reads a char-string written by {@link Encoder#writeString}.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and char-string is 
not
    *                           the type of the next value to be read
    */
@@ -110,7 +110,7 @@ public abstract class Decoder {
 
   /**
    * Discards a char-string written by {@link Encoder#writeString}.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and char-string is 
not
    *                           the type of the next value to be read
    */
@@ -120,7 +120,7 @@ public abstract class Decoder {
    * Reads a byte-string written by {@link Encoder#writeBytes}. if 
<tt>old</tt> is
    * not null and has sufficient capacity to take in the bytes being read, the
    * bytes are returned in <tt>old</tt>.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and byte-string is 
not
    *                           the type of the next value to be read
    */
@@ -128,7 +128,7 @@ public abstract class Decoder {
 
   /**
    * Discards a byte-string written by {@link Encoder#writeBytes}.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and byte-string is 
not
    *                           the type of the next value to be read
    */
@@ -136,7 +136,7 @@ public abstract class Decoder {
 
   /**
    * Reads fixed sized binary object.
-   * 
+   *
    * @param bytes  The buffer to store the contents being read.
    * @param start  The position where the data needs to be written.
    * @param length The size of the binary object.
@@ -149,7 +149,7 @@ public abstract class Decoder {
 
   /**
    * A shorthand for <tt>readFixed(bytes, 0, bytes.length)</tt>.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and fixed sized 
binary
    *                           object is not the type of the next value to be 
read
    *                           or the length is incorrect.
@@ -161,7 +161,7 @@ public abstract class Decoder {
 
   /**
    * Discards fixed sized binary object.
-   * 
+   *
    * @param length The size of the binary object to be skipped.
    * @throws AvroTypeException If this is a stateful reader and fixed sized 
binary
    *                           object is not the type of the next value to be 
read
@@ -172,7 +172,7 @@ public abstract class Decoder {
 
   /**
    * Reads an enumeration.
-   * 
+   *
    * @return The enumeration's value.
    * @throws AvroTypeException If this is a stateful reader and enumeration is 
not
    *                           the type of the next value to be read.
@@ -185,7 +185,7 @@ public abstract class Decoder {
    * returns non-zero, then the caller should read the indicated number of 
items,
    * and then call {@link #arrayNext} to find out the number of items in the 
next
    * block. The typical pattern for consuming an array looks like:
-   * 
+   *
    * <pre>
    *   for(long i = in.readArrayStart(); i != 0; i = in.arrayNext()) {
    *     for (long j = 0; j < i; j++) {
@@ -193,7 +193,7 @@ public abstract class Decoder {
    *     }
    *   }
    * </pre>
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and array is not 
the
    *                           type of the next value to be read
    */
@@ -201,9 +201,9 @@ public abstract class Decoder {
 
   /**
    * Processes the next block of an array and returns the number of items in 
the
-   * block and let's the caller read those items.
-   * 
-   * @throws AvroTypeException When called outside of an array context
+   * block and lets the caller read those items.
+   *
+   * @throws AvroTypeException When called outside an array context
    */
   public abstract long arrayNext() throws IOException;
 
@@ -216,7 +216,7 @@ public abstract class Decoder {
    * possible. It will return zero if there are no more items to skip through, 
or
    * an item count if it needs the client's help in skipping. The typical usage
    * pattern is:
-   * 
+   *
    * <pre>
    *   for(long i = in.skipArray(); i != 0; i = i.skipArray()) {
    *     for (long j = 0; j < i; j++) {
@@ -224,7 +224,7 @@ public abstract class Decoder {
    *     }
    *   }
    * </pre>
-   * 
+   *
    * Note that this method can automatically skip through items if a 
byte-count is
    * found in the underlying data, or if a schema has been provided to the
    * implementation, but otherwise the client will have to skip through items
@@ -240,9 +240,9 @@ public abstract class Decoder {
    * {@link #readArrayStart}.
    *
    * As an example, let's say you want to read a map of records, the record
-   * consisting of an Long field and a Boolean field. Your code would look
+   * consisting of a Long field and a Boolean field. Your code would look
    * something like this:
-   * 
+   *
    * <pre>
    * Map<String, Record> m = new HashMap<String, Record>();
    * Record reuse = new Record();
@@ -255,7 +255,7 @@ public abstract class Decoder {
    *   }
    * }
    * </pre>
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and map is not the
    *                           type of the next value to be read
    */
@@ -264,8 +264,8 @@ public abstract class Decoder {
   /**
    * Processes the next block of map entries and returns the count of them.
    * Similar to {@link #arrayNext}. See {@link #readMapStart} for details.
-   * 
-   * @throws AvroTypeException When called outside of a map context
+   *
+   * @throws AvroTypeException When called outside a map context
    */
   public abstract long mapNext() throws IOException;
 
@@ -273,9 +273,9 @@ public abstract class Decoder {
    * Support for quickly skipping through a map similar to {@link #skipArray}.
    *
    * As an example, let's say you want to skip a map of records, the record
-   * consisting of an Long field and a Boolean field. Your code would look
+   * consisting of a Long field and a Boolean field. Your code would look
    * something like this:
-   * 
+   *
    * <pre>
    * for (long i = in.skipMap(); i != 0; i = in.skipMap()) {
    *   for (long j = 0; j < i; j++) {
@@ -285,7 +285,7 @@ public abstract class Decoder {
    *   }
    * }
    * </pre>
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and array is not 
the
    *                           type of the next value to be read
    */
@@ -294,7 +294,7 @@ public abstract class Decoder {
 
   /**
    * Reads the tag of a union written by {@link Encoder#writeIndex}.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful reader and union is not 
the
    *                           type of the next value to be read
    */
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/DirectBinaryDecoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/DirectBinaryDecoder.java
index 71f3ed593a..ac251550da 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/DirectBinaryDecoder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/DirectBinaryDecoder.java
@@ -190,7 +190,7 @@ class DirectBinaryDecoder extends BinaryDecoder {
   }
 
   @Override
-  public boolean isEnd() throws IOException {
+  public boolean isEnd() {
     throw new UnsupportedOperationException();
   }
 }
diff --git a/lang/java/avro/src/main/java/org/apache/avro/io/Encoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/Encoder.java
index db3e88b6c8..85d5c421fb 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/Encoder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/Encoder.java
@@ -39,7 +39,7 @@ import org.apache.avro.util.Utf8;
  * <p/>
  * {@link EncoderFactory} contains Encoder construction and configuration
  * facilities.
- * 
+ *
  * @see EncoderFactory
  * @see Decoder
  */
@@ -48,7 +48,7 @@ public abstract class Encoder implements Flushable {
   /**
    * "Writes" a null value. (Doesn't actually write anything, but advances the
    * state of the parser if this class is stateful.)
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and a null is not
    *                           expected
    */
@@ -56,7 +56,7 @@ public abstract class Encoder implements Flushable {
 
   /**
    * Write a boolean value.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and a boolean is 
not
    *                           expected
    */
@@ -64,7 +64,7 @@ public abstract class Encoder implements Flushable {
 
   /**
    * Writes a 32-bit integer.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and an integer is 
not
    *                           expected
    */
@@ -72,7 +72,7 @@ public abstract class Encoder implements Flushable {
 
   /**
    * Write a 64-bit integer.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and a long is not
    *                           expected
    */
@@ -80,7 +80,7 @@ public abstract class Encoder implements Flushable {
 
   /**
    * Write a float.
-   * 
+   *
    * @throws IOException
    * @throws AvroTypeException If this is a stateful writer and a float is not
    *                           expected
@@ -89,7 +89,7 @@ public abstract class Encoder implements Flushable {
 
   /**
    * Write a double.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and a double is not
    *                           expected
    */
@@ -97,7 +97,7 @@ public abstract class Encoder implements Flushable {
 
   /**
    * Write a Unicode character string.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and a char-string 
is
    *                           not expected
    */
@@ -107,7 +107,7 @@ public abstract class Encoder implements Flushable {
    * Write a Unicode character string. The default implementation converts the
    * String to a {@link org.apache.avro.util.Utf8}. Some Encoder 
implementations
    * may want to do something different as a performance optimization.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and a char-string 
is
    *                           not expected
    */
@@ -119,7 +119,7 @@ public abstract class Encoder implements Flushable {
    * Write a Unicode character string. If the CharSequence is an
    * {@link org.apache.avro.util.Utf8} it writes this directly, otherwise the
    * CharSequence is converted to a String via toString() and written.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and a char-string 
is
    *                           not expected
    */
@@ -132,7 +132,7 @@ public abstract class Encoder implements Flushable {
 
   /**
    * Write a byte string.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and a byte-string 
is
    *                           not expected
    */
@@ -140,7 +140,7 @@ public abstract class Encoder implements Flushable {
 
   /**
    * Write a byte string.
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and a byte-string 
is
    *                           not expected
    */
@@ -149,7 +149,7 @@ public abstract class Encoder implements Flushable {
   /**
    * Writes a byte string. Equivalent to
    * <tt>writeBytes(bytes, 0, bytes.length)</tt>
-   * 
+   *
    * @throws IOException
    * @throws AvroTypeException If this is a stateful writer and a byte-string 
is
    *                           not expected
@@ -160,7 +160,7 @@ public abstract class Encoder implements Flushable {
 
   /**
    * Writes a fixed size binary object.
-   * 
+   *
    * @param bytes The contents to write
    * @param start The position within <tt>bytes</tt> where the contents start.
    * @param len   The number of bytes to write.
@@ -172,8 +172,8 @@ public abstract class Encoder implements Flushable {
 
   /**
    * A shorthand for <tt>writeFixed(bytes, 0, bytes.length)</tt>
-   * 
-   * @param bytes
+   *
+   * @param bytes the data
    */
   public void writeFixed(byte[] bytes) throws IOException {
     writeFixed(bytes, 0, bytes.length);
@@ -194,8 +194,8 @@ public abstract class Encoder implements Flushable {
 
   /**
    * Writes an enumeration.
-   * 
-   * @param e
+   *
+   * @param e the enumeration to write
    * @throws AvroTypeException If this is a stateful writer and an enumeration 
is
    *                           not expected or the <tt>e</tt> is out of range.
    * @throws IOException
@@ -214,9 +214,9 @@ public abstract class Encoder implements Flushable {
    * the array have been written, call {@link #writeArrayEnd}.
    *
    * As an example, let's say you want to write an array of records, the record
-   * consisting of an Long field and a Boolean field. Your code would look
+   * consisting of a Long field and a Boolean field. Your code would look
    * something like this:
-   * 
+   *
    * <pre>
    * out.writeArrayStart();
    * out.setItemCount(list.size());
@@ -227,7 +227,7 @@ public abstract class Encoder implements Flushable {
    * }
    * out.writeArrayEnd();
    * </pre>
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and an array is not
    *                           expected
    */
@@ -248,8 +248,8 @@ public abstract class Encoder implements Flushable {
   /**
    * Start a new item of an array or map. See {@link #writeArrayStart} for 
usage
    * information.
-   * 
-   * @throws AvroTypeException If called outside of an array or map context
+   *
+   * @throws AvroTypeException If called outside an array or map context
    */
   public abstract void startItem() throws IOException;
 
@@ -268,9 +268,9 @@ public abstract class Encoder implements Flushable {
    * usage.
    *
    * As an example of usage, let's say you want to write a map of records, the
-   * record consisting of an Long field and a Boolean field. Your code would 
look
+   * record consisting of a Long field and a Boolean field. Your code would 
look
    * something like this:
-   * 
+   *
    * <pre>
    * out.writeMapStart();
    * out.setItemCount(list.size());
@@ -282,7 +282,7 @@ public abstract class Encoder implements Flushable {
    * }
    * out.writeMapEnd();
    * </pre>
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and a map is not
    *                           expected
    */
@@ -302,15 +302,15 @@ public abstract class Encoder implements Flushable {
    * Call this method to write the tag of a union.
    *
    * As an example of usage, let's say you want to write a union, whose second
-   * branch is a record consisting of an Long field and a Boolean field. Your 
code
+   * branch is a record consisting of a Long field and a Boolean field. Your 
code
    * would look something like this:
-   * 
+   *
    * <pre>
    * out.writeIndex(1);
    * out.writeLong(record.longField);
    * out.writeBoolean(record.boolField);
    * </pre>
-   * 
+   *
    * @throws AvroTypeException If this is a stateful writer and a map is not
    *                           expected
    */
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/EncoderFactory.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/EncoderFactory.java
index 2039f30097..eaa83ba8ba 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/EncoderFactory.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/EncoderFactory.java
@@ -166,7 +166,6 @@ public class EncoderFactory {
    *         <i>reuse</i> is null, this will be a new instance. If 
<i>reuse</i> is
    *         not null, then the returned instance may be a new instance or
    *         <i>reuse</i> reconfigured to use <i>out</i>.
-   * @throws IOException
    * @see BufferedBinaryEncoder
    * @see Encoder
    */
@@ -287,7 +286,6 @@ public class EncoderFactory {
    *         <i>reuse</i> is null, this will be a new instance. If 
<i>reuse</i> is
    *         not null, then the returned instance may be a new instance or
    *         <i>reuse</i> reconfigured to use <i>out</i>.
-   * @throws IOException
    * @see BlockingBinaryEncoder
    * @see Encoder
    */
@@ -403,7 +401,7 @@ public class EncoderFactory {
    * {@link ValidatingEncoder} is not thread-safe.
    *
    * @param schema  The Schema to validate operations against. Cannot be null.
-   * @param encoder The Encoder to wrap. Cannot be be null.
+   * @param encoder The Encoder to wrap. Cannot be null.
    * @return A ValidatingEncoder configured to wrap <i>encoder</i> and validate
    *         against <i>schema</i>
    * @throws IOException
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/FastReaderBuilder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/FastReaderBuilder.java
index f6e1ed5aae..dbd06f305e 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/FastReaderBuilder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/FastReaderBuilder.java
@@ -140,7 +140,7 @@ public class FastReaderBuilder {
     return recordReader;
   }
 
-  private RecordReader initializeRecordReader(RecordReader recordReader, 
RecordAdjust action) throws IOException {
+  private void initializeRecordReader(RecordReader recordReader, RecordAdjust 
action) throws IOException {
     recordReader.startInitialization();
 
     // generate supplier for the new object instances
@@ -171,7 +171,6 @@ public class FastReaderBuilder {
     }
 
     recordReader.finishInitialization(readSteps, action.reader, 
action.instanceSupplier);
-    return recordReader;
   }
 
   private ExecutionStep createFieldSetter(Field field, FieldReader reader) {
@@ -277,7 +276,7 @@ public class FastReaderBuilder {
         throw new IllegalStateException("Error getting reader for action type 
" + action.getClass());
       }
     case DO_NOTHING:
-      return getReaderForBaseType(action.reader, action.writer);
+      return getReaderForBaseType(action.reader);
     case RECORD:
       return createRecordReader((RecordAdjust) action);
     case ENUM:
@@ -297,7 +296,7 @@ public class FastReaderBuilder {
     }
   }
 
-  private FieldReader getReaderForBaseType(Schema readerSchema, Schema 
writerSchema) throws IOException {
+  private FieldReader getReaderForBaseType(Schema readerSchema) {
     switch (readerSchema.getType()) {
     case NULL:
       return (old, decoder) -> {
@@ -307,7 +306,7 @@ public class FastReaderBuilder {
     case BOOLEAN:
       return (old, decoder) -> decoder.readBoolean();
     case STRING:
-      return createStringReader(readerSchema, writerSchema);
+      return createStringReader(readerSchema);
     case INT:
       return (old, decoder) -> decoder.readInt();
     case LONG:
@@ -319,7 +318,7 @@ public class FastReaderBuilder {
     case BYTES:
       return createBytesReader();
     case FIXED:
-      return createFixedReader(readerSchema, writerSchema);
+      return createFixedReader(readerSchema);
     case RECORD: // covered by action type
     case UNION: // covered by action type
     case ENUM: // covered by action type
@@ -330,7 +329,7 @@ public class FastReaderBuilder {
     }
   }
 
-  private FieldReader createPromotingReader(Promote promote) throws 
IOException {
+  private FieldReader createPromotingReader(Promote promote) {
     switch (promote.reader.getType()) {
     case BYTES:
       return (reuse, decoder) -> 
ByteBuffer.wrap(decoder.readString(null).getBytes());
@@ -364,7 +363,7 @@ public class FastReaderBuilder {
         "No promotion possible for type " + promote.writer.getType() + " to " 
+ promote.reader.getType());
   }
 
-  private FieldReader createStringReader(Schema readerSchema, Schema 
writerSchema) {
+  private FieldReader createStringReader(Schema readerSchema) {
     FieldReader stringReader = createSimpleStringReader(readerSchema);
     if (isClassPropEnabled()) {
       return 
getTransformingStringReader(readerSchema.getProp(SpecificData.CLASS_PROP), 
stringReader);
@@ -497,7 +496,7 @@ public class FastReaderBuilder {
     });
   }
 
-  private FieldReader createFixedReader(Schema readerSchema, Schema 
writerSchema) {
+  private FieldReader createFixedReader(Schema readerSchema) {
     return reusingReader((reuse, decoder) -> {
       GenericFixed fixed = (GenericFixed) data.createFixed(reuse, 
readerSchema);
       decoder.readFixed(fixed.bytes(), 0, readerSchema.getFixedSize());
@@ -516,9 +515,9 @@ public class FastReaderBuilder {
 
   public interface FieldReader extends DatumReader<Object> {
     @Override
-    public Object read(Object reuse, Decoder decoder) throws IOException;
+    Object read(Object reuse, Decoder decoder) throws IOException;
 
-    public default boolean canReuse() {
+    default boolean canReuse() {
       return false;
     }
 
@@ -530,7 +529,7 @@ public class FastReaderBuilder {
 
   public interface ReusingFieldReader extends FieldReader {
     @Override
-    public default boolean canReuse() {
+    default boolean canReuse() {
       return true;
     }
   }
@@ -608,7 +607,7 @@ public class FastReaderBuilder {
   }
 
   public interface ExecutionStep {
-    public void execute(Object record, Decoder decoder) throws IOException;
+    void execute(Object record, Decoder decoder) throws IOException;
   }
 
 }
diff --git a/lang/java/avro/src/main/java/org/apache/avro/io/JsonDecoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/JsonDecoder.java
index 2ad496a5b8..64e7ba9faf 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/JsonDecoder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/JsonDecoder.java
@@ -47,7 +47,7 @@ import com.fasterxml.jackson.databind.util.TokenBuffer;
  */
 public class JsonDecoder extends ParsingDecoder implements 
Parser.ActionHandler {
   private JsonParser in;
-  private static JsonFactory jsonFactory = new JsonFactory();
+  private static final JsonFactory JSON_FACTORY = new JsonFactory();
   Stack<ReorderBuffer> reorderBuffers = new Stack<>();
   ReorderBuffer currentReorderBuffer;
 
@@ -97,7 +97,7 @@ public class JsonDecoder extends ParsingDecoder implements 
Parser.ActionHandler
     parser.reset();
     reorderBuffers.clear();
     currentReorderBuffer = null;
-    this.in = jsonFactory.createParser(in);
+    this.in = JSON_FACTORY.createParser(in);
     this.in.nextToken();
     return this;
   }
@@ -268,8 +268,7 @@ public class JsonDecoder extends ParsingDecoder implements 
Parser.ActionHandler
   }
 
   private byte[] readByteArray() throws IOException {
-    byte[] result = in.getText().getBytes(StandardCharsets.ISO_8859_1);
-    return result;
+    return in.getText().getBytes(StandardCharsets.ISO_8859_1);
   }
 
   @Override
diff --git a/lang/java/avro/src/main/java/org/apache/avro/io/JsonEncoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/JsonEncoder.java
index 46fb6b5cb5..50f44c0afd 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/JsonEncoder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/JsonEncoder.java
@@ -50,7 +50,7 @@ import com.fasterxml.jackson.core.util.MinimalPrettyPrinter;
  * JsonEncoder is not thread-safe.
  */
 public class JsonEncoder extends ParsingEncoder implements 
Parser.ActionHandler {
-  private static final String LINE_SEPARATOR = 
System.getProperty("line.separator");
+  private static final String LINE_SEPARATOR = System.lineSeparator();
   final Parser parser;
   private JsonGenerator out;
   private boolean includeNamespace = true;
@@ -88,7 +88,7 @@ public class JsonEncoder extends ParsingEncoder implements 
Parser.ActionHandler
   enum JsonOptions {
     Pretty,
 
-    // Prevent underlying outputstream to be flush for optimisation purpose.
+    // Prevent underlying OutputStream to be flush for optimisation purpose.
     NoFlushStream
   }
 
@@ -98,7 +98,7 @@ public class JsonEncoder extends ParsingEncoder implements 
Parser.ActionHandler
     Objects.requireNonNull(out, "OutputStream cannot be null");
     JsonGenerator g = new JsonFactory().createGenerator(out, 
JsonEncoding.UTF8);
     if (options.contains(JsonOptions.NoFlushStream)) {
-      g = g.configure(JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM, false);
+      g.configure(JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM, false);
     }
     final PrettyPrinter pp;
     if (options.contains(JsonOptions.Pretty)) {
@@ -170,15 +170,13 @@ public class JsonEncoder extends ParsingEncoder 
implements Parser.ActionHandler
    * @param generator The JsonGenerator to direct output to. Cannot be null.
    * @throws IOException
    * @throws NullPointerException if {@code generator} is {@code null}
-   * @return this JsonEncoder
    */
-  private JsonEncoder configure(JsonGenerator generator) throws IOException {
+  private void configure(JsonGenerator generator) throws IOException {
     Objects.requireNonNull(generator, "JsonGenerator cannot be null");
     if (null != parser) {
       flush();
     }
     this.out = generator;
-    return this;
   }
 
   @Override
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/ResolvingDecoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/ResolvingDecoder.java
index 6f119a39b6..6bdb16a332 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/ResolvingDecoder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/ResolvingDecoder.java
@@ -140,7 +140,7 @@ public class ResolvingDecoder extends ValidatingDecoder {
 
   /**
    * Consume any more data that has been written by the writer but not needed 
by
-   * the reader so that the the underlying decoder is in proper shape for the 
next
+   * the reader so that the underlying decoder is in proper shape for the next
    * record. This situation happens when, for example, the writer writes a 
record
    * with two fields and the reader needs only the first field.
    *
@@ -187,11 +187,11 @@ public class ResolvingDecoder extends ValidatingDecoder {
   public double readDouble() throws IOException {
     Symbol actual = parser.advance(Symbol.DOUBLE);
     if (actual == Symbol.INT) {
-      return (double) in.readInt();
+      return in.readInt();
     } else if (actual == Symbol.LONG) {
       return (double) in.readLong();
     } else if (actual == Symbol.FLOAT) {
-      return (double) in.readFloat();
+      return in.readFloat();
     } else {
       assert actual == Symbol.DOUBLE;
       return in.readDouble();
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/ValidatingEncoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/ValidatingEncoder.java
index d7440c7406..d61967751a 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/ValidatingEncoder.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/ValidatingEncoder.java
@@ -36,7 +36,7 @@ import org.apache.avro.util.Utf8;
  * and configure.
  * <p/>
  * ValidatingEncoder is not thread-safe.
- * 
+ *
  * @see Encoder
  * @see EncoderFactory
  */
@@ -44,12 +44,12 @@ public class ValidatingEncoder extends ParsingEncoder 
implements Parser.ActionHa
   protected Encoder out;
   protected final Parser parser;
 
-  ValidatingEncoder(Symbol root, Encoder out) throws IOException {
+  ValidatingEncoder(Symbol root, Encoder out) {
     this.out = out;
     this.parser = new Parser(root, this);
   }
 
-  ValidatingEncoder(Schema schema, Encoder in) throws IOException {
+  ValidatingEncoder(Schema schema, Encoder in) {
     this(new ValidatingGrammarGenerator().generate(schema), in);
   }
 
@@ -60,7 +60,7 @@ public class ValidatingEncoder extends ParsingEncoder 
implements Parser.ActionHa
 
   /**
    * Reconfigures this ValidatingEncoder to wrap the encoder provided.
-   * 
+   *
    * @param encoder The Encoder to wrap for validation.
    * @return This ValidatingEncoder.
    */
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Parser.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Parser.java
index 12fc4044a9..89269578d2 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Parser.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Parser.java
@@ -139,7 +139,7 @@ public class Parser {
    * repeater and <tt>input</tt> is either {@link Symbol#ARRAY_END} or
    * {@link Symbol#MAP_END} pushes nothing.
    *
-   * @param sym
+   * @param sym the symbol
    */
   public final void pushProduction(Symbol sym) {
     Symbol[] p = sym.production;
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
 
b/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
index f1c9d139e7..77acbd9524 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
@@ -223,7 +223,7 @@ public class ResolvingGrammarGenerator extends 
ValidatingGrammarGenerator {
     }
   }
 
-  private static EncoderFactory factory = new 
EncoderFactory().configureBufferSize(32);
+  private final static EncoderFactory ENCODER_FACTORY = new 
EncoderFactory().configureBufferSize(32);
 
   /**
    * Returns the Avro binary encoded version of <tt>n</tt> according to the 
schema
@@ -236,7 +236,7 @@ public class ResolvingGrammarGenerator extends 
ValidatingGrammarGenerator {
    */
   private static byte[] getBinary(Schema s, JsonNode n) throws IOException {
     ByteArrayOutputStream out = new ByteArrayOutputStream();
-    Encoder e = factory.binaryEncoder(out, null);
+    Encoder e = ENCODER_FACTORY.binaryEncoder(out, null);
     encode(e, s, n);
     e.flush();
     return out.toByteArray();
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Symbol.java 
b/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Symbol.java
index a18f3fdbcd..b5dcbeb68f 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Symbol.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Symbol.java
@@ -51,15 +51,15 @@ public abstract class Symbol {
     IMPLICIT_ACTION,
     /** non-terminal action symbol which is explicitly consumed */
     EXPLICIT_ACTION
-  };
+  }
 
   /// The kind of this symbol.
   public final Kind kind;
 
   /**
    * The production for this symbol. If this symbol is a terminal this is
-   * <tt>null</tt>. Otherwise this holds the the sequence of the symbols that
-   * forms the production for this symbol. The sequence is in the reverse 
order of
+   * <tt>null</tt>. Otherwise this holds the sequence of the symbols that forms
+   * the production for this symbol. The sequence is in the reverse order of
    * production. This is useful for easy copying onto parsing stack.
    *
    * Please note that this is a final. So the production for a symbol should be
@@ -94,7 +94,7 @@ public abstract class Symbol {
 
   /**
    * A convenience method to construct a sequence.
-   * 
+   *
    * @param production The constituent symbols of the sequence.
    */
   static Symbol seq(Symbol... production) {
@@ -103,7 +103,7 @@ public abstract class Symbol {
 
   /**
    * A convenience method to construct a repeater.
-   * 
+   *
    * @param symsToRepeat The symbols to repeat in the repeater.
    */
   static Symbol repeat(Symbol endSymbol, Symbol... symsToRepeat) {
@@ -119,7 +119,7 @@ public abstract class Symbol {
 
   /**
    * A convenience method to construct an ErrorAction.
-   * 
+   *
    * @param e
    */
   static Symbol error(String e) {
@@ -128,7 +128,7 @@ public abstract class Symbol {
 
   /**
    * A convenience method to construct a ResolvingAction.
-   * 
+   *
    * @param w The writer symbol
    * @param r The reader symbol
    */
@@ -201,7 +201,7 @@ public abstract class Symbol {
    * @param skip  The position where the output input sub-array starts.
    * @param map   A map of symbols which have already been expanded. Useful for
    *              handling recursive definitions and for caching.
-   * @param map2  A map to to store the list of fix-ups.
+   * @param map2  A map to store the list of fix-ups.
    */
   static void flatten(Symbol[] in, int start, Symbol[] out, int skip, 
Map<Sequence, Sequence> map,
       Map<Sequence, List<Fixup>> map2) {
@@ -238,7 +238,7 @@ public abstract class Symbol {
   /**
    * Returns the amount of space required to flatten the given sub-array of
    * symbols.
-   * 
+   *
    * @param symbols The array of input symbols.
    * @param start   The index where the subarray starts.
    * @return The number of symbols that will be produced if one expands the 
given
@@ -317,7 +317,7 @@ public abstract class Symbol {
 
     @Override
     public Iterator<Symbol> iterator() {
-      return new Iterator<Symbol>() {
+      return new Iterator<>() {
         private int pos = production.length;
 
         @Override
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java
 
b/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java
index 7798f520ae..2f2e9cdc1c 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java
@@ -41,7 +41,7 @@ public class ValidatingGrammarGenerator {
    * given schema <tt>sc</tt>. If there is already an entry for the given 
schema
    * in the given map <tt>seen</tt> then that entry is returned. Otherwise a 
new
    * symbol is generated and an entry is inserted into the map.
-   * 
+   *
    * @param sc   The schema for which the start symbol is required
    * @param seen A map of schema to symbol mapping done so far.
    * @return The start symbol for the schema
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/message/BinaryMessageDecoder.java
 
b/lang/java/avro/src/main/java/org/apache/avro/message/BinaryMessageDecoder.java
index d835bd3fc8..46d1d04b8b 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/message/BinaryMessageDecoder.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/message/BinaryMessageDecoder.java
@@ -122,7 +122,7 @@ public class BinaryMessageDecoder<D> extends 
MessageDecoder.BaseDecoder<D> {
   public void addSchema(Schema writeSchema) {
     long fp = SchemaNormalization.parsingFingerprint64(writeSchema);
     final Schema actualReadSchema = this.readSchema != null ? this.readSchema 
: writeSchema;
-    codecByFingerprint.put(fp, new RawMessageDecoder<D>(model, writeSchema, 
actualReadSchema));
+    codecByFingerprint.put(fp, new RawMessageDecoder<>(model, writeSchema, 
actualReadSchema));
   }
 
   private RawMessageDecoder<D> getDecoder(long fp) {
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/message/RawMessageDecoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/message/RawMessageDecoder.java
index ad2b1d31e4..917e5be88e 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/message/RawMessageDecoder.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/message/RawMessageDecoder.java
@@ -78,9 +78,7 @@ public class RawMessageDecoder<D> extends 
MessageDecoder.BaseDecoder<D> {
    * @param writeSchema the {@link Schema} used to decode buffers
    */
   public RawMessageDecoder(GenericData model, Schema writeSchema, Schema 
readSchema) {
-    Schema writeSchema1 = writeSchema;
-    Schema readSchema1 = readSchema;
-    this.reader = model.createDatumReader(writeSchema1, readSchema1);
+    this.reader = model.createDatumReader(writeSchema, readSchema);
   }
 
   @Override
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/message/RawMessageEncoder.java 
b/lang/java/avro/src/main/java/org/apache/avro/message/RawMessageEncoder.java
index 4df0d4c368..230c6c1fea 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/message/RawMessageEncoder.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/message/RawMessageEncoder.java
@@ -81,9 +81,8 @@ public class RawMessageEncoder<D> implements 
MessageEncoder<D> {
    * @param shouldCopy whether to copy buffers before returning encoded results
    */
   public RawMessageEncoder(GenericData model, Schema schema, boolean 
shouldCopy) {
-    Schema writeSchema = schema;
     this.copyOutputBytes = shouldCopy;
-    this.writer = model.createDatumWriter(writeSchema);
+    this.writer = model.createDatumWriter(schema);
   }
 
   @Override
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/path/TracingAvroTypeException.java
 
b/lang/java/avro/src/main/java/org/apache/avro/path/TracingAvroTypeException.java
index 4aed18b91d..f7dae885d5 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/path/TracingAvroTypeException.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/path/TracingAvroTypeException.java
@@ -59,8 +59,6 @@ public class TracingAvroTypeException extends 
AvroTypeException implements PathT
         sb.append(step.toString());
       }
     }
-    AvroTypeException summary = new AvroTypeException(sb.toString());
-    summary.initCause(cause);
-    return summary;
+    return new AvroTypeException(sb.toString(), cause);
   }
 }
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/reflect/FieldAccessReflect.java 
b/lang/java/avro/src/main/java/org/apache/avro/reflect/FieldAccessReflect.java
index 5d51be054b..df258f9d50 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/reflect/FieldAccessReflect.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/reflect/FieldAccessReflect.java
@@ -40,8 +40,8 @@ class FieldAccessReflect extends FieldAccess {
 
   private static class ReflectionBasedAccessor extends FieldAccessor {
     protected final Field field;
-    private boolean isStringable;
-    private boolean isCustomEncoded;
+    private final boolean isStringable;
+    private final boolean isCustomEncoded;
 
     public ReflectionBasedAccessor(Field field) {
       this.field = field;
@@ -105,7 +105,7 @@ class FieldAccessReflect extends FieldAccess {
 
   private static final class ReflectionBasesAccessorCustomEncoded extends 
ReflectionBasedAccessor {
 
-    private CustomEncoding<?> encoding;
+    private final CustomEncoding<?> encoding;
 
     public ReflectionBasesAccessorCustomEncoded(Field f, CustomEncoding<?> 
encoding) {
       super(f);
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java 
b/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
index 0c0b10478a..19c3027f27 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
@@ -547,8 +547,7 @@ public class ReflectData extends SpecificData {
     String name = getNameForNonStringMapRecord(keyType, valueType, keySchema, 
valueSchema);
     Schema elementSchema = Schema.createRecord(name, null, null, false);
     elementSchema.setFields(Arrays.asList(keyField, valueField));
-    Schema arraySchema = Schema.createArray(elementSchema);
-    return arraySchema;
+    return Schema.createArray(elementSchema);
   }
 
   /*
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/specific/ExternalizableInput.java
 
b/lang/java/avro/src/main/java/org/apache/avro/specific/ExternalizableInput.java
index 503db7d16f..8fa56ae123 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/specific/ExternalizableInput.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/specific/ExternalizableInput.java
@@ -42,11 +42,6 @@ class ExternalizableInput extends InputStream {
     in.close();
   }
 
-  @Override
-  public boolean markSupported() {
-    return false;
-  }
-
   @Override
   public int read() throws IOException {
     return in.read();
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java 
b/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
index c30616e17a..3f7b592c07 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
@@ -635,7 +635,7 @@ public class SpecificData extends GenericData {
 
     boolean useSchema = SchemaConstructable.class.isAssignableFrom(c);
     Constructor<?> meth = CTOR_CACHE.apply(c);
-    Object[] params = useSchema ? new Object[] { schema } : (Object[]) null;
+    Object[] params = useSchema ? new Object[] { schema } : null;
 
     return (old, sch) -> {
       try {
diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/util/ByteBufferInputStream.java 
b/lang/java/avro/src/main/java/org/apache/avro/util/ByteBufferInputStream.java
index f0ae5cc8a5..6abb62015d 100644
--- 
a/lang/java/avro/src/main/java/org/apache/avro/util/ByteBufferInputStream.java
+++ 
b/lang/java/avro/src/main/java/org/apache/avro/util/ByteBufferInputStream.java
@@ -25,7 +25,7 @@ import java.util.List;
 
 /** Utility to present {@link ByteBuffer} data as an {@link InputStream}. */
 public class ByteBufferInputStream extends InputStream {
-  private List<ByteBuffer> buffers;
+  private final List<ByteBuffer> buffers;
   private int current;
 
   public ByteBufferInputStream(List<ByteBuffer> buffers) {
@@ -90,7 +90,7 @@ public class ByteBufferInputStream extends InputStream {
   /**
    * Returns the next non-empty buffer.
    */
-  private ByteBuffer getBuffer() throws IOException {
+  private ByteBuffer getBuffer() {
     while (current < buffers.size()) {
       ByteBuffer buffer = buffers.get(current);
       if (buffer.hasRemaining())

Reply via email to