Skip to content

Commit 244e7ca

Browse files
committed
bugfix: finally store seems to work
1 parent b9cb984 commit 244e7ca

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/core/org/apache/hadoop/fs/swift/SwiftFileSystem.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,15 @@ private class SwiftFsOutputStream extends OutputStream {
131131
private PipedInputStream fromPipe;
132132
private SwiftProgress callback;
133133
private long pos = 0;
134+
private Thread thread;
134135

135136
public SwiftFsOutputStream(final ISwiftFilesClient client, final String container,
136137
final String objName, int bufferSize, Progressable progress) throws IOException {
137138
this.toPipe = new PipedOutputStream();
138139
this.fromPipe = new PipedInputStream(toPipe, bufferSize);
139140
this.callback = new SwiftProgress(progress);
140141

141-
new Thread() {
142+
this.thread = new Thread() {
142143
public void run(){
143144
try {
144145
client.storeStreamedObject(container, fromPipe, "binary/octet-stream", objName, new HashMap<String, String>());
@@ -147,17 +148,20 @@ public void run(){
147148
e.printStackTrace();
148149
}
149150
}
150-
}.start();
151-
151+
};
152+
thread.start();
152153
}
153154

154155
@Override
155156
public synchronized void close() {
156157
try {
157158
toPipe.flush();
158159
toPipe.close();
160+
thread.join();
159161
} catch (IOException e) {
160162
e.printStackTrace();
163+
} catch (InterruptedException e) {
164+
e.printStackTrace();
161165
}
162166
}
163167

0 commit comments

Comments
 (0)