]> source.dussan.org Git - poi.git/commitdiff
Sonar fixes - array is stored directly
authorAndreas Beeker <kiwiwings@apache.org>
Mon, 16 May 2016 09:57:19 +0000 (09:57 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Mon, 16 May 2016 09:57:19 +0000 (09:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1744003 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/formula/CollaboratingWorkbooksEnvironment.java
src/java/org/apache/poi/ss/formula/Formula.java
src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java
src/java/org/apache/poi/ss/formula/ParseNode.java

index f2d936f3d96b1a3f06e89b77c03a13e445406740..58ce3d929f04da14b7a11a424bc38e2e43862ecf 100644 (file)
@@ -117,7 +117,7 @@ public final class CollaboratingWorkbooksEnvironment {
         unhookOldEnvironments(evaluators);
         hookNewEnvironment(evaluators, this);
         _unhooked = false;
-        _evaluators = evaluators;
+        _evaluators = evaluators.clone();
         _evaluatorsByName = evaluatorsByName;
     }
 
index 48c7f391beaa99b1ce55494bc84c14b0361cabbb..9f4f25e90d9f9d8d14c2b95fca8dfac34fa379b0 100644 (file)
@@ -42,7 +42,7 @@ public class Formula {
        private final int _encodedTokenLen;
 
        private Formula(byte[] byteEncoding, int encodedTokenLen) {
-               _byteEncoding = byteEncoding;
+               _byteEncoding = byteEncoding.clone();
                _encodedTokenLen = encodedTokenLen;
 //             if (false) { // set to true to eagerly check Ptg decoding
 //                     LittleEndianByteArrayInputStream in = new LittleEndianByteArrayInputStream(byteEncoding);
index 2d399494ab92055a8f14dbcb6d0fe19840a3aa70..0561956181a9000625e6714dea51d3424baa48a6 100644 (file)
@@ -27,8 +27,6 @@ import org.apache.poi.ss.formula.FormulaUsedBlankCellSet.BookSheetKey;
 
 /**
  * Stores the cached result of a formula evaluation, along with the set of sensitive input cells
- * 
- * @author Josh Micich
  */
 final class FormulaCellCacheEntry extends CellCacheEntry {
        
@@ -57,8 +55,13 @@ final class FormulaCellCacheEntry extends CellCacheEntry {
        public void setSensitiveInputCells(CellCacheEntry[] sensitiveInputCells) {
                // need to tell all cells that were previously used, but no longer are, 
                // that they are not consumed by this cell any more
-               changeConsumingCells(sensitiveInputCells == null ? CellCacheEntry.EMPTY_ARRAY : sensitiveInputCells);
-               _sensitiveInputCells = sensitiveInputCells;
+           if (sensitiveInputCells == null) {
+            _sensitiveInputCells = null;
+               changeConsumingCells(CellCacheEntry.EMPTY_ARRAY);
+           } else {
+               _sensitiveInputCells = sensitiveInputCells.clone();
+               changeConsumingCells(_sensitiveInputCells);
+           }
        }
 
        public void clearFormulaEntry() {
index a671ede597cb080cfdd6b105b088424cda47b581..a41ec26346f60e17df636d6c9a19ca8e839a14ff 100644 (file)
@@ -28,8 +28,6 @@ import org.apache.poi.ss.formula.function.FunctionMetadataRegistry;
  * Represents a syntactic element from a formula by encapsulating the corresponding <tt>Ptg</tt>
  * token.  Each <tt>ParseNode</tt> may have child <tt>ParseNode</tt>s in the case when the wrapped
  * <tt>Ptg</tt> is non-atomic.
- *
- * @author Josh Micich
  */
 final class ParseNode {
 
@@ -44,7 +42,7 @@ final class ParseNode {
                        throw new IllegalArgumentException("token must not be null");
                }
                _token = token;
-               _children = children;
+               _children = children.clone();
                _isIf = isIf(token);
                int tokenCount = 1;
                for (int i = 0; i < children.length; i++) {