Unidata / thredds

THREDDS Data Server v4.6
https://www.unidata.ucar.edu/software/tds/v4.6/index.html
265 stars 179 forks source link

Array.factory(Object) cannot handle String[] #600

Open cwardgar opened 8 years ago

cwardgar commented 8 years ago

From the mailing list. Executing:

String tsar[] = new String[]{"one", "two", "three"};
Array.factory(tsar);

results in:

Exception in thread "main" java.lang.NullPointerException
    at ucar.ma2.Array.reflectArrayCopyIn(Array.java:259)
    at ucar.ma2.Array.reflectArrayCopyIn(Array.java:263)
    at ucar.ma2.Array.factory(Array.java:252)
    at Foo.main(Foo.java:10)

I think we can add some special-case handling for String[] in Array.reflectArrayCopyIn() to fix this.

JohnLCaron commented 8 years ago

Extensively refactored in 5.0 esp for unsigned types, now:

static public Array makeFromJavaArray(Object javaArray);

but not sure if it works there.

But this should work:

Array.factory(DataType.STRING , shape, stringArray);