Skip to content

Commit 7f03511

Browse files
committed
Reformat and clean up code
Small improvements
1 parent a314c1e commit 7f03511

File tree

8 files changed

+61
-24
lines changed

8 files changed

+61
-24
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ A clear and concise description of what the bug is.
1212

1313
**To Reproduce**
1414
Steps to reproduce the behavior:
15+
1516
1. Create '...'
1617
2. Invoke '....'
1718
3. Send a request to '....'
@@ -24,9 +25,10 @@ A clear and concise description of what you expected to happen.
2425
If applicable, add stack traces to help explain your problem.
2526

2627
**Desktop (please complete the following information):**
27-
- OS
28-
- JRE/JDK build&version
29-
- Version
28+
29+
- OS
30+
- JRE/JDK build&version
31+
- Version
3032

3133
**Additional context**
3234
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ assignees: RomanQed
88
---
99

1010
**Is your feature request related to a problem? Please describe.**
11-
A clear and concise description of what the problem is. Ex. I always have to fix/spend extra time/write extra code when [...]
11+
A clear and concise description of what the problem is. Ex. I always have to fix/spend extra time/write extra code
12+
when [...]
1213

1314
**Describe the solution you'd like**
1415
A clear and concise description of what you want to happen.

CODE_OF_CONDUCT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
106106
### 4. Permanent Ban
107107

108108
**Community Impact**: Demonstrating a pattern of violation of community
109-
standards, including sustained inappropriate behavior, harassment of an
109+
standards, including sustained inappropriate behavior, harassment of an
110110
individual, or aggression toward or disparagement of classes of individuals.
111111

112112
**Consequence**: A permanent ban from any sort of public interaction within

README.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# sun-http-server [![maven-central](https://img.shields.io/maven-central/v/io.github.amayaframework/http-server?color=blue)](https://repo1.maven.org/maven2/io/github/amayaframework/http-server/)
22

3-
A repackaged and refactored sun http server, created in the original form by Oracle and formerly embedded in the jdk.
3+
A repackaged and refactored sun http server, created in the original form by Oracle and formerly embedded in the jdk.
44
Distributed under the GNU v2 license.
55

6-
This server, built on non-blocking sockets, is a really good lightweight solution that has everything you need
7-
for full use in various projects. Up to this point, it was ignored by most of the community due to its location
6+
This server, built on non-blocking sockets, is a really good lightweight solution that has everything you need
7+
for full use in various projects. Up to this point, it was ignored by most of the community due to its location
88
in sun packages. Now this restriction has been removed.
99

1010
## Getting Started
1111

1212
To install it, you will need:
13-
* any build of the JDK no older than version 8
14-
* some implementation of slf4j
13+
14+
* Java 8+
15+
* SLF4J implementation (optional)
1516
* Maven/Gradle
1617

