Commit 3e95123
committed
[Java] Avoid checking parentMessage.actingVersion inside composite.
Most not present conditions were already elided via
`generateFieldNotPresentCondition(inComposite=true, ...)` but the
condition within the wrap method was not.
Here's an example of a failing schema found with the DTO property-based
tests:
```
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<sbe:messageSchema id="42" package="uk.co.real_logic.sbe.properties" version="1" xmlns:sbe="http://fixprotocol.io/2016/sbe">
<types>
<composite name="messageHeader">
<type name="blockLength" primitiveType="uint16"/>
<type name="templateId" primitiveType="uint16"/>
<type name="schemaId" primitiveType="uint16"/>
<type name="version" primitiveType="uint16"/>
</composite>
<composite name="groupSizeEncoding">
<type name="blockLength" primitiveType="uint16"/>
<type name="numInGroup" primitiveType="uint16"/>
</composite>
<composite name="Type1">
<type length="2" name="member0OfType0" presence="required" primitiveType="uint8"/>
</composite>
</types>
<sbe:message id="1" name="TestMessage">
<field id="0" name="member0" presence="optional" sinceVersion="1" type="Type1"/>
</sbe:message>
</sbe:messageSchema>
```
And generated code (within a composite without a `parentMessage`):
```
public void wrapMember0OfType0(final DirectBuffer wrapBuffer)
{
if (parentMessage.actingVersion < 1)
{
wrapBuffer.wrap(buffer, offset, 0);
return;
}
wrapBuffer.wrap(buffer, offset + 0, 2);
}
```1 parent a8fa1a4 commit 3e95123
File tree
1 file changed
+7
-4
lines changed- sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java
1 file changed
+7
-4
lines changedLines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1665 | 1665 | | |
1666 | 1666 | | |
1667 | 1667 | | |
1668 | | - | |
| 1668 | + | |
1669 | 1669 | | |
1670 | 1670 | | |
1671 | 1671 | | |
| |||
2671 | 2671 | | |
2672 | 2672 | | |
2673 | 2673 | | |
2674 | | - | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
2675 | 2678 | | |
2676 | | - | |
| 2679 | + | |
2677 | 2680 | | |
2678 | 2681 | | |
2679 | 2682 | | |
| |||
2925 | 2928 | | |
2926 | 2929 | | |
2927 | 2930 | | |
2928 | | - | |
| 2931 | + | |
2929 | 2932 | | |
2930 | 2933 | | |
2931 | 2934 | | |
| |||
0 commit comments