Skip to content

Commit

Permalink
AVRO-3403: Improvements after review
Browse files Browse the repository at this point in the history
Improved the code thanks to good review comments.
  • Loading branch information
opwvhk committed Aug 9, 2023
1 parent 10e27a3 commit 634f1d4
Show file tree
Hide file tree
Showing 16 changed files with 441 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
<name>Simple Avro Ordering Service</name>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>${maven.compiler.source}</maven.compiler.source>
<maven.compiler.target>${maven.compiler.target}</maven.compiler.target>
<project.build.sourceEncoding>${project.build.sourceEncoding}</project.build.sourceEncoding>
<avro.version>${project.version}</avro.version>
<jackson-bom.version>${jackson-bom.version}</jackson-bom.version>
<junit5.version>${junit5.version}</junit5.version>
Expand Down
67 changes: 38 additions & 29 deletions lang/java/compiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,37 +182,8 @@
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>


<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down Expand Up @@ -241,4 +212,42 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>m2e</id>
<activation>
<property><name>m2e.version</name></property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
</project>
68 changes: 39 additions & 29 deletions lang/java/idl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,37 +107,8 @@
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>


<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
Expand All @@ -159,4 +130,43 @@
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>

<profiles>
<profile>
<id>m2e</id>
<activation>
<property><name>m2e.version</name></property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
</project>
8 changes: 4 additions & 4 deletions lang/java/idl/src/main/java/org/apache/avro/idl/IdlFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public List<String> getWarnings() {

public List<String> 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());
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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();
}
}
Expand Down
3 changes: 1 addition & 2 deletions lang/java/idl/src/main/java/org/apache/avro/idl/Schemas.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ public static <T> T visit(final Schema start, final SchemaVisitor<T> visitor) {
switch (action) {
case CONTINUE:
break;
case SKIP_SUBTREE:
throw new UnsupportedOperationException();
case SKIP_SIBLINGS:
while (dq.peek() instanceof Schema) {
dq.remove();
}
break;
case TERMINATE:
return visitor.get();
case SKIP_SUBTREE:
default:
throw new UnsupportedOperationException("Invalid action " + action);
}
Expand Down
24 changes: 13 additions & 11 deletions lang/java/idl/src/test/idl/input/forward_ref.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Loading

0 comments on commit 634f1d4

Please sign in to comment.