Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write string array failed #656

Closed
tianxie opened this issue Dec 11, 2024 · 4 comments
Closed

Write string array failed #656

tianxie opened this issue Dec 11, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@tianxie
Copy link

tianxie commented Dec 11, 2024

Describe the bug

Write string array failed if it contains non-ASCII characters.

To Reproduce

        try (WritableHdfFile hdfFile = HdfFile.write(Paths.get("jhdf.hdf5"))) {
            WritableGroup group = hdfFile.putGroup("group");
            group.putDataset("strings1", new String[]{"hello"});  // success
            group.putDataset("strings2", new String[]{"你好"}); // failed
            String[][] strings = {{"你好"}, {"世界"}};
            group.putDataset("strings3", strings); // failed
        }

Please complete the following information:

  • jhdf version: 0.8.4
  • Java version: OpenJDK 64-Bit Server VM Temurin-17.0.9+9
  • OS (Windows, Mac, Linux): Windows
  • Stack trace if available
  • jhdf logging if available
Exception in thread "main" java.nio.BufferOverflowException
	at java.base/java.nio.ByteBuffer.put(ByteBuffer.java:1007)
	at java.base/java.nio.HeapByteBuffer.put(HeapByteBuffer.java:243)
	at io.jhdf.object.datatype.StringData.writeArrayData(StringData.java:216)
	at io.jhdf.object.datatype.StringData.writeArrayData(StringData.java:210)
	at io.jhdf.object.datatype.StringData.writeData(StringData.java:194)
	at io.jhdf.WritableDatasetImpl.writeData(WritableDatasetImpl.java:243)
	at io.jhdf.WritableDatasetImpl.write(WritableDatasetImpl.java:225)
	at io.jhdf.WritableGroupImpl.write(WritableGroupImpl.java:181)
	at io.jhdf.WritableGroupImpl.write(WritableGroupImpl.java:181)
	at io.jhdf.WritableHdfFile.flush(WritableHdfFile.java:78)
	at io.jhdf.WritableHdfFile.close(WritableHdfFile.java:68)
	at com.example.Test.main(Test.java:18)
@jamesmudd
Copy link
Owner

Thanks for opening this issue, I will take a look ASAP.

@jamesmudd jamesmudd added the bug Something isn't working label Dec 11, 2024
@jamesmudd
Copy link
Owner

I have merged the fix for this will publish a release soon.

@jamesmudd
Copy link
Owner

Released in v0.8.5

@tianxie
Copy link
Author

tianxie commented Dec 21, 2024

Thank you so much for your quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants