Skip to content

Commit 59979ee

Browse files
committed
code cleanup
1 parent dd2700d commit 59979ee

File tree

67 files changed

+53
-149
lines changed

Some content is hidden

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

67 files changed

+53
-149
lines changed

docs/src/main/java/io/jooby/adoc/DocApp.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.slf4j.bridge.SLF4JBridgeHandler;
1414

1515
import java.nio.file.Path;
16-
import java.time.Duration;
1716
import java.util.Arrays;
1817

1918
import static org.slf4j.helpers.NOPLogger.NOP_LOGGER;

docs/src/main/java/io/jooby/adoc/DocGenerator.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77

88
import io.jooby.SneakyThrows;
99
import org.apache.commons.io.FileUtils;
10-
import org.apache.commons.io.filefilter.AndFileFilter;
11-
import org.apache.commons.io.filefilter.DirectoryFileFilter;
12-
import org.apache.commons.io.filefilter.IOFileFilter;
13-
import org.apache.commons.io.filefilter.NameFileFilter;
14-
import org.apache.commons.io.filefilter.TrueFileFilter;
1510
import org.asciidoctor.Asciidoctor;
1611
import org.asciidoctor.Attributes;
1712
import org.asciidoctor.Options;
@@ -30,14 +25,11 @@
3025
import java.nio.file.Paths;
3126
import java.nio.file.StandardCopyOption;
3227
import java.time.Instant;
33-
import java.time.LocalDateTime;
3428
import java.time.format.DateTimeFormatter;
3529
import java.util.Arrays;
3630
import java.util.Collection;
37-
import java.util.HashSet;
3831
import java.util.LinkedHashSet;
3932
import java.util.List;
40-
import java.util.Set;
4133
import java.util.UUID;
4234
import java.util.stream.Collectors;
4335
import java.util.stream.Stream;

