Skip to content

Commit 28a6f98

Browse files
authored
Merge pull request #139 from Katsuya-Tomioka/WS-1518-remove-guava
WS-1518: remove guava from rosette-api
2 parents db75844 + c79bc42 commit 28a6f98

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

api/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@
6161
<artifactId>httpmime</artifactId>
6262
<version>${http-components-version}</version>
6363
</dependency>
64-
<dependency>
65-
<groupId>com.google.guava</groupId>
66-
<artifactId>guava</artifactId>
67-
<scope>compile</scope>
68-
</dependency>
6964
<dependency>
7065
<groupId>org.slf4j</groupId>
7166
<artifactId>slf4j-api</artifactId>

api/src/main/java/com/basistech/rosette/api/HttpRosetteAPI.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import com.fasterxml.jackson.databind.DeserializationFeature;
3636
import com.fasterxml.jackson.databind.ObjectMapper;
3737
import com.fasterxml.jackson.databind.ObjectWriter;
38-
import com.google.common.io.ByteStreams;
3938
import org.apache.http.Header;
4039
import org.apache.http.HttpEntity;
4140
import org.apache.http.HttpHeaders;
@@ -61,6 +60,7 @@
6160
import org.slf4j.Logger;
6261
import org.slf4j.LoggerFactory;
6362

63+
import java.io.ByteArrayOutputStream;
6464
import java.io.IOException;
6565
import java.io.InputStream;
6666
import java.io.OutputStream;
@@ -159,7 +159,18 @@ private static String getVersion() {
159159
* @throws IOException
160160
*/
161161
private static byte[] getBytes(InputStream is) throws IOException {
162-
return ByteStreams.toByteArray(is);
162+
ByteArrayOutputStream out = new ByteArrayOutputStream();
163+
164+
byte[] buf = new byte[4096];
165+
166+
while (true) {
167+
int r = is.read(buf);
168+
if (r == -1) {
169+
out.flush();
170+
return out.toByteArray();
171+
}
172+
out.write(buf, 0, r);
173+
}
163174
}
164175

165176
private void initClient(String key, List<Header> additionalHeaders) {

examples/src/main/java/com/basistech/rosette/examples/CategoriesExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static void main(String[] args) {
3939
}
4040

4141
private void run() throws IOException {
42-
String categoriesUrlData = "http://www.onlocationvacations.com/2015/03/05/the-new-ghostbusters-movie-begins-filming-in-boston-in-june/";
42+
String categoriesUrlData = "https://onlocationvacations.com/2015/03/05/the-new-ghostbusters-movie-begins-filming-in-boston-in-june/";
4343
HttpRosetteAPI rosetteApi = new HttpRosetteAPI.Builder()
4444
.key(getApiKeyFromSystemProperty())
4545
.url(getAltUrlFromSystemProperty())

0 commit comments

Comments
 (0)