1718
## Installing
@@ -25,6 +26,7 @@ dependencies {
2526
```
2627

2728
### Maven dependency
29+
2830
```
2931
<dependency>
3032
<groupId>io.github.amayaframework</groupId>
@@ -36,7 +38,7 @@ dependencies {
3638
## Usage example
3739

3840
The code below will start the server associated with the address localhost:8000.
39-
There will be one handler on the server responding to a route starting with /hello.
41+
There will be one handler on the server responding to a route starting with /hello.
4042
The response will contain code 200 and an empty body.
4143
He will respond to all other requests with the code 404.
4244

@@ -59,16 +61,18 @@ public class Server {
5961
* [slf4j](https://www.slf4j.org) - Logging facade
6062

6163
## Authors
62-
* **Oracle Corporation** - *Main work* - [Oracle](https://www.oracle.com)
63-
* **RomanQed** - *Repackaging and refactoring* - [RomanQed](https://github.com/RomanQed)
6464

65-
See also the list of [contributors](https://github.com/AmayaFramework/sun-http-server/contributors) who participated in this project.
65+
* [Oracle Corporation](https://www.oracle.com) - *Main work*
66+
* [RomanQed](https://github.com/RomanQed) - *Repackaging and refactoring*
67+
68+
See also the list of [contributors](https://github.com/AmayaFramework/sun-http-server/contributors) who participated in
69+
this project.
6670

6771
## License
6872

6973
This project is licensed under the GNU GENERAL PUBLIC LICENSE Version 2 - see the [LICENSE](LICENSE) file for details
7074

71-
Also, according to the requirements, the original inserts of Oracle
75+
Also, according to the requirements, the original inserts of Oracle
7276
license headers are preserved in the original source files.
7377

7478
## Acknowledgments

build.gradle

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.text.SimpleDateFormat
2+
13
plugins {
24
id 'java-library'
35
id 'maven-publish'
@@ -22,12 +24,33 @@ repositories {
2224

2325
dependencies {
2426
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.35'
25-
api group: 'io.github.amayaframework', name: 'http-utils', version: '1.0.0'
27+
api group: 'io.github.amayaframework', name: 'http-utils', version: '1.1.1'
2628
}
2729

2830
jar {
29-
from sourceSets.main.output
30-
from sourceSets.main.allJava
31+
manifest {
32+
var date = new Date()
33+
var javaVersion = System.getProperty("java.version")
34+
var vmVendor = System.getProperty("java.vm.vendor")
35+
var vmVersion = System.getProperty("java.vm.version")
36+
37+
attributes(
38+
'Created-By': String.format("%s (%s %s)", javaVersion, vmVendor, vmVersion),
39+
'Gradle-Version': "Gradle $gradle.gradleVersion",
40+
'Build-Date': new SimpleDateFormat("yyyy-MM-dd").format(date),
41+
'Build-Time': new SimpleDateFormat("HH:mm:ss.SSSZ").format(date),
42+
'Built-By': 'Roman Bakaldin',
43+
'Bundle-Name': 'Sun Http Server',
44+
'Bundle-Version': archiveVersion,
45+
'Bundle-SymbolicName': archivesBaseName,
46+
'Implementation-Title': archivesBaseName,
47+
'Implementation-Vendor': 'github.com/amayaframework',
48+
'Implementation-Version': archiveVersion,
49+
'Specification-Title': archivesBaseName,
50+
'Specification-Vendor': 'github.com/amayaframework',
51+
'Specification-Version': archiveVersion
52+
)
53+
}
3154
}
3255

3356
signing {

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
import java.io.IOException;
1010
import java.net.InetSocketAddress;
1111

12-
public class Servers {
12+
public final class Servers {
13+
14+
private Servers() {
15+
}
16+
1317
/**
1418
* Create a <code>HttpsServer</code> instance which will bind to the
1519
* specified {@link java.net.InetSocketAddress} (IP address and port number)

src/main/java/io/github/amayaframework/server/utils/Formats.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.util.Locale;
77
import java.util.TimeZone;
88

9-
public class Formats {
9+
public final class Formats {
1010
private static final String PATTERN = "EEE, dd MMM yyyy HH:mm:ss zzz";
1111
private static final TimeZone GMT_TZ = TimeZone.getTimeZone("GMT");
1212
private static final ThreadLocal<DateFormat> DATE_FORMAT;
@@ -19,6 +19,9 @@ public class Formats {
1919
});
2020
}
2121

22+
private Formats() {
23+
}
24+
2225
public static String formatDate(Date date) {
2326
return DATE_FORMAT.get().format(date);
2427
}

src/main/java/io/github/amayaframework/server/utils/ServerConfig.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,17 @@
2525

2626
package io.github.amayaframework.server.utils;
2727

28-
public class ServerConfig {
28+
public final class ServerConfig {
2929

3030
private static final int DEFAULT_CLOCK_TICK = 10000; // 10 sec.
31-
3231
/* These values must be a reasonable multiple of clockTick */
3332
private static final long DEFAULT_IDLE_INTERVAL = 30; // 5 min
3433
private static final int DEFAULT_MAX_IDLE_CONNECTIONS = 200;
35-
3634
private static final long DEFAULT_MAX_REQ_TIME = -1; // default: forever
3735
private static final long DEFAULT_MAX_RSP_TIME = -1; // default: forever
3836
private static final long DEFAULT_TIMER_MILLIS = 1000;
3937
private static final int DEFAULT_MAX_REQ_HEADERS = 200;
4038
private static final long DEFAULT_DRAIN_AMOUNT = 64 * 1024;
41-
4239
private static int clockTick = DEFAULT_CLOCK_TICK;
4340
private static long idleInterval = DEFAULT_IDLE_INTERVAL;
4441
// The maximum number of bytes to drain from an input stream
@@ -54,6 +51,9 @@ public class ServerConfig {
5451
// the value of the TCP_NO_DELAY socket-level option
5552
private static boolean noDelay = false;
5653

54+
private ServerConfig() {
55+
}
56+
5757
public static int getClockTick() {
5858
return clockTick;
5959
}

0 commit comments

Comments
 (0)