Skip to content

Commit d35ccaa

Browse files
committed
Make build.gradle compatible to gradle 7
Improve javadocs Update java-utils
1 parent 5725fcf commit d35ccaa

File tree

11 files changed

+83
-67
lines changed

11 files changed

+83
-67
lines changed

build.gradle

+39-51
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies {
2424
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
2525
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
2626
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.35'
27-
api group: 'com.github.romanqed', name: 'jutils', version: '1.2.7'
27+
api group: 'com.github.romanqed', name: 'jutils', version: '3.3.0'
2828
}
2929

3030
test {
@@ -43,12 +43,45 @@ signing {
4343
publishing {
4444
publications {
4545
mavenJava(MavenPublication) {
46-
customizePom(pom)
47-
groupId group
48-
artifactId archivesBaseName
49-
version version
50-
46+
// Specify artifacts
47+
groupId = group
48+
artifactId = archivesBaseName
49+
version = version
5150
from components.java
51+
// Configure pom
52+
pom {
53+
name.set('http-server')
54+
description.set('A repackaged and refactored sun http server, ' +
55+
'created in the original form by Oracle and formerly embedded in the jdk. ' +
56+
'Distributed under the GNU v2 license.')
57+
url.set('https://github.com/AmayaFramework/sun-http-server')
58+
organization {
59+
name.set('io.github.amayaframework')
60+
url.set('https://github.com/AmayaFramework')
61+
}
62+
issueManagement {
63+
system.set('GitHub')
64+
url.set('https://github.com/AmayaFramework/sun-http-server/issues')
65+
}
66+
licenses {
67+
license {
68+
name.set('GNU General Public License v2.0')
69+
url.set('https://github.com/AmayaFramework/sun-http-server/blob/main/LICENSE')
70+
}
71+
}
72+
scm {
73+
url.set('https://github.com/AmayaFramework/sun-http-server')
74+
connection.set('scm:https://github.com/AmayaFramework/sun-http-server.git')
75+
developerConnection.set('scm:https://github.com/AmayaFramework/sun-http-server.git')
76+
}
77+
developers {
78+
developer {
79+
id.set('RomanQed')
80+
name.set('Roman Bakaldin')
81+
email.set('gbakaldin@gmail.com')
82+
}
83+
}
84+
}
5285
}
5386
}
5487
repositories {
@@ -60,49 +93,4 @@ publishing {
6093
}
6194
}
6295
}
63-
}
64-
65-
def customizePom(pom) {
66-
pom.withXml {
67-
def root = asNode()
68-
69-
root.dependencies.removeAll { dep ->
70-
dep.scope == "test"
71-
}
72-
73-
root.children().last() + {
74-
resolveStrategy = DELEGATE_FIRST
75-
description 'A repackaged and refactored sun http server, ' +
76-
'created in the original form by Oracle and formerly embedded in the jdk. ' +
77-
'Distributed under the GNU v2 license.'
78-
name 'http-server'
79-
url 'https://github.com/AmayaFramework/sun-http-server'
80-
organization {
81-
name 'io.github.amayaframework'
82-
url 'https://github.com/AmayaFramework'
83-
}
84-
issueManagement {
85-
system 'GitHub'
86-
url 'https://github.com/AmayaFramework/sun-http-server/issues'
87-
}
88-
licenses {
89-
license {
90-
name 'GNU General Public License v2.0'
91-
url 'https://github.com/AmayaFramework/sun-http-server/blob/main/LICENSE'
92-
}
93-
}
94-
scm {
95-
url 'https://github.com/AmayaFramework/sun-http-server'
96-
connection 'scm:https://github.com/AmayaFramework/sun-http-server.git'
97-
developerConnection 'scm:https://github.com/AmayaFramework/sun-http-server.git'
98-
}
99-
developers {
100-
developer {
101-
id 'dev'
102-
name 'RomanQed'
103-
email 'gbakaldin@gmail.com'
104-
}
105-
}
106-
}
107-
}
10896
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/io/github/amayaframework/server/Servers.java

+10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class Servers {
2424
* to set the address
2525
* @param backlog the socket backlog. If this value is less than or equal to zero,
2626
* then a system default value is used.
27+
* @return created https server
28+
* @throws IOException if server creation will be failed
2729
*/
2830
public static HttpsServer httpsServer(InetSocketAddress address, int backlog) throws IOException {
2931
return new HttpsServerImpl(address, backlog);
@@ -34,6 +36,9 @@ public static HttpsServer httpsServer(InetSocketAddress address, int backlog) th
3436
* The server must be bound using {@link HttpsServer#bind(InetSocketAddress, int)} before it can be used.
3537
* The server must also have a HttpsConfigurator established
3638
* with {@link HttpsServer#setHttpsConfigurator(HttpsConfigurator)}
39+
*
40+
* @return created https server
41+
* @throws IOException if server creation will be failed
3742
*/
3843
public static HttpsServer httpsServer() throws IOException {
3944
return httpsServer(null, 0);
@@ -51,6 +56,8 @@ public static HttpsServer httpsServer() throws IOException {
5156
* to set the address
5257
* @param backlog the socket backlog. If this value is less than or equal to zero,
5358
* then a system default value is used.
59+
* @return created http server
60+
* @throws IOException if server creation will be failed
5461
*/
5562
public static HttpServer httpServer(InetSocketAddress address, int backlog) throws IOException {
5663
return new HttpServerImpl(address, backlog);
@@ -59,6 +66,9 @@ public static HttpServer httpServer(InetSocketAddress address, int backlog) thro
5966
/**
6067
* Creates a HttpServer instance which is initially not bound to any local address/port.
6168
* The server must be bound using {@link HttpServer#bind(InetSocketAddress, int)} before it can be used.
69+
*
70+
* @return created http server
71+
* @throws IOException if server creation will be failed
6272
*/
6373
public static HttpServer httpServer() throws IOException {
6474
return httpServer(null, 0);

src/main/java/io/github/amayaframework/server/implementations/Request.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ public OutputStream outputStream() {
6767
/**
6868
* read a line from the stream returning as a String.
6969
* Not used for reading headers.
70+
*
71+
* @return readied line
72+
* @throws IOException if read() throws it
7073
*/
71-
7274
public String readLine() throws IOException {
7375
boolean gotCR = false, gotLF = false;
7476
pos = 0;
@@ -107,7 +109,7 @@ private void consume(int c) {
107109
}
108110

109111
/**
110-
* returns the request line (first line of a request)
112+
* @return the request line (first line of a request)
111113
*/
112114
public String requestLine() {
113115
return startLine;

src/main/java/io/github/amayaframework/server/implementations/SSLStreams.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void close() {
9292
}
9393

9494
/**
95-
* return the SSL InputStream
95+
* @return the SSL InputStream
9696
*/
9797
public InputStream getInputStream() {
9898
if (inputStream == null) {
@@ -102,7 +102,7 @@ public InputStream getInputStream() {
102102
}
103103

104104
/**
105-
* return the SSL OutputStream
105+
* @return the SSL OutputStream
106106
*/
107107
public OutputStream getOutputStream() {
108108
if (outputStream == null) {
@@ -119,6 +119,8 @@ public SSLEngine getSSLEngine() {
119119
* request the engine to repeat the handshake on this session
120120
* the handshake must be driven by reads/writes on the streams
121121
* Normally, not necessary to call this.
122+
*
123+
* @throws SSLException if begin handshake will be failed
122124
*/
123125
public void beginHandshake() throws SSLException {
124126
engine.beginHandshake();
@@ -210,6 +212,10 @@ public WrapperResult sendData(ByteBuffer src) throws IOException {
210212
* given buffer was not large enough, a new one is allocated
211213
* and returned. This call handles handshaking automatically.
212214
* Caller should check if engine has been closed.
215+
*
216+
* @param dst {@link ByteBuffer} to write data
217+
* @return {@link WrapperResult}
218+
* @throws IOException if recv will be failed
213219
*/
214220
public WrapperResult recvData(ByteBuffer dst) throws IOException {
215221
/* we wait until some user data arrives */

src/main/java/io/github/amayaframework/server/interfaces/HttpContext.java

+4
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,17 @@ public interface HttpContext {
7171
* <p>
7272
* Every attribute stored in this Map will be visible to
7373
* every HttpExchange processed by this context
74+
*
75+
* @return attached attributes
7476
*/
7577
Map<String, Object> getAttributes();
7678

7779
/**
7880
* returns this context's list of Filters. This is the
7981
* actual list used by the server when dispatching requests
8082
* so modifications to this list immediately affect the handling of exchanges.
83+
*
84+
* @return list of {@link Filter}
8185
*/
8286
List<Filter> getFilters();
8387
}

src/main/java/io/github/amayaframework/server/interfaces/HttpExchange.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ public interface HttpExchange {
117117
HttpContext getHttpContext();
118118

119119
/**
120-
* Ends this exchange by doing the following in sequence:<p><ol>
120+
* <p>Ends this exchange by doing the following in sequence:</p>
121+
* <ol>
121122
* <li>close the request InputStream, if not already closed<p></li>
122123
* <li>close the response OutputStream, if not already closed. </li>
123124
* </ol>
@@ -183,6 +184,7 @@ public interface HttpExchange {
183184
* and an arbitrary number of bytes may be written.
184185
* if less or equal -1, then no response body length is specified and
185186
* no response body may be written.
187+
* @throws IOException if sending fails
186188
* @see HttpExchange#getResponseBody()
187189
*/
188190
void sendResponseHeaders(HttpCode code, long responseLength) throws IOException;

src/main/java/io/github/amayaframework/server/interfaces/HttpHandler.java

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public interface HttpHandler {
4242
* @param exchange the exchange containing the request from the
4343
* client and used to send the response
4444
* @throws NullPointerException if exchange is <code>null</code>
45+
* @throws IOException if exchange operations throws it
4546
*/
4647
void handle(HttpExchange exchange) throws IOException;
4748
}

src/main/java/io/github/amayaframework/server/interfaces/HttpServer.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,14 @@
5454
* whose path is the longest matching prefix of the request URI's path.
5555
* Paths are matched literally, which means that the strings are compared
5656
* case sensitively, and with no conversion to or from any encoded forms.
57-
* For example. Given a HttpServer with the following HttpContexts configured.<p>
57+
* <p>For example. Given a HttpServer with the following HttpContexts configured.</p>
5858
* <table summary="">
5959
* <tr><td><i>Context</i></td><td><i>Context path</i></td></tr>
6060
* <tr><td>ctx1</td><td>"/"</td></tr>
6161
* <tr><td>ctx2</td><td>"/apps/"</td></tr>
6262
* <tr><td>ctx3</td><td>"/apps/foo/"</td></tr>
6363
* </table>
64-
* <p>
65-
* the following table shows some request URIs and which, if any context they would
66-
* match with.<p>
64+
* <p>the following table shows some request URIs and which, if any context they would match with.</p>
6765
* <table summary="">
6866
* <tr><td><i>Request URI</i></td><td><i>Matches context</i></td></tr>
6967
* <tr><td>"http://foo.com/apps/foo/bar"</td><td>ctx3</td></tr>
@@ -156,6 +154,7 @@ public interface HttpServer {
156154
*
157155
* @param path the root URI path to associate the context with
158156
* @param handler the handler to invoke for incoming requests.
157+
* @return created {@link HttpContext}
159158
* @throws IllegalArgumentException if path is invalid, or if a context
160159
* already exists for this path
161160
* @throws NullPointerException if either path, or handler are <code>null</code>
@@ -177,6 +176,7 @@ public interface HttpServer {
177176
* to HttpContext instances.
178177
*
179178
* @param path the root URI path to associate the context with
179+
* @return created {@link HttpContext}
180180
* @throws IllegalArgumentException if path is invalid, or if a context
181181
* already exists for this path
182182
* @throws NullPointerException if path is <code>null</code>

src/main/java/io/github/amayaframework/server/interfaces/HttpsParameters.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ public abstract class HttpsParameters {
5858
private boolean needClientAuth;
5959

6060
/**
61-
* Returns the HttpsConfigurator for this HttpsParameters.
61+
* @return the HttpsConfigurator for this HttpsParameters.
6262
*/
6363
public abstract HttpsConfigurator getHttpsConfigurator();
6464

6565
/**
66-
* Returns the address of the remote client initiating the
66+
* @return the address of the remote client initiating the
6767
* connection.
6868
*/
6969
public abstract InetSocketAddress getClientAddress();

src/main/java/io/github/amayaframework/server/streams/LeftOverInputStream.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public LeftOverInputStream(ExchangeImpl exchange, InputStream src) {
4444
}
4545

4646
/**
47-
* if bytes are left over buffered on *the UNDERLYING* stream
47+
* @return if bytes are left over buffered on *the UNDERLYING* stream
48+
* @throws IOException if available() throws it
4849
*/
4950
public boolean isDataBuffered() throws IOException {
5051
return super.available() > 0;
@@ -91,9 +92,11 @@ public synchronized int read(byte[] b, int off, int len) throws IOException {
9192

9293
/**
9394
* read and discard up to l bytes or "eof" occurs,
94-
* (whichever is first). Then return true if the stream
95-
* is at eof (i.e. all bytes were read) or false if not
96-
* (still bytes to be read)
95+
* (whichever is first).
96+
*
97+
* @param l bytes count
98+
* @return return true if the stream is at eof (i.e. all bytes were read) or false if not still bytes to be read
99+
* @throws IOException if readImpl() throws it
97100
*/
98101
public boolean drain(long l) throws IOException {
99102
int bufSize = 2048;

0 commit comments

Comments
 (0)