Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit 0c840e5

Browse files
committed
Merge pull request #3 from simonetripodi/master
Jersey Upgrade
2 parents 3f185a7 + d966eac commit 0c840e5

File tree

5 files changed

+39
-56
lines changed

5 files changed

+39
-56
lines changed

pom.xml

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<parent>
1717
<groupId>org.sonatype.forge</groupId>
1818
<artifactId>forge-parent</artifactId>
19-
<version>6</version>
19+
<version>12</version>
2020
</parent>
2121
<modelVersion>4.0.0</modelVersion>
2222
<groupId>org.sonatype.spice</groupId>
@@ -42,6 +42,11 @@
4242
<name>Jeanfrancois Arcand</name>
4343
<email>[email protected]</email>
4444
</developer>
45+
<developer>
46+
<id>simonetripodi</id>
47+
<name>Simone Tripodi</name>
48+
<email>[email protected]</email>
49+
</developer>
4550
</developers>
4651
<licenses>
4752
<license>
@@ -55,16 +60,19 @@
5560
<distribution>repo</distribution>
5661
</license>
5762
</licenses>
63+
<properties>
64+
<jersey.version>1.14</jersey.version>
65+
</properties>
5866
<dependencies>
5967
<dependency>
6068
<groupId>com.sun.jersey</groupId>
6169
<artifactId>jersey-client</artifactId>
62-
<version>1.5</version>
70+
<version>${jersey.version}</version>
6371
</dependency>
6472
<dependency>
6573
<groupId>com.sun.jersey</groupId>
6674
<artifactId>jersey-json</artifactId>
67-
<version>1.5</version>
75+
<version>${jersey.version}</version>
6876
</dependency>
6977
<dependency>
7078
<groupId>javax.ws.rs</groupId>
@@ -75,7 +83,7 @@
7583
<dependency>
7684
<groupId>com.ning</groupId>
7785
<artifactId>async-http-client</artifactId>
78-
<version>1.6.4</version>
86+
<version>1.7.6</version>
7987
</dependency>
8088
<dependency>
8189
<groupId>com.sun.xml.bind</groupId>
@@ -98,13 +106,19 @@
98106
<dependency>
99107
<groupId>junit</groupId>
100108
<artifactId>junit</artifactId>
101-
<version>4.8.2</version>
109+
<version>4.10</version>
102110
<scope>test</scope>
103111
</dependency>
104112
<dependency>
105113
<groupId>com.sun.jersey</groupId>
106114
<artifactId>jersey-server</artifactId>
107-
<version>1.5</version>
115+
<version>${jersey.version}</version>
116+
<scope>test</scope>
117+
</dependency>
118+
<dependency>
119+
<groupId>com.sun.jersey</groupId>
120+
<artifactId>jersey-bundle</artifactId>
121+
<version>${jersey.version}</version>
108122
<scope>test</scope>
109123
</dependency>
110124
</dependencies>
@@ -114,7 +128,6 @@
114128
<plugin>
115129
<groupId>org.codehaus.mojo</groupId>
116130
<artifactId>animal-sniffer-maven-plugin</artifactId>
117-
<version>1.6</version>
118131
<configuration>
119132
<signature>
120133
<groupId>org.codehaus.mojo.signature</groupId>
@@ -135,7 +148,6 @@
135148
<plugin>
136149
<groupId>org.apache.felix</groupId>
137150
<artifactId>maven-bundle-plugin</artifactId>
138-
<version>2.0.1</version>
139151
<extensions>true</extensions>
140152
<configuration>
141153
<manifestLocation>META-INF</manifestLocation>
@@ -163,7 +175,6 @@
163175
<plugin>
164176
<groupId>org.apache.maven.plugins</groupId>
165177
<artifactId>maven-enforcer-plugin</artifactId>
166-
<version>1.0-beta-1</version>
167178
<executions>
168179
<execution>
169180
<id>enforce-versions</id>
@@ -186,31 +197,13 @@
186197
<plugin>
187198
<groupId>org.apache.maven.plugins</groupId>
188199
<artifactId>maven-compiler-plugin</artifactId>
189-
<version>2.3.2</version>
190200
<configuration>
191-
<source>1.5</source>
192-
<target>1.5</target>
193-
<encoding>UTF-8</encoding>
194201
<maxmem>1024m</maxmem>
195202
</configuration>
196203
</plugin>
197-
<plugin>
198-
<groupId>org.apache.maven.plugins</groupId>
199-
<artifactId>maven-resources-plugin</artifactId>
200-
<version>2.4.3</version>
201-
<configuration>
202-
<encoding>UTF-8</encoding>
203-
</configuration>
204-
</plugin>
205-
<plugin>
206-
<groupId>org.apache.maven.plugins</groupId>
207-
<artifactId>maven-release-plugin</artifactId>
208-
<version>2.1</version>
209-
</plugin>
210204
<plugin>
211205
<groupId>org.apache.maven.plugins</groupId>
212206
<artifactId>maven-jar-plugin</artifactId>
213-
<version>2.3.1</version>
214207
<executions>
215208
<execution>
216209
<goals>
@@ -219,20 +212,6 @@
219212
</execution>
220213
</executions>
221214
</plugin>
222-
<plugin>
223-
<groupId>org.apache.maven.plugins</groupId>
224-
<artifactId>maven-source-plugin</artifactId>
225-
<version>2.1.2</version>
226-
<executions>
227-
<execution>
228-
<id>attach-sources</id>
229-
<phase>verify</phase>
230-
<goals>
231-
<goal>jar-no-fork</goal>
232-
</goals>
233-
</execution>
234-
</executions>
235-
</plugin>
236215
</plugins>
237216
</build>
238217
</project>

