Skip to content

Commit

Permalink
TestReflect had a bug. Minor other fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Zeyliger committed Oct 16, 2009
1 parent 97db7d7 commit 11b5d4c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/java/org/apache/avro/Schema.java
Expand Up @@ -702,23 +702,24 @@ public Schema get(Object o) {
static Schema parse(JsonNode schema, Names names) {
if (schema.isTextual()) { // name
Schema result = names.get(schema.getTextValue());
if (result == null)
if (result == null) {
throw new SchemaParseException("Undefined name: "+schema);
}
return result;
} else if (schema.isObject()) {
String type = getTextRequired(schema, "type", "No type");
String name = null, space = null, doc = null;
if (type.equals("record") || type.equals("error")
|| type.equals("enum") || type.equals("fixed")) {
String key = "name";
name = getTextRequired(schema, "name", "No name in schema");
doc = getTextOptional(schema, "doc");
space = getTextOptional(schema, "namespace");
if (space == null) {
space = names.space();
}
if (names.space() == null && space != null)
if (names.space() == null && space != null) {
names.space(space); // set default namespace
}
}
if (type.equals("record") || type.equals("error")) { // record
LinkedHashMap<String,Field> fields = new LinkedHashMap<String,Field>();
Expand Down Expand Up @@ -822,5 +823,4 @@ static JsonNode parseJson(String s) {
throw new RuntimeException(e);
}
}

}
10 changes: 5 additions & 5 deletions src/java/org/apache/avro/specific/SpecificCompiler.java
Expand Up @@ -61,9 +61,7 @@ static class OutputFile {
/** Writes output to path destination. */
void writeToDestination(File dest) throws IOException {
File f = new File(dest, path);
if (!f.getParentFile().mkdirs()) {
throw new IOException("Could not create directory: " + f.toString());
}
f.getParentFile().mkdirs();
FileWriter fw = new FileWriter(f);
try {
fw.write(contents);
Expand Down Expand Up @@ -138,6 +136,7 @@ private OutputFile compileInterface(Protocol protocol) {
OutputFile outputFile = new OutputFile();
outputFile.path = makePath(protocol.getName(), protocol.getNamespace());
StringBuilder out = new StringBuilder();
header(out, protocol.getNamespace());
line(out, 0, "public interface "+protocol.getName()+" {");

out.append("\n");
Expand Down Expand Up @@ -302,10 +301,11 @@ private void doc(StringBuilder out, int indent, String doc) {
}

/**
* TODO(philip) XXX figure out proper escaping
* Be sure that generated code will compile by replacing
* end-comment markers with the appropriate HTML entity.
*/
private String escapeForJavaDoc(String doc) {
return doc;
return doc.replace("*/", "*&#47;");
}

private static final Schema NULL_SCHEMA = Schema.create(Schema.Type.NULL);
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/org/apache/avro/TestReflect.java
Expand Up @@ -134,15 +134,16 @@ public int hashCode() {
}

public boolean equals(Object other) {
boolean equals = false;
if (other instanceof AnotherSampleRecord) {
AnotherSampleRecord o = (AnotherSampleRecord) other;
boolean equals = this.a == o.a;
equals = this.a == o.a;
if (this.s == null && o.s != null)
equals = false;
if (this.s != null && this.s.equals(o.s))
equals = true;
}
return true;
return equals;
}
}
}
Expand Down

0 comments on commit 11b5d4c

Please sign in to comment.