diff --git a/pom.xml b/pom.xml
index 7fe2f6af..6160cbdc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.qcloud.cos
hadoop-cos
- 8.1.3
+ 8.1.4
jar
Apache Hadoop Tencent Cloud COS Support
diff --git a/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java b/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java
index 127f40e6..8d4735a0 100644
--- a/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java
+++ b/src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java
@@ -12,7 +12,7 @@
@InterfaceStability.Unstable
public class CosNConfigKeys extends CommonConfigurationKeys {
public static final String USER_AGENT = "fs.cosn.user.agent";
- public static final String DEFAULT_USER_AGENT = "cos-hadoop-plugin-v8.1.3";
+ public static final String DEFAULT_USER_AGENT = "cos-hadoop-plugin-v8.1.4";
public static final String TENCENT_EMR_VERSION_KEY = "fs.emr.version";
diff --git a/src/main/java/org/apache/hadoop/fs/cosn/buffer/CosNByteBuffer.java b/src/main/java/org/apache/hadoop/fs/cosn/buffer/CosNByteBuffer.java
index 917852ea..a9d767c2 100644
--- a/src/main/java/org/apache/hadoop/fs/cosn/buffer/CosNByteBuffer.java
+++ b/src/main/java/org/apache/hadoop/fs/cosn/buffer/CosNByteBuffer.java
@@ -15,16 +15,19 @@ public abstract class CosNByteBuffer implements Closeable {
LoggerFactory.getLogger(CosNByteBuffer.class);
protected ByteBuffer byteBuffer;
- private int lastWritePosition;
+ private int nextWritePosition;
public CosNByteBuffer(ByteBuffer byteBuffer) {
this.byteBuffer = byteBuffer;
- this.lastWritePosition = this.byteBuffer.position();
+ this.nextWritePosition = this.byteBuffer.position();
}
- public CosNByteBuffer put(byte b) {
+ public CosNByteBuffer put(byte b) throws IOException {
+ if (this.byteBuffer.hasRemaining()) {
+ throw new IOException("There is no remaining in the buffer.");
+ }
this.byteBuffer.put(b);
- this.lastWritePosition = this.byteBuffer.position();
+ this.nextWritePosition = this.byteBuffer.position();
return this;
}
@@ -37,7 +40,7 @@ public CosNByteBuffer put(byte[] src, int offset, int length) throws IOException
}
this.byteBuffer.put(src, offset, length);
- this.lastWritePosition = this.byteBuffer.position();
+ this.nextWritePosition = this.byteBuffer.position();
return this;
}
@@ -84,6 +87,7 @@ public CosNByteBuffer reset() {
public CosNByteBuffer clear() {
this.byteBuffer.clear();
+ this.nextWritePosition = 0;
return this;
}
@@ -98,13 +102,13 @@ public CosNByteBuffer rewind() {
}
public CosNByteBuffer flipRead() {
- this.limit(this.lastWritePosition);
+ this.limit(this.nextWritePosition);
this.position(0);
return this;
}
public CosNByteBuffer flipWrite() {
- this.position(this.lastWritePosition);
+ this.position(this.nextWritePosition);
this.limit(this.byteBuffer.capacity());
return this;
}
@@ -129,6 +133,6 @@ public void close() throws IOException {
this.byteBuffer.clear();
this.byteBuffer = null;
- this.lastWritePosition = -1;
+ this.nextWritePosition = -1;
}
}