src/main/java/org/sonatype/spice/jersey/client/ahc/AhcClientHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ public AsyncHttpClient getHttpClient() {
105105
* @return the {@link ClientResponse}
106106
* @throws ClientHandlerException
107107
*/
108-
@Override
109108
public ClientResponse handle(final ClientRequest cr)
110109
throws ClientHandlerException {
111110

src/main/java/org/sonatype/spice/jersey/client/ahc/AhcHttpClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ protected void finalize(){
149149
// Do not close the AHCClient.
150150
super.destroy();
151151
} finally {
152-
super.finalize();
152+
try {
153+
super.finalize();
154+
} catch (Throwable e) {
155+
// TODO swallow?
156+
}
153157
}
154158
}
155159

src/main/java/org/sonatype/spice/jersey/client/ahc/AhcRequestWriter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*******************************************************************************/
1212
package org.sonatype.spice.jersey.client.ahc;
1313

14+
import static com.sun.jersey.api.client.ClientRequest.getHeaderValue;
15+
1416
import com.ning.http.client.PerRequestConfig;
1517
import com.ning.http.client.Request;
1618
import com.ning.http.client.RequestBuilder;
@@ -52,7 +54,7 @@ public void configureRequest(final RequestBuilder requestBuilder, final ClientRe
5254
re.writeRequestEntity(new CommittingOutputStream(baos) {
5355
@Override
5456
protected void commit() throws IOException {
55-
configureHeaders(cr.getMetadata(), requestBuilder);
57+
configureHeaders(cr.getHeaders(), requestBuilder);
5658
}
5759
});
5860
} catch (IOException ex) {
@@ -61,13 +63,12 @@ protected void commit() throws IOException {
6163

6264
final byte[] content = baos.toByteArray();
6365
requestBuilder.setBody(new Request.EntityWriter() {
64-
@Override
6566
public void writeEntity(OutputStream out) throws IOException {
6667
out.write(content);
6768
}
6869
});
6970
} else {
70-
configureHeaders(cr.getMetadata(), requestBuilder);
71+
configureHeaders(cr.getHeaders(), requestBuilder);
7172
}
7273
}
7374

@@ -78,7 +79,7 @@ private void configureHeaders(MultivaluedMap<String, Object> metadata, RequestBu
7879
if (String.class.isAssignableFrom( o.getClass() )) {
7980
requestBuilder.addHeader(e.getKey(), o.toString());
8081
} else {
81-
requestBuilder.addHeader(e.getKey(), headerValueToString(o));
82+
requestBuilder.addHeader(e.getKey(), getHeaderValue(o));
8283
}
8384
}
8485
}

src/test/java/org/sonatype/spice/jersey/client/ahc/tests/tests/AbstractGrizzlyServerTester.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public abstract class AbstractGrizzlyServerTester extends TestCase {
3333
private SelectorThread selectorThread;
3434

3535
private int port = getEnvVariable("JERSEY_HTTP_PORT", 9997);
36-
36+
3737
private static int getEnvVariable(final String varName, int defaultValue) {
3838
if (null == varName) {
3939
return defaultValue;
@@ -52,26 +52,26 @@ private static int getEnvVariable(final String varName, int defaultValue) {
5252
public AbstractGrizzlyServerTester(String name) {
5353
super(name);
5454
}
55-
55+
5656
public UriBuilder getUri() {
5757
return UriBuilder.fromUri("http://localhost").port(port).path(CONTEXT);
5858
}
59-
60-
public void startServer(Class... resources) {
59+
60+
public void startServer(Class<?>... resources) {
6161
start(ContainerFactory.createContainer(Adapter.class, resources));
6262
}
63-
63+
6464
public void startServer(ResourceConfig config) {
6565
start(ContainerFactory.createContainer(Adapter.class, config));
6666
}
67-
67+
6868
private void start(Adapter adapter) {
6969
if (selectorThread != null && selectorThread.isRunning()){
7070
stopServer();
7171
}
7272

7373
System.out.println("Starting GrizzlyServer port number = " + port);
74-
74+
7575
URI u = UriBuilder.fromUri("http://localhost").port(port).build();
7676
try {
7777
selectorThread = GrizzlyServerFactory.create(u, adapter);
@@ -91,13 +91,13 @@ private void start(Adapter adapter) {
9191
}
9292
}
9393
}
94-
94+
9595
public void stopServer() {
9696
if (selectorThread.isRunning()) {
9797
selectorThread.stopEndpoint();
9898
}
9999
}
100-
100+
101101
@Override
102102
public void tearDown() {
103103
stopServer();

0 commit comments

Comments
 (0)