Skip to content

Commit

Permalink
Fix serialization bug with writing boolean values--missing break in c…
Browse files Browse the repository at this point in the history
…ase statement.
  • Loading branch information
jkreps committed Jan 6, 2009
1 parent f177152 commit 46a5b4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<classpathentry kind="src" path="example/java"/> <classpathentry kind="src" path="example/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/catalina-ant.jar"/> <classpathentry kind="lib" path="lib/catalina-ant.jar"/>
<classpathentry kind="lib" path="lib/colt.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/> <classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-3.1.jar"/> <classpathentry kind="lib" path="lib/commons-collections-3.1.jar"/>
<classpathentry kind="lib" path="lib/commons-dbcp-1.2.2.jar"/> <classpathentry kind="lib" path="lib/commons-dbcp-1.2.2.jar"/>
Expand All @@ -29,5 +28,6 @@
<classpathentry kind="lib" path="lib/slf4j-log4j12-1.4.3.jar"/> <classpathentry kind="lib" path="lib/slf4j-log4j12-1.4.3.jar"/>
<classpathentry kind="lib" path="lib/velocity-1.5.jar"/> <classpathentry kind="lib" path="lib/velocity-1.5.jar"/>
<classpathentry kind="lib" path="lib/xerces.jar"/> <classpathentry kind="lib" path="lib/xerces.jar"/>
<classpathentry kind="lib" path="lib/colt-1.2.0.jar"/>
<classpathentry kind="output" path="classes"/> <classpathentry kind="output" path="classes"/>
</classpath> </classpath>
7 changes: 4 additions & 3 deletions src/java/voldemort/serialization/json/JsonTypeSerializer.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private void write(DataOutputStream output, Object object, Object type) throws I
break; break;
case BOOLEAN: case BOOLEAN:
writeBoolean(output, (Boolean) object); writeBoolean(output, (Boolean) object);
break;
default: default:
throw new SerializationException("Unknown type: " + type); throw new SerializationException("Unknown type: " + type);
} }
Expand Down Expand Up @@ -478,7 +479,7 @@ private void writeMap(DataOutputStream output,
if(object.size() != type.size()) if(object.size() != type.size())
throw new SerializationException("Invalid map for serialization, expected: " + type throw new SerializationException("Invalid map for serialization, expected: " + type
+ " but got " + object); + " but got " + object);
for(Map.Entry<String, Object> entry : type.entrySet()) { for(Map.Entry<String, Object> entry: type.entrySet()) {
if(!object.containsKey(entry.getKey())) if(!object.containsKey(entry.getKey()))
throw new SerializationException("Missing property: " + entry.getKey() + " in " throw new SerializationException("Missing property: " + entry.getKey() + " in "
+ type); + type);
Expand All @@ -491,7 +492,7 @@ private void writeMap(DataOutputStream output,
if(stream.readByte() == -1) if(stream.readByte() == -1)
return null; return null;
Map<String, Object> m = new HashMap<String, Object>(type.size()); Map<String, Object> m = new HashMap<String, Object>(type.size());
for(String property : type.keySet()) for(String property: type.keySet())
m.put(property, read(stream, type.get(property))); m.put(property, read(stream, type.get(property)));
return m; return m;
} }
Expand All @@ -506,7 +507,7 @@ private void writeList(DataOutputStream output, List<Object> objects, List<Objec
output.writeShort(-1); output.writeShort(-1);
} else if(objects.size() < Short.MAX_VALUE) { } else if(objects.size() < Short.MAX_VALUE) {
output.writeShort(objects.size()); output.writeShort(objects.size());
for(Object o : objects) for(Object o: objects)
write(output, o, entryType); write(output, o, entryType);
} else { } else {
throw new SerializationException("List has length " + objects.size() throw new SerializationException("List has length " + objects.size()
Expand Down

0 comments on commit 46a5b4d

Please sign in to comment.