Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 45e6c45

Browse files
committed
changed back to non-streaming result handling because of socket-read hiccups
1 parent cd96c36 commit 45e6c45

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-5
lines changed

pom.xml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<properties>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1818
<slf4j.version>1.6.1</slf4j.version>
19-
<neo4j.version>1.8-SNAPSHOT</neo4j.version>
19+
<neo4j.version>1.8.M06</neo4j.version>
2020
<jersey.version>1.4</jersey.version>
2121
<blueprints.version>1.2</blueprints.version>
2222
<gremlin.version>1.5</gremlin.version>
@@ -87,8 +87,25 @@ the relevant Commercial Agreement.
8787
<dependency>
8888
<groupId>org.codehaus.jackson</groupId>
8989
<artifactId>jackson-jaxrs</artifactId>
90-
<version>1.8.3</version>
90+
<version>1.8.5</version>
9191
</dependency>
92+
<!--dependency>
93+
<groupId>com.sun.jersey.contribs</groupId>
94+
<artifactId>jersey-apache-client4</artifactId>
95+
<version>1.9-ea04</version>
96+
</dependency>
97+
<dependency>
98+
<groupId>org.apache.httpcomponents</groupId>
99+
<artifactId>httpclient</artifactId>
100+
<version>4.1.3</version>
101+
<scope>compile</scope>
102+
</dependency>
103+
<dependency>
104+
<groupId>org.apache.httpcomponents</groupId>
105+
<artifactId>httpcore</artifactId>
106+
<version>4.1.3</version>
107+
<scope>compile</scope>
108+
</dependency-->
92109
<dependency>
93110
<groupId>junit</groupId>
94111
<artifactId>junit</artifactId>
@@ -153,6 +170,10 @@ the relevant Commercial Agreement.
153170
<groupId>com.sun.jersey</groupId>
154171
<artifactId>jersey-server</artifactId>
155172
</exclusion>
173+
<exclusion>
174+
<artifactId>jackson-jaxrs</artifactId>
175+
<groupId>org.codehaus.jackson</groupId>
176+
</exclusion>
156177
<exclusion>
157178
<groupId>de.huxhorn.lilith</groupId>
158179
<artifactId>de.huxhorn.lilith.3rdparty.rrd4j</artifactId>

src/main/java/org/neo4j/rest/graphdb/ExecutingRestRequest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ protected void addAuthFilter(String username, String password) {
6666

6767
protected Client createClient() {
6868
Client client = Client.create();
69-
7069
client.setConnectTimeout(CONNECT_TIMEOUT);
7170
client.setReadTimeout(READ_TIMEOUT);
7271
client.setChunkedEncodingSize(8*1024);

src/main/java/org/neo4j/rest/graphdb/RequestResult.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package org.neo4j.rest.graphdb;
2121

22+
import java.io.IOException;
2223
import java.io.InputStream;
2324
import java.net.URI;
2425
import java.util.Map;
@@ -76,8 +77,18 @@ public static RequestResult batchResult(RestOperation restOperation){
7677
public static RequestResult extractFrom(ClientResponse clientResponse) {
7778
final int status = clientResponse.getStatus();
7879
final URI location = clientResponse.getLocation();
79-
final InputStream data = status != Response.Status.NO_CONTENT.getStatusCode() ? clientResponse.getEntityInputStream() : null;
80-
return new RequestResult(status, uriString(location), data,clientResponse);
80+
// final InputStream data;
81+
if (status == Response.Status.NO_CONTENT.getStatusCode()) {
82+
// data = null;
83+
clientResponse.close();
84+
return new RequestResult(status, uriString(location), null,clientResponse);
85+
} else {
86+
// data = clientResponse.getEntityInputStream();
87+
RequestResult result = new RequestResult(status, uriString(location), clientResponse.getEntity(String.class));
88+
clientResponse.close();
89+
return result;
90+
}
91+
//return new RequestResult(status, uriString(location), data,clientResponse);
8192
}
8293

8394
private static String uriString(URI location) {
@@ -138,11 +149,19 @@ public String getText() {
138149
}
139150

140151
private void closeStream() {
152+
if (stream!=null) readFully(stream);
141153
stream = null;
142154
if (response!=null) {
143155
response.close();
144156
response = null;
145157
}
146158
}
147159

160+
private void readFully(InputStream stream) {
161+
try {
162+
while (stream.read()!=-1);
163+
} catch (IOException e) {
164+
// ignore
165+
}
166+
}
148167
}

src/test/java/org/neo4j/rest/graphdb/LocalTestServer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.neo4j.server.CommunityNeoServer;
2626
import org.neo4j.server.configuration.PropertyFileConfigurator;
2727
import org.neo4j.server.database.Database;
28+
import org.neo4j.server.database.WrappingDatabase;
2829
import org.neo4j.server.modules.RESTApiModule;
2930
import org.neo4j.server.modules.ServerModule;
3031
import org.neo4j.server.modules.ThirdPartyJAXRSModule;
@@ -100,6 +101,11 @@ protected int getWebServerPort() {
100101
return port;
101102
}
102103

104+
@Override
105+
protected Database createDatabase() {
106+
return new WrappingDatabase(graphDatabase);
107+
}
108+
103109
@Override
104110
protected StartupHealthCheck createHealthCheck() {
105111
return new StartupHealthCheck();

0 commit comments

Comments
 (0)