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

Commit 8c06e4c

Browse files
committed
Merge branch 'github/master'
2 parents b0fc74e + e136f0a commit 8c06e4c

File tree

139 files changed

+15692
-229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+15692
-229
lines changed

archetypes/jersey-example-java8-webapp/pom.xml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
55
6-
Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
6+
Copyright (c) 2015-2016 Oracle and/or its affiliates. All rights reserved.
77
88
The contents of this file are subject to the terms of either the GNU
99
General Public License Version 2 only ("GPL") or the Common Development
@@ -55,20 +55,11 @@
5555
<description>Jersey (Java8) WebApp Example Archetype.</description>
5656

5757
<build>
58-
<extensions>
59-
<extension>
60-
<groupId>org.apache.maven.archetype</groupId>
61-
<artifactId>archetype-packaging</artifactId>
62-
<version>2.3</version>
63-
</extension>
64-
</extensions>
65-
66-
<plugins>
67-
<plugin>
68-
<groupId>org.apache.maven.plugins</groupId>
69-
<artifactId>maven-archetype-plugin</artifactId>
70-
<version>2.3</version>
71-
</plugin>
72-
</plugins>
58+
<resources>
59+
<resource>
60+
<directory>${basedir}/src/main/resources</directory>
61+
<filtering>true</filtering>
62+
</resource>
63+
</resources>
7364
</build>
7465
</project>

archetypes/jersey-heroku-webapp/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
55
6-
Copyright (c) 2013-2015 Oracle and/or its affiliates. All rights reserved.
6+
Copyright (c) 2013-2016 Oracle and/or its affiliates. All rights reserved.
77
88
The contents of this file are subject to the terms of either the GNU
99
General Public License Version 2 only ("GPL") or the Common Development
@@ -47,6 +47,7 @@
4747
<artifactId>project</artifactId>
4848
<version>3.0-SNAPSHOT</version>
4949
</parent>
50+
<packaging>maven-archetype</packaging>
5051

5152
<artifactId>jersey-heroku-webapp</artifactId>
5253
<name>jersey-archetype-heroku-webapp</name>

archetypes/jersey-quickstart-grizzly2/pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
55
6-
Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved.
6+
Copyright (c) 2010-2016 Oracle and/or its affiliates. All rights reserved.
77
88
The contents of this file are subject to the terms of either the GNU
99
General Public License Version 2 only ("GPL") or the Common Development
@@ -47,11 +47,13 @@
4747
<version>3.0-SNAPSHOT</version>
4848
</parent>
4949
<artifactId>jersey-quickstart-grizzly2</artifactId>
50+
<packaging>maven-archetype</packaging>
5051
<modelVersion>4.0.0</modelVersion>
5152
<description>
5253
An archetype which contains a quick start Jersey project based on Grizzly container.
5354
</description>
5455
<name>jersey-archetype-grizzly2</name>
56+
5557
<build>
5658
<resources>
5759
<resource>

archetypes/jersey-quickstart-webapp/pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
55
6-
Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved.
6+
Copyright (c) 2010-2016 Oracle and/or its affiliates. All rights reserved.
77
88
The contents of this file are subject to the terms of either the GNU
99
General Public License Version 2 only ("GPL") or the Common Development
@@ -47,11 +47,13 @@
4747
<version>3.0-SNAPSHOT</version>
4848
</parent>
4949
<modelVersion>4.0.0</modelVersion>
50+
<packaging>maven-archetype</packaging>
5051
<description>
5152
An archetype which contains a quick start Jersey-based web application project.
5253
</description>
5354
<artifactId>jersey-quickstart-webapp</artifactId>
5455
<name>jersey-archetype-webapp</name>
56+
5557
<build>
5658
<plugins>
5759
<plugin>

