eclipse-ee4j / jaxb-fi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should the Decoding of the Attribute Name Surrogate within the initial vocabulary be more robust?

Tomas-Kraus opened this issue · comments

We've been using a Fast Infoset document that contains a large initial vocabulary that was created by another tool and we're trying to parse it with the Java FI library. One interesting issue we've hit is that apparently the other tool encoded a final entry in the attribute-name surrogate table of the initial vocabulary where the prefix-string-index bit was present, and the index encoded referred to a null value in the prefixes table. The same thing happens for the namespace-name-prefix and the namespaceName table. This results in an exception in the call to the QualifiedName constructor inside of decodeTableItems(QualifiedNameArray array, boolean isAttribute) in the Decoder class. The exception(s) are the result of the prefix string and namespaceName strings being assigned a null value, which then causes a later exception in the QualifiedName constructor since the QualifiedName constructor assumes that various input variables are not null.

Since we've parsed this other file with a handful of over FI tools, we were thinking one approach might be to just add some additional robustness checking to decodeTableItems() to ensure that the prefix variable is set back to an empty string if the lookup in the prefix table returns null. The same could be done with the namespaceName attribute and the lookup in the namespaceName table. Alternatively, the constructor to QualifiedName could have more sanity checks and not assume that various parameters are not null.

@glassfishrobot Commented
Reported by khiggins

@glassfishrobot Commented
khiggins said:
Here's one fix that could be done to the decodeTableItems(QualifiedNameArray array, boolean isAttribute) function. Like I said above, probably the better way to tackle this is to just improve the QualifiedName constructor.

String prefix = "";
int prefixIndex = -1;
if ((b & EncodingConstants.NAME_SURROGATE_PREFIX_FLAG) > 0) {
prefixIndex = decodeIntegerIndexOnSecondBit();
prefix = _v.prefix.get(prefixIndex);
if (prefix == null)

{ prefix = ""; }

}

@glassfishrobot Commented
khiggins said:
Same thing, but for the namespaceName variable within decodeTableItems(QualifiedNameArray array, boolean isAttribute):

String namespaceName = "";
int namespaceNameIndex = -1;
if ((b & EncodingConstants.NAME_SURROGATE_NAME_FLAG) > 0) {
namespaceNameIndex = decodeIntegerIndexOnSecondBit();
namespaceName = _v.namespaceName.get(namespaceNameIndex);
if (namespaceName == null)

{ namespaceName = ""; }

}

@glassfishrobot Commented
khiggins said:
Actually, upon further look, it looks like the fix from #31 actually resolves this issue, and the values appear to make sense for our application. Can the fix from #31 be applied? Or have there been concerns about it?

@glassfishrobot Commented
This issue was imported from java.net JIRA FI-50