This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 23333e6 Fix a NullPointerException when a netCDF file contains no
global attribute.
23333e6 is described below
commit 23333e6ed31aeda18ac3d939bc8e81ee8b7d6c36
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Thu Mar 21 16:29:43 2019 +0100
Fix a NullPointerException when a netCDF file contains no global attribute.
---
.../org/apache/sis/internal/netcdf/impl/ChannelDecoder.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
index e5b6abf..e9fa786 100644
---
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
+++
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
@@ -255,7 +255,7 @@ public final class ChannelDecoder extends Decoder {
*/
DimensionInfo[] dimensions = null;
VariableInfo[] variables = null;
- Map<String,Object> attributes = null;
+ Map<String,Object> attributes = Collections.emptyMap();
for (int i=0; i<3; i++) {
final long tn = input.readLong(); // Combination
of tag and nelems
if (tn != 0) {
@@ -275,8 +275,13 @@ public final class ChannelDecoder extends Decoder {
}
}
this.attributeMap = attributes;
- this.variables = variables;
- this.variableMap = toCaseInsensitiveNameMap(variables);
+ if (variables != null) {
+ this.variables = variables;
+ this.variableMap = toCaseInsensitiveNameMap(variables);
+ } else {
+ this.variables = new VariableInfo[0];
+ this.variableMap = Collections.emptyMap();
+ }
initialize();
}