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

hold back flush till stream close (#51) #456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class PageBlobOutputStream extends FilterOutputStream {
private long currentPageSize = PAGE_BLOB_PAGE_SIZE;

private volatile IOException lastError;
private boolean closed = false;

/**
* Creates an output stream filter built on top of the Azure
Expand Down Expand Up @@ -63,22 +64,34 @@ public void write(int b) throws IOException {
internalWrite(b);
}

@Override
public void flush() throws IOException {
// cannot flush untill close
}

@Override
public void close() throws IOException {

this.checkStreamState();
if(closed)
return;

// top off page size
// flush write does NOT occur unless full page is written
if (count < currentPageSize) {
byte[] pad = new byte[(int) (currentPageSize - count)];
writePad(pad);
}
super.close();

try {
super.flush();
super.close();
} finally {
closed = true;
}
uploadMetadata();
}


private void writePad(byte[] pad) throws IOException {
out.write(pad);
}
Expand Down