OpenJDK / jdk / hs
changeset 42710:7ae63c40a6ec
8153208: TIFFImageReadParam: should "contains()" check be appropriate for addAllowedTagSet() method?
Summary: Do not add a duplicate TIFFTagSet instance and update the spec accordingly.
Reviewed-by: prr
author | bpb |
---|---|
date | Tue, 15 Nov 2016 08:58:29 -0800 |
parents | 53ac12e1344a |
children | 1a4a75c37134 |
files | jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java Tue Nov 15 12:52:24 2016 +0530 +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFImageReadParam.java Tue Nov 15 08:58:29 2016 -0800 @@ -50,7 +50,8 @@ */ public final class TIFFImageReadParam extends ImageReadParam { - private List<TIFFTagSet> allowedTagSets = new ArrayList<TIFFTagSet>(4); + private final List<TIFFTagSet> allowedTagSets = + new ArrayList<TIFFTagSet>(4); /** * Constructs a {@code TIFFImageReadParam}. Tags defined by @@ -72,7 +73,8 @@ /** * Adds a {@code TIFFTagSet} object to the list of allowed - * tag sets. + * tag sets. Attempting to add a duplicate object to the list + * has no effect. * * @param tagSet a {@code TIFFTagSet}. * @@ -83,7 +85,9 @@ if (tagSet == null) { throw new IllegalArgumentException("tagSet == null!"); } - allowedTagSets.add(tagSet); + if (!allowedTagSets.contains(tagSet)) { + allowedTagSets.add(tagSet); + } } /**