diff --git a/lang/java/compiler/pom.xml b/lang/java/compiler/pom.xml
index 4ebd8b11e48..53719816387 100644
--- a/lang/java/compiler/pom.xml
+++ b/lang/java/compiler/pom.xml
@@ -1,11 +1,11 @@
- org.codehaus.mojo
+ org.javacc.plugin
javacc-maven-plugin
@@ -133,11 +133,11 @@
test
-classpath
-
+
org.apache.avro.compiler.specific.SchemaTask
${project.basedir}/src/test/resources/full_record_v1.avsc
${project.basedir}/src/test/resources/full_record_v2.avsc
- ${project.basedir}/target/generated-test-sources
+ ${project.basedir}/target/generated-test-sources/javacc
@@ -149,10 +149,8 @@
add-test-source
generate-test-sources
@@ -161,16 +159,14 @@
- ${project.basedir}/target/generated-test-sources
+ ${project.basedir}/target/generated-test-sources/javacc
add-source
generate-sources
@@ -225,8 +221,8 @@
org.apache.commons
- commons-lang3
- ${commons-lang.version}
+ commons-text
+ ${commons-text.version}
org.apache.velocity
diff --git a/lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj b/lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj
index 5fe78714420..ee467ff9902 100644
--- a/lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj
+++ b/lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj
@@ -81,7 +81,7 @@ import org.apache.avro.util.internal.Accessor;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.*;
-import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.text.StringEscapeUtils;
/**
* Grammar to parse a higher-level language into an Avro Schema.
@@ -96,7 +96,7 @@ public class Idl implements Closeable {
URI inputDir;
ClassLoader resourceLoader = null;
String namespace;
- Map names = new LinkedHashMap();
+ Map names = new LinkedHashMap<>();
private List parserWarnings = Collections.emptyList();
/**
@@ -137,6 +137,7 @@ public class Idl implements Closeable {
this.resourceLoader = parent.resourceLoader;
}
+ @SuppressWarnings("RedundantThrows")
public void close() throws IOException {
jj_input_stream.inputStream.close();
}
@@ -159,7 +160,7 @@ public class Idl implements Closeable {
JsonNode value = props.get(key);
if (!value.isArray())
throw error(key+" property must be array: "+value, token);
- List values = new ArrayList();
+ List values = new ArrayList<>();
for (JsonNode n : value)
if (n.isTextual())
values.add(n.textValue());
@@ -209,7 +210,6 @@ public class Idl implements Closeable {
}
return schema;
}
-
}
PARSER_END(Idl)
@@ -248,13 +248,13 @@ MORE :
SPECIAL_TOKEN :
{
- <"*/" > {DocCommentHelper.setDoc(matchedToken);} : DEFAULT
+ "*/" {DocCommentHelper.setDoc(matchedToken);} : DEFAULT
}
SKIP :
{
- <"*/" > : DEFAULT
+ "*/" : DEFAULT
}
/* RESERVED WORDS AND LITERALS */
@@ -1053,7 +1053,7 @@ Protocol CompilationUnit():
}
{
p = ProtocolDeclaration()
- ( < "\u001a" > )?
+ ( "\u001a" )?
( )?
{
@@ -1102,7 +1102,7 @@ private Schema NamedSchemaDeclaration(Map props):
Schema UnionDefinition():
{
Schema s;
- List schemata = new ArrayList();
+ List schemata = new ArrayList<>();
}
{
// Don't disallow unions here: its constructor disallows nested unions and throws a descriptive exception.
@@ -1127,7 +1127,7 @@ Protocol ProtocolDeclaration():
{
String name;
Protocol p;
- Map props = new LinkedHashMap();
+ Map props = new LinkedHashMap<>();
}
{
( SchemaProperty(props) )*
@@ -1164,8 +1164,7 @@ Schema EnumDeclaration():
symbols = EnumBody()
[ defaultSymbol=Identifier() ]
{
- Schema s = Schema.createEnum(name, doc, this.namespace, symbols,
- defaultSymbol);
+ Schema s = Schema.createEnum(name, doc, namespace, symbols, defaultSymbol);
names.put(s.getFullName(), s);
return s;
}
@@ -1173,7 +1172,7 @@ Schema EnumDeclaration():
List EnumBody():
{
- List symbols = new ArrayList();
+ List symbols = new ArrayList<>();
}
{
"{"
@@ -1197,7 +1196,7 @@ void ProtocolBody(Protocol p):
Schema schema;
Message message;
Protocol importProtocol;
- Map props = new LinkedHashMap();
+ Map props = new LinkedHashMap<>();
}
{
"{"
@@ -1234,13 +1233,8 @@ Protocol ImportIdl() : {
{
importFile = JsonString() ";"
{
- try {
- Idl idl = new Idl(findFile(importFile), this);
- try {
- return idl.CompilationUnit();
- } finally {
- idl.close();
- }
+ try (Idl idl=new Idl(findFile(importFile), this)){
+ return idl.CompilationUnit();
} catch (IOException e) {
throw error("Error importing "+importFile+": "+e, token);
}
@@ -1253,14 +1247,8 @@ Protocol ImportProtocol() : {
{
importFile = JsonString() ";"
{
-
- try {
- InputStream stream = findFile(importFile).openStream();
- try {
- return Protocol.parse(stream);
- } finally {
- stream.close();
- }
+ try (InputStream stream=findFile(importFile).openStream()) {
+ return Protocol.parse(stream);
} catch (IOException e) {
throw error("Error importing "+importFile+": "+e, token);
}
@@ -1273,17 +1261,12 @@ Schema ImportSchema() : {
{
importFile = JsonString() ";"
{
- try {
+ try (InputStream stream=findFile(importFile).openStream()){
Parser parser = new Schema.Parser();
parser.addTypes(names); // inherit names
- InputStream stream = findFile(importFile).openStream();
- try {
- Schema value = parser.parse(stream);
- names = parser.getTypes(); // update names
- return value;
- } finally {
- stream.close();
- }
+ Schema value = parser.parse(stream);
+ names = parser.getTypes(); // update names
+ return value;
} catch (IOException e) {
throw error("Error importing "+importFile+": "+e, token);
}
@@ -1309,7 +1292,7 @@ Schema FixedDeclaration():
Schema RecordDeclaration():
{
String name;
- List fields = new ArrayList();
+ List fields = new ArrayList<>();
boolean isError;
}
{
@@ -1361,7 +1344,7 @@ void VariableDeclarator(Schema type, List fields):
{
String name;
JsonNode defaultValue = null;
- Map props = new LinkedHashMap();
+ Map props = new LinkedHashMap<>();
}
{
( SchemaProperty(props) )*
@@ -1408,7 +1391,7 @@ private Message MessageDeclaration(Protocol p, Map props):
Schema request;
Schema response;
boolean oneWay = false;
- List errorSchemata = new ArrayList();
+ List errorSchemata = new ArrayList<>();
errorSchemata.add(Protocol.SYSTEM_ERROR);
}
{
@@ -1440,14 +1423,12 @@ void ErrorList(List errors):
Schema FormalParameters():
{
- List fields = new ArrayList();
+ List fields = new ArrayList<>();
}
{
- (
- "(" [ FormalParameter(fields) ( "," FormalParameter(fields) )* ] ")"
- )
+ "(" [ FormalParameter(fields) ( "," FormalParameter(fields) )* ] ")"
{
- return Schema.createRecord(fields);
+ return Schema.createRecord(null, null, null, false, fields);
}
}
@@ -1463,7 +1444,7 @@ void FormalParameter(List fields):
Schema Type():
{
Schema s;
- Map props = new LinkedHashMap();
+ Map props = new LinkedHashMap<>();
}
{
( SchemaProperty(props) )*
@@ -1557,10 +1538,8 @@ Schema ReferenceType():
StringBuilder sb = new StringBuilder();
}
{
- (
- part = Identifier() { sb.append(part); }
- ("." tok = AnyIdentifier() { sb.append(".").append(tok.image); })*
- )
+ part = Identifier() { sb.append(part); }
+ ("." tok = AnyIdentifier() { sb.append(".").append(tok.image); })*
{
String name = sb.toString();
if ((name.indexOf('.') == -1) && namespace != null)
@@ -1575,7 +1554,7 @@ Schema ReferenceType():
}
Schema PrimitiveType():
-{}
+{ Schema s; }
{
"boolean" { return Schema.create(Type.BOOLEAN); }
| "bytes" { return Schema.create(Type.BYTES); }
@@ -1589,7 +1568,7 @@ Schema PrimitiveType():
| "time_ms" { return LogicalTypes.timeMillis().addToSchema(Schema.create(Type.INT)); }
| "timestamp_ms" { return LogicalTypes.timestampMillis().addToSchema(Schema.create(Type.LONG)); }
| "local_timestamp_ms" { return LogicalTypes.localTimestampMillis().addToSchema(Schema.create(Type.LONG)); }
-| "decimal" { return DecimalTypeProperties(); }
+| "decimal" s = DecimalTypeProperties() { return s; }
| "uuid" {return LogicalTypes.uuid().addToSchema(Schema.create(Type.STRING));}
}
diff --git a/lang/java/pom.xml b/lang/java/pom.xml
index 3e434c9d1cf..366372320e6 100644
--- a/lang/java/pom.xml
+++ b/lang/java/pom.xml
@@ -23,7 +23,7 @@
org.apache.avro
avro-toplevel
1.12.0-SNAPSHOT
- ../../
+ ../../pom.xml
avro-parent
@@ -53,7 +53,7 @@
1.10.11
1.4
1.21
- 3.12.0
+ 1.9
1.9
4.3
2.2
@@ -64,7 +64,8 @@
5.1.2
3.0.0
3.0.0
- 2.6
+ 3.0.3
+ 7.0.10
@@ -210,9 +211,16 @@
- org.codehaus.mojo
+ org.javacc.plugin
javacc-maven-plugin
${javacc-plugin.version}
+
+
+ net.java.dev.javacc
+ javacc
+ ${javacc.version}
+
+
org.codehaus.mojo