THRIFT-489. java: Java enum validation only validates explicitly assigned values
This patch puts all of an enum's values into the valid values set, fixing validation.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@780091 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index 3ec816f..419053d 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -360,13 +360,12 @@
bool first = true;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
// populate set
- if ((*c_iter)->has_value()) {
- f_enum << (first ? "" : ", ") << (*c_iter)->get_name();
- first = false;
- }
+ f_enum << (first ? "" : ", ") << endl;
+ first = false;
+ indent(f_enum) << (*c_iter)->get_name();
}
+ f_enum << " );" << endl << endl;
indent_down();
- f_enum << ");" << endl;
indent(f_enum) << "public static final Map<Integer, String> VALUES_TO_NAMES = new HashMap<Integer, String>() {{" << endl;