archetypes/pom.xml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
55
6-
Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved.
6+
Copyright (c) 2010-2016 Oracle and/or its affiliates. All rights reserved.
77
88
The contents of this file are subject to the terms of either the GNU
99
General Public License Version 2 only ("GPL") or the Common Development
@@ -63,6 +63,24 @@
6363
<module>jersey-example-java8-webapp</module>
6464
</modules>
6565

66+
<build>
67+
<extensions>
68+
<extension>
69+
<groupId>org.apache.maven.archetype</groupId>
70+
<artifactId>archetype-packaging</artifactId>
71+
<version>${archetype.mvn.plugin.version}</version>
72+
</extension>
73+
</extensions>
74+
75+
<plugins>
76+
<plugin>
77+
<groupId>org.apache.maven.plugins</groupId>
78+
<artifactId>maven-archetype-plugin</artifactId>
79+
<version>${archetype.mvn.plugin.version}</version>
80+
</plugin>
81+
</plugins>
82+
</build>
83+
6684
<profiles>
6785
<profile>
6886
<id>release</id>
@@ -71,7 +89,7 @@
7189
<plugin>
7290
<groupId>org.apache.maven.plugins</groupId>
7391
<artifactId>maven-gpg-plugin</artifactId>
74-
<version>1.1</version>
92+
<version>1.6</version>
7593
<executions>
7694
<execution>
7795
<id>sign-artifact</id>

bundles/repackaged/jersey-guava/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
55
6-
Copyright (c) 2014-2015 Oracle and/or its affiliates. All rights reserved.
6+
Copyright (c) 2014-2016 Oracle and/or its affiliates. All rights reserved.
77
88
The contents of this file are subject to the terms of either the GNU
99
General Public License Version 2 only ("GPL") or the Common Development
@@ -160,6 +160,9 @@
160160
<plugin>
161161
<groupId>org.fortasoft</groupId>
162162
<artifactId>gradle-maven-plugin</artifactId>
163+
<configuration>
164+
<gradleInstallationDir>${gradleHome}</gradleInstallationDir>
165+
</configuration>
163166
<executions>
164167
<execution>
165168
<id>proguard</id>

