Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.avro.util.Schemas;

import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -253,7 +252,7 @@ public void commit() {
}

public SchemaParser.ParseResult commit(Schema mainSchema) {
Collection<Schema> parsedNamedSchemas = newSchemas.values();
List<Schema> parsedNamedSchemas = new ArrayList<>(newSchemas.values());
SchemaParser.ParseResult parseResult = new SchemaParser.ParseResult() {
@Override
public Schema mainSchema() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -35,7 +36,7 @@

class TestSchemaParser {
private static final Schema SCHEMA_REAL = Schema.createFixed("Real", null, "tests", 42);
private static final String SCHEMA_JSON = SCHEMA_REAL.toString(false);
private static final String SCHEMA_JSON = SchemaFormatter.getInstance("json").format(SCHEMA_REAL);
private static final Charset[] UTF_CHARSETS = { StandardCharsets.UTF_8, StandardCharsets.UTF_16LE,
StandardCharsets.UTF_16BE };

Expand Down Expand Up @@ -88,7 +89,11 @@ void testParseTextWithFallbackJsonParser() {

@Test
void testParseByCustomParser() {
Schema schema = new SchemaParser().parse(DummySchemaParser.SCHEMA_TEXT_ONE).mainSchema();
SchemaParser.ParseResult parseResult = new SchemaParser().parse(DummySchemaParser.SCHEMA_TEXT_ONE);
List<Schema> namedSchemas = parseResult.parsedNamedSchemas();
assertEquals(1, namedSchemas.size());
assertEquals(DummySchemaParser.FIXED_SCHEMA, namedSchemas.get(0));
Schema schema = parseResult.mainSchema();
assertEquals(DummySchemaParser.FIXED_SCHEMA, schema);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void setUp() {

static void assertCompilesWithJavaCompiler(File dstDir, Collection<SpecificCompiler.OutputFile> outputs)
throws IOException {
assertCompilesWithJavaCompiler(dstDir, outputs, false);
assertCompilesWithJavaCompiler(dstDir, outputs, true);
}

/**
Expand Down
12 changes: 4 additions & 8 deletions lang/java/idl/src/main/java/org/apache/avro/idl/IdlReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@ private Schema namedSchemaOrUnresolved(String fullName) {
return parseContext.find(fullName, null);
}

private void addSchema(Schema schema) {
parseContext.put(schema);
}

public IdlFile parse(Path location) throws IOException {
return parse(location.toUri());
}
Expand Down Expand Up @@ -437,7 +433,7 @@ public void exitImportStatement(ImportStatementContext importContext) {
try (InputStream stream = importLocation.toURL().openStream()) {
Protocol importProtocol = Protocol.parse(stream);
for (Schema s : importProtocol.getTypes()) {
addSchema(s);
parseContext.put(s);
}
if (protocol != null) {
protocol.getMessages().putAll(importProtocol.getMessages());
Expand Down Expand Up @@ -515,7 +511,7 @@ public void exitFixedDeclaration(FixedDeclarationContext ctx) {
Schema schema = Schema.createFixed(name, doc, space, size);
properties.copyAliases(schema::addAlias);
properties.copyProperties(schema);
addSchema(schema);
parseContext.put(schema);
}

@Override
Expand All @@ -539,7 +535,7 @@ public void exitEnumDeclaration(EnumDeclarationContext ctx) {
enumSymbols.clear();
enumDefaultSymbol = null;

addSchema(schema);
parseContext.put(schema);
}

@Override
Expand Down Expand Up @@ -590,7 +586,7 @@ public void enterRecordBody(RecordBodyContext ctx) {
public void exitRecordDeclaration(RecordDeclarationContext ctx) {
schema.setFields(fields);
fields.clear();
addSchema(schema);
parseContext.put(schema);
schema = null;

popNamespace();
Expand Down
2 changes: 2 additions & 0 deletions lang/java/mapred/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<parallel>none</parallel>
<!-- Required for recent JDKs (fixes "UnsupportedOperationException: getSubject is supported only if a security manager is allowed") -->
<argLine>-Djava.security.manager=allow</argLine>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 2 additions & 0 deletions lang/java/tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<parallel>none</parallel>
<!-- Required for recent JDKs (fixes "UnsupportedOperationException: getSubject is supported only if a security manager is allowed") -->
<argLine>-Djava.security.manager=allow</argLine>
</configuration>
</plugin>
<!-- Allow guava because hadoop brings it as a transitive dependency. -->
Expand Down
2 changes: 2 additions & 0 deletions lang/java/trevni/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<parallel>none</parallel>
<!-- Required for recent JDKs (fixes "UnsupportedOperationException: getSubject is supported only if a security manager is allowed") -->
<argLine>-Djava.security.manager=allow</argLine>
</configuration>
</plugin>
</plugins>
Expand Down