Skip to content

Commit f1c44dc

Browse files
qwangseumike.wq
andauthored
fix(#io) : fix io read (#13)
Co-authored-by: mike.wq <[email protected]>
1 parent 0e85d35 commit f1c44dc

File tree

12 files changed

+26
-22
lines changed

12 files changed

+26
-22
lines changed

app-stream-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>open-app-stream-client</artifactId>
77
<groupId>com.dingtalk.open</groupId>
8-
<version>1.3.6</version>
8+
<version>1.3.7</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
package com.dingtalk.open.app.api.util;
22

3+
import java.io.ByteArrayOutputStream;
34
import java.io.InputStream;
45

56
/**
67
* @author feiyin
78
* @date 2023/3/1
89
*/
910
public class IoUtils {
10-
public static byte[] readAll(InputStream stream) throws Exception {
11-
if (stream == null) {
11+
private static final int EOF = -1;
12+
private static final int BUFFER_SIZE = 4 * 1024;
13+
14+
public static byte[] readAll(InputStream input) throws Exception {
15+
if (input == null) {
1216
return null;
1317
}
14-
int count = stream.available();
15-
byte[] content = new byte[count];
16-
while (count > 0) {
17-
int readBytes = stream.read(content);
18-
count -= readBytes;
18+
ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
19+
byte[] buffer = new byte[BUFFER_SIZE];
20+
int n;
21+
while (EOF != (n = input.read(buffer))) {
22+
output.write(buffer, 0, n);
1923
}
20-
return content;
24+
return output.toByteArray();
2125
}
2226
}

app-stream-client/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<parent>
55
<groupId>com.dingtalk.open</groupId>
66
<artifactId>open-app-stream-client</artifactId>
7-
<version>1.3.6</version>
7+
<version>1.3.7</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

1111
<artifactId>app-stream-client</artifactId>
1212
<packaging>jar</packaging>
13-
<version>1.3.6</version>
13+
<version>1.3.7</version>
1414
<name>app-stream-client</name>
1515

1616
<dependencies>

app-stream-network/app-stream-network-api/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
<parent>
55
<groupId>com.dingtalk.open</groupId>
66
<artifactId>app-stream-network</artifactId>
7-
<version>1.3.6</version>
7+
<version>1.3.7</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

1111
<artifactId>app-stream-network-api</artifactId>
12-
<version>1.3.6</version>
12+
<version>1.3.7</version>
1313
<packaging>jar</packaging>
1414

1515
<name>app-stream-network-api</name>

app-stream-network/app-stream-network-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.dingtalk.open</groupId>
66
<artifactId>app-stream-network</artifactId>
7-
<version>1.3.6</version>
7+
<version>1.3.7</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

app-stream-network/app-stream-network-rsocket/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.dingtalk.open</groupId>
66
<artifactId>app-stream-network</artifactId>
7-
<version>1.3.6</version>
7+
<version>1.3.7</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

app-stream-network/app-stream-network-ws/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.dingtalk.open</groupId>
66
<artifactId>app-stream-network</artifactId>
7-
<version>1.3.6</version>
7+
<version>1.3.7</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

app-stream-network/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>open-app-stream-client</artifactId>
77
<groupId>com.dingtalk.open</groupId>
8-
<version>1.3.6</version>
8+
<version>1.3.7</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<packaging>pom</packaging>

app-stream-protocol/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.dingtalk.open</groupId>
88
<artifactId>open-app-stream-client</artifactId>
9-
<version>1.3.6</version>
9+
<version>1.3.7</version>
1010
</parent>
1111

1212
<artifactId>app-stream-protocol</artifactId>

dingtalk-stream/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<parent>
55
<groupId>com.dingtalk.open</groupId>
66
<artifactId>open-app-stream-client</artifactId>
7-
<version>1.3.6</version>
7+
<version>1.3.7</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

1111
<artifactId>dingtalk-stream</artifactId>
1212
<packaging>jar</packaging>
13-
<version>1.3.6</version>
13+
<version>1.3.7</version>
1414
<name>app-stream-client</name>
1515

1616
<dependencies>

0 commit comments

Comments
 (0)