jooby/src/main/java/io/jooby/AttachedFile.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public class AttachedFile {
3333

3434
private final MediaType contentType;
3535

36-
private String fileName;
36+
private final String fileName;
3737

38-
private String contentDisposition;
38+
private final String contentDisposition;
3939

40-
private InputStream content;
40+
private final InputStream content;
4141

4242
/**
4343
* Creates a new file attachment.

jooby/src/main/java/io/jooby/DefaultContext.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public interface DefaultContext extends Context {
197197

198198
@Override default boolean accept(@Nonnull MediaType contentType) {
199199
Value accept = header(ACCEPT);
200-
return accept.isMissing() ? true : contentType.matches(accept.value());
200+
return accept.isMissing() || contentType.matches(accept.value());
201201
}
202202

203203
@Override default MediaType accept(@Nonnull List<MediaType> produceTypes) {
@@ -237,14 +237,10 @@ public interface DefaultContext extends Context {
237237
url.append(getRequestPath());
238238
} else {
239239
String contextPath = getContextPath();
240-
if (contextPath.equals("/")) {
241-
url.append(path);
242-
} else {
243-
if (!path.startsWith(contextPath)) {
244-
url.append(contextPath);
245-
}
246-
url.append(path);
240+
if (!contextPath.equals("/") && !path.startsWith(contextPath)) {
241+
url.append(contextPath);
247242
}
243+
url.append(path);
248244
}
249245
url.append(queryString());
250246

jooby/src/main/java/io/jooby/Jooby.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ public static void runApp(@Nonnull String[] args, @Nonnull ExecutionMode executi
954954
Jooby app = createApp(args, executionMode, provider);
955955
Server server = app.start();
956956
Config conf = app.getConfig();
957-
boolean join = conf.hasPath("server.join") ? conf.getBoolean("server.join") : true;
957+
boolean join = !conf.hasPath("server.join") || conf.getBoolean("server.join");
958958
if (join) {
959959
server.join();
960960
}

jooby/src/main/java/io/jooby/OpenAPIModule.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import javax.annotation.Nonnull;
1212
import java.io.IOException;
1313
import java.io.InputStream;
14+
import java.nio.charset.StandardCharsets;
1415
import java.util.Arrays;
1516
import java.util.EnumSet;
1617
import java.util.HashMap;
@@ -181,7 +182,7 @@ private void swaggerUI(Jooby application, AssetSource source) throws IOException
181182

182183
private static String readString(AssetSource source, String resource) throws IOException {
183184
try (InputStream stream = source.resolve(resource).stream()) {
184-
return IOUtils.toString(stream, "UTF-8");
185+
return IOUtils.toString(stream, StandardCharsets.UTF_8);
185186
}
186187
}
187188

jooby/src/main/java/io/jooby/SSLHandler.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ public SSLHandler(@Nonnull String host) {
5555
* please consider to set {@link Router#setTrustProxy(boolean)} option.
5656
*
5757
* @param port HTTPS port.
58-
* @deprecated Use {@link Router#setTrustProxy(boolean)}.
5958
*/
60-
@Deprecated
6159
public SSLHandler(int port) {
6260
this.host = null;
6361
this.port = port;

jooby/src/main/java/io/jooby/internal/ByteArrayBody.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class ByteArrayBody implements Body {
2626

2727
protected final Context ctx;
2828

29-
private byte[] bytes;
29+
private final byte[] bytes;
3030

3131
public ByteArrayBody(Context ctx, byte[] bytes) {
3232
this.ctx = ctx;
@@ -81,7 +81,7 @@ public ByteArrayBody(Context ctx, byte[] bytes) {
8181
return Collections.emptyMap();
8282
}
8383

84-
public static final Body empty(Context ctx) {
84+
public static Body empty(Context ctx) {
8585
return new ByteArrayBody(ctx, EMPTY);
8686
}
8787
}

jooby/src/main/java/io/jooby/internal/Chi.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Chi implements RouteTree {
2828
private static final byte ntParam = 2; // /{user}
2929
private static final byte ntCatchAll = 3; // /api/v1/*
3030

31-
private static int NODE_SIZE = ntCatchAll + 1;
31+
private static final int NODE_SIZE = ntCatchAll + 1;
3232

3333
static final StaticRoute NO_MATCH = new StaticRoute(Collections.emptyMap());
3434

@@ -54,10 +54,10 @@ public void put(String method, Route route) {
5454
static class ZeroCopyString {
5555
public static final ZeroCopyString EMPTY = new ZeroCopyString(new char[0], 0, 0);
5656

57-
private int offset;
58-
private int length;
57+
private final int offset;
58+
private final int length;
5959
private int hash = 0;
60-
private char[] value;
60+
private final char[] value;
6161

6262
public ZeroCopyString(String source) {
6363
this.offset = 0;
@@ -496,18 +496,14 @@ void setEndpoint(String method, Route route) {
496496
// Recursive edge traversal by checking all nodeTyp groups along the way.
497497
// It's like searching through a multi-dimensional radix trie.
498498
Route findRoute(RouterMatch rctx, String method, ZeroCopyString path) {
499-
Node n = this;
500-
Node nn = n;
501-
502-
ZeroCopyString search = path;
503499

504500
for (int ntyp = 0; ntyp < NODE_SIZE; ntyp++) {
505-
Node[] nds = nn.children[ntyp];
501+
Node[] nds = this.children[ntyp];
506502
if (nds != null) {
507503
Node xn = null;
508-
ZeroCopyString xsearch = search;
504+
ZeroCopyString xsearch = path;
509505

510-
char label = search.length() > 0 ? search.charAt(0) : ZERO_CHAR;
506+
char label = path.length() > 0 ? path.charAt(0) : ZERO_CHAR;
511507

512508
switch (ntyp) {
513509
case ntStatic:
@@ -760,12 +756,12 @@ public void destroy() {
760756
}
761757
}
762758

763-
private static String BASE_CATCH_ALL = "/?*";
759+
private static final String BASE_CATCH_ALL = "/?*";
764760

765-
private Node root = new Node();
761+
private final Node root = new Node();
766762

767763
/** Not need to use a concurrent map, due we don't allow to add routes after application started. */
768-
private Map<Object, StaticRoute> staticPaths = newMap(16);
764+
private final Map<Object, StaticRoute> staticPaths = newMap(16);
769765

770766
static <K, V> Map<K, V> newMap(int size) {
771767
return new ConcurrentHashMap<>(size);

jooby/src/main/java/io/jooby/internal/HashValue.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import io.jooby.Context;
99
import io.jooby.FileUpload;
1010
import io.jooby.Formdata;
11-
import io.jooby.Multipart;
1211
import io.jooby.ValueNode;
1312

1413
import javax.annotation.Nonnull;

0 commit comments

Comments
 (0)