You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/06/01 12:55:02 UTC
[commons-imaging] branch master updated: Bullet-proof SimplePalette
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git
The following commit(s) were added to refs/heads/master by this push:
new 4a9dcf25 Bullet-proof SimplePalette
4a9dcf25 is described below
commit 4a9dcf25515b3185330cd2128df2fe365f1cc5c3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jun 1 08:54:58 2023 -0400
Bullet-proof SimplePalette
---
.../org/apache/commons/imaging/palette/SimplePalette.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/palette/SimplePalette.java b/src/main/java/org/apache/commons/imaging/palette/SimplePalette.java
index 1ccd35e2..9ba335ef 100644
--- a/src/main/java/org/apache/commons/imaging/palette/SimplePalette.java
+++ b/src/main/java/org/apache/commons/imaging/palette/SimplePalette.java
@@ -16,11 +16,19 @@
*/
package org.apache.commons.imaging.palette;
+import java.util.Objects;
+
public class SimplePalette implements Palette {
+
private final int[] palette;
+ /**
+ * Constructs a new instance.
+ *
+ * @param palette palette to copy and store.
+ */
public SimplePalette(final int[] palette) {
- this.palette = palette;
+ this.palette = Objects.requireNonNull(palette, "palette").clone();
}
@Override
@@ -35,7 +43,6 @@ public class SimplePalette implements Palette {
return i;
}
}
-
return -1;
}