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

StreamHandle: fix subtle bug when seeking more than 1 MB backward #22

Merged
merged 3 commits into from
Nov 1, 2018

Conversation

melissalinkert
Copy link
Member

Originally reported as part of Harmony format support, see glencoesoftware/bioformats#4

f5e4cac updates URLHandleTest to create a failing test exhibiting the problem. 518f31b is a port of glencoesoftware/bioformats@84fa9b6, which should result in the test passing.

To test, check that building and running unit tests with f5e4cac alone results in a single test failure. Building and running unit tests with both commits together should result in all tests passing.

@sbesson
Copy link
Member

sbesson commented Oct 31, 2018

@melissalinkert with the new decision to combine the Harmony reader and the Operetta one, are there some sample datasets this PR should be tested with (i.e. using internal URL rather than filepaths) or is most of the code review at the level of this repository with the additional unit tests?

@sbesson sbesson added this to the 6.0.0 milestone Oct 31, 2018
@melissalinkert
Copy link
Member Author

From the Harmony/Operetta side, this bug was only exposed when using Index.ref.xml files which point to URLs, which we have examples of in curated/perkinelmer-operetta/public/. It's probably not practical to test those directly, so code review and verifying that the unit tests are sufficient should be enough.

@@ -66,6 +69,10 @@ public void setup() throws IOException {
tmpFile.deleteOnExit();
FileOutputStream out = new FileOutputStream(tmpFile);
out.write("hello, world!\n".getBytes(Constants.ENCODING));
byte[] emptyBuffer = new byte[EMPTY_BUFFER_SIZE];
Arrays.fill(emptyBuffer, (byte) 0);
Copy link
Member

@mtbc mtbc Nov 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a no-op: new byte arrays are already zeroed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f78eed7

@dgault
Copy link
Member

dgault commented Nov 1, 2018

Looking at the code and fp is being reset which means https://github.com/ome/ome-common-java/pull/22/files#diff-372db24dc54d341492aa9963f8aa7f33L160 was not behaving as expected. Setting both to pos after the reset is accomplishing the intended result.

Running the new unit test without the code changes results in a failure:
java.io.IOException: Resetting to invalid mark

With the code changes the test runs and completes without error. PR looks good from my perspective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants