Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 53ca4ef

Browse files
Marek Potociarpavelbucek
authored andcommitted
Updated to most recent Grizzly server & client.
Change-Id: I902dcccdb5cc3c08ac4f0b18bd4a5edad12f73d1 Signed-off-by: Marek Potociar <[email protected]>
1 parent 6df1cc4 commit 53ca4ef

File tree

4 files changed

+17
-30
lines changed

4 files changed

+17
-30
lines changed

connectors/grizzly-connector/pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@
6767
<dependency>
6868
<groupId>org.glassfish.grizzly</groupId>
6969
<artifactId>grizzly-websockets</artifactId>
70-
<!-- Until grizzly-http-client is not updated to the latest grizzly API.-->
71-
<version>2.3.19</version>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.glassfish.grizzly</groupId>
73+
<artifactId>connection-pool</artifactId>
7274
</dependency>
7375

7476
<dependency>

connectors/grizzly-connector/src/main/java/org/glassfish/jersey/grizzly/connector/GrizzlyConnector.java

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ class GrizzlyConnector implements Connector {
122122

123123
builder = builder.setExecutorService(executorService);
124124

125-
builder.setConnectionTimeoutInMs(ClientProperties.getValue(config.getProperties(),
125+
builder.setConnectTimeout(ClientProperties.getValue(config.getProperties(),
126126
ClientProperties.CONNECT_TIMEOUT, 0));
127127

128-
builder.setRequestTimeoutInMs(ClientProperties.getValue(config.getProperties(),
128+
builder.setRequestTimeout(ClientProperties.getValue(config.getProperties(),
129129
ClientProperties.READ_TIMEOUT, 0));
130130

131131
Object proxyUri;
@@ -156,7 +156,7 @@ class GrizzlyConnector implements Connector {
156156
builder.setExecutorService(executorService);
157157
}
158158

159-
builder.setAllowPoolingConnection(true);
159+
builder.setAllowPoolingConnections(true);
160160
if (client.getSslContext() != null) {
161161
builder.setSSLContext(client.getSslContext());
162162
}
@@ -252,8 +252,6 @@ public void onThrowable(Throwable t) {
252252
});
253253

254254
return responseFuture.get();
255-
} catch (IOException ex) {
256-
throw new ProcessingException(ex.getMessage(), ex.getCause());
257255
} catch (ExecutionException ex) {
258256
Throwable e = ex.getCause() == null ? ex : ex.getCause();
259257
throw new ProcessingException(e.getMessage(), e);
@@ -315,8 +313,6 @@ public void onThrowable(Throwable t) {
315313
}
316314
}
317315
});
318-
} catch (IOException ex) {
319-
failure = new ProcessingException(ex.getMessage(), ex.getCause());
320316
} catch (Throwable t) {
321317
failure = t;
322318
}
@@ -383,7 +379,7 @@ private com.ning.http.client.Request translate(final ClientRequest requestContex
383379
if (entityProcessing == RequestEntityProcessing.BUFFERED) {
384380
byte[] entityBytes = bufferEntity(requestContext);
385381
builder = builder.setBody(entityBytes);
386-
} else if (entityProcessing == RequestEntityProcessing.CHUNKED) {
382+
} else {
387383
final FeedableBodyGenerator bodyGenerator = new FeedableBodyGenerator();
388384
final Integer chunkSize = requestContext.resolveProperty(
389385
ClientProperties.CHUNKED_ENCODING_SIZE, ClientProperties.DEFAULT_CHUNK_SIZE);
@@ -403,8 +399,6 @@ public OutputStream getOutputStream(int contentLength) throws IOException {
403399
});
404400
bodyGenerator.setFeeder(feeder);
405401
builder.setBody(bodyGenerator);
406-
} else {
407-
builder.setBody(getEntityWriter(requestContext));
408402
}
409403
}
410404

@@ -485,22 +479,6 @@ private static Map<String, String> writeOutBoundHeaders(final MultivaluedMap<Str
485479
return stringHeaders;
486480
}
487481

488-
private com.ning.http.client.Request.EntityWriter getEntityWriter(final ClientRequest requestContext) {
489-
return new com.ning.http.client.Request.EntityWriter() {
490-
@Override
491-
public void writeEntity(final OutputStream out) throws IOException {
492-
requestContext.setStreamProvider(new OutboundMessageContext.StreamProvider() {
493-
494-
@Override
495-
public OutputStream getOutputStream(int contentLength) throws IOException {
496-
return out;
497-
}
498-
});
499-
requestContext.writeEntity();
500-
}
501-
};
502-
}
503-
504482
@Override
505483
public String getName() {
506484
return String.format("Async HTTP Grizzly Connector %s", Version.getVersion());

containers/grizzly2-http/src/main/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpServerFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import org.glassfish.grizzly.http.server.NetworkListener;
5959
import org.glassfish.grizzly.http.server.ServerConfiguration;
6060
import org.glassfish.grizzly.ssl.SSLEngineConfigurator;
61+
import org.glassfish.grizzly.utils.Charsets;
6162

6263
import jersey.repackaged.com.google.common.util.concurrent.ThreadFactoryBuilder;
6364

@@ -287,6 +288,7 @@ public static HttpServer createHttpServer(final URI uri,
287288
}
288289

289290
config.setPassTraceRequest(true);
291+
config.setDefaultQueryEncoding(Charsets.UTF8_CHARSET);
290292

291293
if (start) {
292294
try {

pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,11 @@
12441244
<artifactId>grizzly-websockets</artifactId>
12451245
<version>${grizzly2.version}</version>
12461246
</dependency>
1247+
<dependency>
1248+
<groupId>org.glassfish.grizzly</groupId>
1249+
<artifactId>connection-pool</artifactId>
1250+
<version>${grizzly2.version}</version>
1251+
</dependency>
12471252
<dependency>
12481253
<groupId>org.glassfish.grizzly</groupId>
12491254
<artifactId>grizzly-http-client</artifactId>
@@ -1662,8 +1667,8 @@
16621667
<findbugs.version>3.0.1</findbugs.version>
16631668
<freemarker.version>2.3.23</freemarker.version>
16641669
<gae.version>1.8.4</gae.version>
1665-
<grizzly.client.version>1.8</grizzly.client.version>
1666-
<grizzly2.version>2.3.19</grizzly2.version>
1670+
<grizzly.client.version>1.9</grizzly.client.version>
1671+
<grizzly2.version>2.3.22</grizzly2.version>
16671672
<guava.version>18.0</guava.version>
16681673
<hamcrest.version>1.3</hamcrest.version>
16691674
<hk2.version>2.4.0-b31</hk2.version>

0 commit comments

Comments
 (0)