Skip to content

Commit c0accf3

Browse files
author
Ben Osheroff
committed
move ObjectInputStream initialization to call-site
1 parent 354bbec commit c0accf3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main/java/com/zendesk/maxwell/util/ListWithDiskBuffer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ public void add(T element) throws IOException {
3939

4040
os.writeUnshared(this.list.removeFirst());
4141

42-
if ( is == null && os != null ) {
43-
os.flush();
44-
is = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
45-
}
46-
4742
elementsInFile++;
4843
}
4944
}
@@ -57,7 +52,12 @@ public T getLast() {
5752
}
5853

5954
public T removeFirst() throws IOException, ClassNotFoundException {
60-
if ( elementsInFile > 0 && is != null ) {
55+
if ( elementsInFile > 0 ) {
56+
if ( is == null ) {
57+
os.flush();
58+
is = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
59+
}
60+
6161
T element = (T) is.readUnshared();
6262
elementsInFile--;
6363
return element;

0 commit comments

Comments
 (0)