summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsunzhaochang <zhchsun1992@gmail.com>2021-08-13 20:55:08 +0800
committerColin Marc <hi@colinmarc.com>2022-02-05 14:02:28 +0100
commit19e9639f12c882075cc2665cde964b11cf54f350 (patch)
treee6896291f6a91a9ba9469ba3b032915deda39ea4
parent154bbe76f0463b6b4e6587659af6f954680456a7 (diff)
Check that closing a file after writing actually succeeds
Hadoop returns a boolean with no context. Fixes #271.
-rw-r--r--file_writer.go3
-rw-r--r--hadoopconf/hadoopconf.go2
-rw-r--r--internal/transfer/block_write_stream.go2
3 files changed, 5 insertions, 2 deletions
diff --git a/file_writer.go b/file_writer.go
index 6b609f4..a773732 100644
--- a/file_writer.go
+++ b/file_writer.go
@@ -1,6 +1,7 @@
package hdfs
import (
+ "errors"
"io"
"os"
"time"
@@ -239,6 +240,8 @@ func (f *FileWriter) Close() error {
err := f.client.namenode.Execute("complete", completeReq, completeResp)
if err != nil {
return &os.PathError{"create", f.name, err}
+ } else if !completeResp.GetResult() {
+ return &os.PathError{"create", f.name, errors.New("failed to close file")}
}
return nil
diff --git a/hadoopconf/hadoopconf.go b/hadoopconf/hadoopconf.go
index f9a6fc2..9bc6db1 100644
--- a/hadoopconf/hadoopconf.go
+++ b/hadoopconf/hadoopconf.go
@@ -123,7 +123,7 @@ func (conf HadoopConf) Namenodes() []string {
}
keys := make([]string, 0, len(nns))
- for k, _ := range nns {
+ for k := range nns {
keys = append(keys, k)
}
diff --git a/internal/transfer/block_write_stream.go b/internal/transfer/block_write_stream.go
index 0f47cb0..752caeb 100644
--- a/internal/transfer/block_write_stream.go
+++ b/internal/transfer/block_write_stream.go
@@ -290,7 +290,7 @@ Acks:
// Once we've seen an error, just keep reading packets off the channel (but
// not off the socket) until the writing thread figures it out. If we don't,
// the upstream thread could deadlock waiting for the channel to have space.
- for _ = range s.packets {
+ for range s.packets {
}
}