Skip to content

Commit d756d41

Browse files
committed
#715 checking for PVAStructureArray before PVAArray
1 parent ac00105 commit d756d41

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

core/pv/src/main/java/org/phoebus/pv/pva/PVAStructureHelper.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,28 @@ public static VType getVType(final PVAStructure struct, final PVNameHelper name_
6969
actual = (PVAStructure) field;
7070
else if (field instanceof PVANumber)
7171
return Decoders.decodeNumber(struct, (PVANumber) field);
72-
else if (field instanceof PVAArray)
73-
return Decoders.decodeArray(struct, (PVAArray) field);
74-
else if (field instanceof PVAString)
75-
return Decoders.decodeString(struct, (PVAString) field);
76-
}
77-
78-
// Handle element references in arrays
79-
if (elementIndex.isPresent())
80-
{
81-
final PVAData field = struct.get(name_helper.getField());
82-
if (field instanceof PVAStructureArray)
72+
else if (field instanceof PVAStructureArray)
8373
{
84-
actual = ((PVAStructureArray) field).get()[elementIndex.get()];
74+
if (elementIndex.isPresent())
75+
{
76+
actual = ((PVAStructureArray) field).get()[elementIndex.get()];
77+
}
8578
}
86-
else if(field instanceof PVAArray)
87-
{
88-
return decodeNTArray(actual, elementIndex.get());
89-
}
90-
else
79+
else if (field instanceof PVAArray)
9180
{
92-
throw new Exception("Expected struct array for field " + name_helper.getField() + ", got " + struct);
81+
if (elementIndex.isPresent())
82+
{
83+
return decodeNTArray(struct, elementIndex.get());
84+
}
85+
else
86+
{
87+
return Decoders.decodeArray(struct, (PVAArray) field);
88+
}
9389
}
90+
else if (field instanceof PVAString)
91+
return Decoders.decodeString(struct, (PVAString) field);
9492
}
93+
9594
// Handle normative types
9695
String type = actual.getStructureName();
9796
if (type.startsWith("epics:nt/"))

0 commit comments

Comments
 (0)