sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1810579 - in /sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl: ChannelDecoder.java VariableInfo.java
Date Mon, 02 Oct 2017 19:10:03 GMT
Author: desruisseaux
Date: Mon Oct  2 19:10:03 2017
New Revision: 1810579

URL: http://svn.apache.org/viewvc?rev=1810579&view=rev
Log:
Fix a NullPointerException when a netCDF variable has no attribute.

Modified:
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java?rev=1810579&r1=1810578&r2=1810579&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
[UTF-8] Mon Oct  2 19:10:03 2017
@@ -555,7 +555,7 @@ public final class ChannelDecoder extend
              * Following block is almost a copy-and-paste of similar block in the contructor,
              * but with less cases in the "switch" statements.
              */
-            Map<String,Object> attributes = null;
+            Map<String,Object> attributes = Collections.emptyMap();
             final long tn = input.readLong();
             if (tn != 0) {
                 final int tag = (int) (tn >>> Integer.SIZE);

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java?rev=1810579&r1=1810578&r2=1810579&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
[UTF-8] Mon Oct  2 19:10:03 2017
@@ -196,12 +196,16 @@ final class VariableInfo extends Variabl
          * Verify if this variable is an enumeration. If yes, we remove the attributes that
define the
          * enumeration since those attributes may be verbose and "pollute" the variable definition.
          */
-        String[] meanings = stringValues(attributes.remove(AttributeNames.FLAG_MEANINGS));
-        switch (meanings.length) {
-            case 0: meanings = null; break;
-            case 1: meanings = (String[]) CharSequences.split(meanings[0], ' '); break;
+        if (!attributes.isEmpty()) {    // For avoiding UnsupportedOperationException if
unmodifiable map.
+            String[] meanings = stringValues(attributes.remove(AttributeNames.FLAG_MEANINGS));
+            switch (meanings.length) {
+                case 0: meanings = null; break;
+                case 1: meanings = (String[]) CharSequences.split(meanings[0], ' '); break;
+            }
+            this.meanings = meanings;
+        } else {
+            meanings = null;
         }
-        this.meanings = meanings;
     }
 
     /**



Mime
View raw message