Skip to content

Commit 6dc1d70

Browse files
committed
SBE Java Generator Bug: when having a group that starts with a lower case letter and that group contains a fix length array, the corresponding put%s() method has the wrong return type (it uses the name of the group instead of using the name of the class)
1 parent f4ff487 commit 6dc1d70

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,14 @@ private int generateGroups(
170170
{
171171
final Token groupToken = tokens.get(index);
172172
final String groupName = groupToken.name();
173+
final String groupClassName = formatClassName(groupName);
173174
sb.append(generateGroupProperty(groupName, groupToken, indent));
174175

175176
generateGroupClassHeader(sb, groupName, parentMessageClassName, tokens, index, indent + INDENT);
176177

177178
final List<Token> rootFields = new ArrayList<>();
178179
index = collectRootFields(tokens, ++index, rootFields);
179-
sb.append(generateFields(groupName, rootFields, indent + INDENT));
180+
sb.append(generateFields(groupClassName, rootFields, indent + INDENT));
180181

181182
if (tokens.get(index).signal() == Signal.BEGIN_GROUP)
182183
{

test/resources/code-generation-schema.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<type name="length" primitiveType="uint8"/>
2020
<type name="varData" primitiveType="uint8" length="0" characterEncoding="UTF-8"/>
2121
</composite>
22+
<type name="string20" primitiveType="char" length="20"/>
2223
</types>
2324
<types>
2425
<type name="CharConstType" presence="constant" primitiveType="char">g</type>
@@ -61,12 +62,13 @@
6162
</group>
6263
<group name="performanceFigures" id="11" dimensionType="groupSizeEncoding">
6364
<field name="octaneRating" id="12" type="uint8"/>
64-
<group name="acceleration" id="13" dimensionType="groupSizeEncoding">
65-
<field name="mph" id="14" type="uint16"/>
66-
<field name="seconds" id="15" type="float"/>
65+
<field name="observations" id="13" type="string20"/>
66+
<group name="acceleration" id="14" dimensionType="groupSizeEncoding">
67+
<field name="mph" id="15" type="uint16"/>
68+
<field name="seconds" id="16" type="float"/>
6769
</group>
6870
</group>
69-
<data name="make" id="16" type="varDataEncoding"/>
70-
<data name="model" id="17" type="varDataEncoding"/>
71+
<data name="make" id="17" type="varDataEncoding"/>
72+
<data name="model" id="18" type="varDataEncoding"/>
7173
</message>
7274
</messageSchema>

0 commit comments

Comments
 (0)