-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
Description
Hello,
Just was experimenting with the IonHashWriter and encountered an error when writing an IonStruct DOM object.
IonSystem ion = IonSystemBuilder.standard().build();
IonHasherProvider hasherProvider = new MessageDigestIonHasherProvider("SHA-256");
// write a simple Ion struct and compute the hash
ByteArrayOutputStream baos = new ByteArrayOutputStream();
IonWriter writer = ion.newTextWriter(baos);
IonHashWriter hashWriter = IonHashWriterBuilder.standard()
.withHasherProvider(hasherProvider)
.withWriter(writer)
.build();
IonValue ionValue = ion.singleValue("{first_name:\"Amanda\",middle_name:\"Amanda\",last_name:\"Smith\"}");
System.out.println("writer");
ionValue.writeTo(hashWriter);
Stack trace (fails here)
com.amazon.ionhash.IonHashWriterImpl cannot be cast to com.amazon.ion.impl._Private_IonWriter
at com.amazon.ion.impl.lite.IonValueLite.writeTo(IonValueLite.java:993)
at com.amazon.ion.impl.lite.IonValueLite.writeChildren(IonValueLite.java:986)
at com.amazon.ion.impl.lite.IonStructLite.writeBodyTo(IonStructLite.java:809)
at com.amazon.ion.impl.lite.IonValueLite.writeTo(IonValueLite.java:1010)
at com.amazon.ion.impl.lite.IonValueLite.writeTo(IonValueLite.java:965)
at com.amazon.ionhash.IonHashWriterImpl.writeValue(IonHashWriterImpl.java:324)
This seems to only fail on Structs but I haven't tried too many other values. Is the IonHashWriter intended to support writes like this?