diff --git a/lang/java/archetypes/avro-service-archetype/src/main/pom/pom.xml b/lang/java/archetypes/avro-service-archetype/src/main/pom/pom.xml
index 4c9558c40b9..069a367b973 100644
--- a/lang/java/archetypes/avro-service-archetype/src/main/pom/pom.xml
+++ b/lang/java/archetypes/avro-service-archetype/src/main/pom/pom.xml
@@ -33,8 +33,9 @@
Simple Avro Ordering Service
- 1.8
- 1.8
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+ ${project.build.sourceEncoding}
${project.version}
${jackson-bom.version}
${junit.version}
diff --git a/lang/java/compiler/pom.xml b/lang/java/compiler/pom.xml
index 53719816387..3195905c03e 100644
--- a/lang/java/compiler/pom.xml
+++ b/lang/java/compiler/pom.xml
@@ -182,37 +182,8 @@
-
-
-
- org.eclipse.m2e
- lifecycle-mapping
- 1.0.0
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- [1.0,)
-
- exec
-
-
-
-
-
-
-
-
-
-
-
-
-
${project.groupId}
@@ -241,4 +212,42 @@
+
+
+ m2e
+
+ m2e.version
+
+
+
+
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ [1.0,)
+
+ exec
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lang/java/idl/pom.xml b/lang/java/idl/pom.xml
index 9ace6dc750f..6363ec150a5 100644
--- a/lang/java/idl/pom.xml
+++ b/lang/java/idl/pom.xml
@@ -107,37 +107,8 @@
-
-
-
- org.eclipse.m2e
- lifecycle-mapping
- 1.0.0
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- [1.0,)
-
- exec
-
-
-
-
-
-
-
-
-
-
-
-
-
${project.groupId}
@@ -159,4 +130,43 @@
jackson-databind
+
+
+
+ m2e
+
+ m2e.version
+
+
+
+
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ [1.0,)
+
+ exec
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lang/java/idl/src/main/java/org/apache/avro/idl/IdlFile.java b/lang/java/idl/src/main/java/org/apache/avro/idl/IdlFile.java
index 3cbb14807cf..56627b5821b 100644
--- a/lang/java/idl/src/main/java/org/apache/avro/idl/IdlFile.java
+++ b/lang/java/idl/src/main/java/org/apache/avro/idl/IdlFile.java
@@ -64,7 +64,7 @@ public List getWarnings() {
public List getWarnings(String importFile) {
return warnings.stream()
- .map(warning -> importFile + " " + Character.toLowerCase(warning.charAt(0)) + warning.substring(1))
+ .map(warning -> importFile + ' ' + Character.toLowerCase(warning.charAt(0)) + warning.substring(1))
.collect(Collectors.toList());
}
@@ -96,7 +96,7 @@ public Schema getNamedSchema(String name) {
return result;
}
if (namespace != null && !name.contains(".")) {
- result = namedSchemas.get(namespace + "." + name);
+ result = namedSchemas.get(namespace + '.' + name);
}
return result;
}
@@ -111,9 +111,9 @@ String outputString() {
} else {
StringBuilder buffer = new StringBuilder();
for (Schema schema : namedSchemas.values()) {
- buffer.append(",").append(schema);
+ buffer.append(',').append(schema);
}
- buffer.append("]").setCharAt(0, '[');
+ buffer.append(']').setCharAt(0, '[');
return buffer.toString();
}
}
diff --git a/lang/java/idl/src/main/java/org/apache/avro/idl/Schemas.java b/lang/java/idl/src/main/java/org/apache/avro/idl/Schemas.java
index 9b2ba7f21c5..da4b949d2bc 100644
--- a/lang/java/idl/src/main/java/org/apache/avro/idl/Schemas.java
+++ b/lang/java/idl/src/main/java/org/apache/avro/idl/Schemas.java
@@ -56,8 +56,6 @@ public static T visit(final Schema start, final SchemaVisitor visitor) {
switch (action) {
case CONTINUE:
break;
- case SKIP_SUBTREE:
- throw new UnsupportedOperationException();
case SKIP_SIBLINGS:
while (dq.peek() instanceof Schema) {
dq.remove();
@@ -65,6 +63,7 @@ public static T visit(final Schema start, final SchemaVisitor visitor) {
break;
case TERMINATE:
return visitor.get();
+ case SKIP_SUBTREE:
default:
throw new UnsupportedOperationException("Invalid action " + action);
}
diff --git a/lang/java/idl/src/test/idl/input/forward_ref.avdl b/lang/java/idl/src/test/idl/input/forward_ref.avdl
index e9317fec0a2..b75d60a4efd 100644
--- a/lang/java/idl/src/test/idl/input/forward_ref.avdl
+++ b/lang/java/idl/src/test/idl/input/forward_ref.avdl
@@ -15,17 +15,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
@namespace("org.foo")
protocol Import {
-/* Name Value record */
-record ANameValue {
- /** the name */
- string name;
- /** the value */
- string value;
- /* is the value a json object */
- ValueType type = "PLAIN";
-}
-enum ValueType {JSON, BASE64BIN, PLAIN}
+ /* Name Value record */
+ record ANameValue {
+ /** the name */
+ string name;
+ /** the value */
+ string value;
+ /* is the value a json object */
+ ValueType type = "PLAIN";
+ }
+
+ enum ValueType {
+ JSON, BASE64BIN, PLAIN
+ }
}
diff --git a/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java b/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java
index d0407eb7468..a429a21e1f2 100644
--- a/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java
+++ b/lang/java/maven-plugin/src/main/java/org/apache/avro/mojo/AbstractAvroMojo.java
@@ -18,6 +18,18 @@
package org.apache.avro.mojo;
+import org.apache.avro.LogicalTypes;
+import org.apache.avro.Protocol;
+import org.apache.avro.Schema;
+import org.apache.avro.compiler.specific.SpecificCompiler;
+import org.apache.avro.generic.GenericData;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.model.fileset.FileSet;
+import org.apache.maven.shared.model.fileset.util.FileSetManager;
+
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@@ -28,15 +40,6 @@
import java.util.Arrays;
import java.util.List;
-import org.apache.avro.LogicalTypes;
-import org.apache.avro.compiler.specific.SpecificCompiler;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.shared.model.fileset.FileSet;
-import org.apache.maven.shared.model.fileset.util.FileSetManager;
-
/**
* Base for Avro Compiler Mojos.
*/
@@ -274,14 +277,23 @@ private String[] getIncludedFiles(String absPath, String[] excludes, String[] in
}
private void compileFiles(String[] files, File sourceDir, File outDir) throws MojoExecutionException {
- for (String filename : files) {
- try {
- // Need to register custom logical type factories before schema compilation.
- loadLogicalTypesFactories();
- doCompile(filename, sourceDir, outDir);
- } catch (IOException e) {
- throw new MojoExecutionException("Error compiling protocol file " + filename + " to " + outDir, e);
+ final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(createClassLoader());
+
+ for (String filename : files) {
+ try {
+ // Need to register custom logical type factories before schema compilation.
+ loadLogicalTypesFactories();
+ doCompile(filename, sourceDir, outDir);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Error compiling protocol file " + filename + " to " + outDir, e);
+ }
}
+ } catch (MalformedURLException | DependencyResolutionRequiredException e) {
+ throw new MojoExecutionException("Cannot locate classpath entries", e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
@@ -314,7 +326,7 @@ protected List