Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.net.InetSocketAddress;
import java.net.UnknownHostException;

import static java.lang.System.Logger.Level.DEBUG;
import static java.lang.System.Logger.Level.INFO;

public final class BootstrapServer {
Expand Down Expand Up @@ -67,6 +68,7 @@ static Jex.Server start(Jex jex, SpiRoutes routes) {
"started com.sun.net.httpserver.HttpServer on port {0}://{1}",
scheme,
socketAddress);
log.log(DEBUG, routes);
return new JdkJexServer(server, jex.lifecycle(), handler);
} catch (IOException e) {
throw new UncheckedIOException(e);
Expand Down
5 changes: 5 additions & 0 deletions avaje-jex/src/main/java/io/avaje/jex/routes/RouteEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,9 @@ public boolean literal() {
public Set<Role> roles() {
return roles;
}

@Override
public String toString() {
return path.raw();
}
}
13 changes: 13 additions & 0 deletions avaje-jex/src/main/java/io/avaje/jex/routes/RouteIndex.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.avaje.jex.routes;

import java.util.Arrays;
import java.util.List;

final class RouteIndex {
Expand All @@ -22,6 +23,13 @@ final class RouteIndex {
.toArray(new IndexEntry[0]);
}

@Override
public String toString() {
return "RouteIndex{" + Arrays.toString(entries) +
", wildcards=" + Arrays.toString(wildcardEntries) +
'}';
}

private static IndexEntry toEntry(List<SpiRoutes.Entry> routeEntries) {
return new IndexEntry(routeEntries.toArray(new SpiRoutes.Entry[0]));
}
Expand Down Expand Up @@ -77,6 +85,11 @@ private static final class IndexEntry {
this.pathEntries = pathEntries;
}

@Override
public String toString() {
return Arrays.toString(pathEntries);
}

SpiRoutes.Entry match(String pathInfo) {
for (SpiRoutes.Entry entry : pathEntries) {
if (entry.matches(pathInfo)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import io.avaje.jex.ExchangeHandler;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* Build the RouteIndex.
Expand Down Expand Up @@ -54,7 +51,7 @@ RouteIndex build() {
private static class Entry {

private final List<SpiRoutes.Entry> list = new ArrayList<>();
private final Map<String,List<SpiRoutes.Entry>> pathMap = new HashMap<>();
private final Map<String,List<SpiRoutes.Entry>> pathMap = new LinkedHashMap<>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the bug fix here - LinkedHashMap required.


void add(SpiRoutes.Entry entry) {
if (entry.literal()) {
Expand Down
6 changes: 5 additions & 1 deletion avaje-jex/src/main/java/io/avaje/jex/routes/Routes.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ final class Routes implements SpiRoutes {

private final AtomicLong noRouteCounter = new AtomicLong();


Routes(EnumMap<Routing.Type, RouteIndex> typeMap, List<HttpFilter> filters) {
this.typeMap = typeMap;
this.filters = filters;
}

@Override
public String toString() {
return "Routes{" + typeMap + ", filters=" + filters + '}';
}

@Override
public void inc() {
noRouteCounter.incrementAndGet();
Expand Down