connectors/apache-connector/src/main/java/org/glassfish/jersey/apache/connector/ApacheConnector.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,15 +624,26 @@ public void close() throws IOException {
624624

625625
private static InputStream getInputStream(final CloseableHttpResponse response) throws IOException {
626626

627+
final InputStream inputStream;
628+
627629
if (response.getEntity() == null) {
628-
return new ByteArrayInputStream(new byte[0]);
630+
inputStream = new ByteArrayInputStream(new byte[0]);
629631
} else {
630632
final InputStream i = response.getEntity().getContent();
631633
if (i.markSupported()) {
632-
return i;
634+
inputStream = i;
635+
} else {
636+
inputStream = new BufferedInputStream(i, ReaderWriter.BUFFER_SIZE);
633637
}
634-
return new BufferedInputStream(i, ReaderWriter.BUFFER_SIZE);
635638
}
639+
640+
return new FilterInputStream(inputStream) {
641+
@Override
642+
public void close() throws IOException {
643+
response.close();
644+
super.close();
645+
}
646+
};
636647
}
637648

638649
private static class ConnectionFactory extends ManagedHttpClientConnectionFactory {
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
5+
*
6+
* The contents of this file are subject to the terms of either the GNU
7+
* General Public License Version 2 only ("GPL") or the Common Development
8+
* and Distribution License("CDDL") (collectively, the "License"). You
9+
* may not use this file except in compliance with the License. You can
10+
* obtain a copy of the License at
11+
* http://glassfish.java.net/public/CDDL+GPL_1_1.html
12+
* or packager/legal/LICENSE.txt. See the License for the specific
13+
* language governing permissions and limitations under the License.
14+
*
15+
* When distributing the software, include this License Header Notice in each
16+
* file and include the License file at packager/legal/LICENSE.txt.
17+
*
18+
* GPL Classpath Exception:
19+
* Oracle designates this particular file as subject to the "Classpath"
20+
* exception as provided by Oracle in the GPL Version 2 section of the License
21+
* file that accompanied this code.
22+
*
23+
* Modifications:
24+
* If applicable, add the following below the License Header, with the fields
25+
* enclosed by brackets [] replaced by your own identifying information:
26+
* "Portions Copyright [year] [name of copyright owner]"
27+
*
28+
* Contributor(s):
29+
* If you wish your version of this file to be governed by only the CDDL or
30+
* only the GPL Version 2, indicate your decision by adding "[Contributor]
31+
* elects to include this software in this distribution under the [CDDL or GPL
32+
* Version 2] license." If you don't indicate a single choice of license, a
33+
* recipient has the option to distribute your version of this file under
34+
* either the CDDL, the GPL Version 2 or to extend the choice of license to
35+
* its licensees as provided above. However, if you add GPL Version 2 code
36+
* and therefore, elected the GPL Version 2 license, then the option applies
37+
* only if the new code is made subject to such option by the copyright
38+
* holder.
39+
*/
40+
41+
package org.glassfish.jersey.apache.connector;
42+
43+
import java.io.IOException;
44+
import java.io.InputStream;
45+
46+
import javax.ws.rs.GET;
47+
import javax.ws.rs.Path;
48+
import javax.ws.rs.Produces;
49+
import javax.ws.rs.client.WebTarget;
50+
import javax.ws.rs.core.Application;
51+
import javax.ws.rs.core.MediaType;
52+
53+
import javax.inject.Singleton;
54+
55+
import org.glassfish.jersey.client.ClientConfig;
56+
import org.glassfish.jersey.server.ChunkedOutput;
57+
import org.glassfish.jersey.server.ResourceConfig;
58+
import org.glassfish.jersey.test.JerseyTest;
59+
60+
import org.junit.Test;
61+
import static org.junit.Assert.assertEquals;
62+
63+
/**
64+
* @author Petr Janouch (petr.janouch at oracle.com)
65+
*/
66+
public class StreamingTest extends JerseyTest {
67+
68+
/**
69+
* Test that a data stream can be terminated from the client side.
70+
*/
71+
@Test
72+
public void clientCloseTest() throws IOException {
73+
// start streaming
74+
InputStream inputStream = target().path("/streamingEndpoint").request().get(InputStream.class);
75+
76+
WebTarget sendTarget = target().path("/streamingEndpoint/send");
77+
// trigger sending 'A' to the stream; OK is sent if everything on the server was OK
78+
assertEquals("OK", sendTarget.request().get().readEntity(String.class));
79+
// check 'A' has been sent
80+
assertEquals('A', inputStream.read());
81+
// closing the stream should tear down the connection
82+
inputStream.close();
83+
// trigger sending another 'A' to the stream; it should fail
84+
// (indicating that the streaming has been terminated on the server)
85+
assertEquals("NOK", sendTarget.request().get().readEntity(String.class));
86+
}
87+
88+
@Override
89+
protected void configureClient(ClientConfig config) {
90+
config.connectorProvider(new ApacheConnectorProvider());
91+
}
92+
93+
@Override
94+
protected Application configure() {
95+
return new ResourceConfig(StreamingEndpoint.class);
96+
}
97+
98+
@Singleton
99+
@Path("streamingEndpoint")
100+
public static class StreamingEndpoint {
101+
102+
private final ChunkedOutput<String> output = new ChunkedOutput<>(String.class);
103+
104+
@GET
105+
@Path("send")
106+
public String sendEvent() {
107+
try {
108+
output.write("A");
109+
} catch (IOException e) {
110+
return "NOK";
111+
}
112+
113+
return "OK";
114+
}
115+
116+
@GET
117+
@Produces(MediaType.TEXT_PLAIN)
118+
public ChunkedOutput<String> get() {
119+
return output;
120+
}
121+
}
122+
}

0 commit comments

Comments
 (0)