dmatej commented on code in PR #181:
URL:
https://github.com/apache/santuario-xml-security-java/pull/181#discussion_r1238510485
##########
src/main/java/org/apache/jcp/xml/dsig/internal/dom/DOMSignedInfo.java:
##########
@@ -100,17 +100,13 @@ public DOMSignedInfo(CanonicalizationMethod cm,
SignatureMethod sm,
}
this.canonicalizationMethod = cm;
this.signatureMethod = sm;
- this.references = Collections.unmodifiableList(
- new ArrayList<>(references));
+ this.references = Collections.unmodifiableList(new
ArrayList<>(references));
if (this.references.isEmpty()) {
- throw new IllegalArgumentException("list of references must " +
- "contain at least one entry");
+ throw new IllegalArgumentException("list of references must
contain at least one entry");
}
- for (int i = 0, size = this.references.size(); i < size; i++) {
- Object obj = this.references.get(i);
- if (!(obj instanceof Reference)) {
- throw new ClassCastException("list of references contains " +
- "an illegal type");
+ for (Object obj : this.references) {
+ if (!Reference.class.isInstance(obj)) {
Review Comment:
This is a bit complicated, first I removed the for loop as it should not be
possible to have an incompatible element IF user would keep rules (generics).
But there is an unit test which proves that it is possible to pass incompatible
type. Maybe it should be refactored later - at least I will comply with rules
and bring back the `instanceof`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]