Skip to content

Commit

Permalink
[UNDERTOW-2303] Removed @SInCE tags from JavaDoc. Updated copyright h…
Browse files Browse the repository at this point in the history
…eaders to 2024. Removed synchronisation for toString(). Fixed Spotbugs issues.
  • Loading branch information
dirkroets committed Mar 15, 2024
1 parent 2331e93 commit 2c81f8f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 26 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/io/undertow/server/RoutingHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014 Red Hat, Inc., and individual contributors
* Copyright 2024 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -37,7 +37,7 @@
/**
* A Handler that handles the common case of routing via path template and method name.
*
* @author Dirk Roets [email protected]. This class was originally written by Stuart Douglas. After the introduction
* @author Dirk Roets. This class was originally written by Stuart Douglas. After the introduction
* of {@link PathTemplateRouter}, it was rewritten against the original interface and tests.
*/
public class RoutingHandler implements HttpHandler {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014 Red Hat, Inc., and individual contributors
* Copyright 2024 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -33,9 +33,8 @@
* by instantiating it with a {@link PathTemplateRouter}. This class implements all of the methods from
* the original PathTemplateHandler to provide backwards compatibility.
*
* @author Dirk Roets [email protected]. This class was originally written by Stuart Douglas. After the introduction
* @author Dirk Roets. This class was originally written by Stuart Douglas. After the introduction
* of {@link PathTemplateRouter}, it was rewritten against the original interface and tests.
* @since 2023-07-20
*/
public class PathTemplateHandler implements HttpHandler {

Expand Down Expand Up @@ -135,10 +134,8 @@ public PathTemplateHandler remove(final String uriTemplate) {

@Override
public String toString() {
final List<PathTemplateRouter.PatternEqualsAdapter<PathTemplateRouter.Template<Supplier<HttpHandler>>>> templates;
synchronized (lock) {
templates = new ArrayList<>(builder.getBuilder().getTemplates().keySet());
}
final List<PathTemplateRouter.PatternEqualsAdapter<PathTemplateRouter.Template<Supplier<HttpHandler>>>> templates
= new ArrayList<>(builder.getBuilder().getTemplates().keySet());

final StringBuilder sb = new StringBuilder();
sb.append("path-template( ");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014 Red Hat, Inc., and individual contributors
* Copyright 2024 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -28,8 +28,7 @@
/**
* A handler that matches URI templates.
*
* @author Dirk Roets [email protected]
* @since 2023-07-20
* @author Dirk Roets
* @see PathTemplateRouter
*/
public class PathTemplateRouterHandler implements HttpHandler {
Expand Down Expand Up @@ -59,7 +58,6 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception {
return;
}

final String pathTemplate = routeResult.getPathTemplate().get();
exchange.putAttachment(PATH_TEMPLATE_MATCH, new PathTemplateHandler.PathTemplateMatch(routeResult));
exchange.putAttachment(io.undertow.util.PathTemplateMatch.ATTACHMENT_KEY, routeResult);
if (rewriteQueryParameters && !routeResult.getParameters().isEmpty()) {
Expand Down
14 changes: 5 additions & 9 deletions core/src/main/java/io/undertow/util/PathTemplateRouter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014 Red Hat, Inc., and individual contributors
* Copyright 2024 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -40,8 +40,7 @@
*
* Instances of this class are thread-safe.
*
* @author Dirk Roets [email protected]
* @since 2023-03-07
* @author Dirk Roets
*/
/*
* Warning:
Expand Down Expand Up @@ -1335,7 +1334,6 @@ private static class RouterFactory<T> {
private List<Integer> currentParamIndexes;
private List<String> currentParamNames;
private MatcherLeaveArterfacts<Supplier<? extends T>> currentLeave;
private TemplateSegment currentSegment;
// Resulting matchers.
private Matcher[] matchers;
private Matcher[] wildCardMatchers;
Expand Down Expand Up @@ -1436,7 +1434,6 @@ private MatcherLeaveArterfacts<Supplier<? extends T>> getCurrentRootLeave() {

private void processSegment(final TemplateSegment segment) {
segmentStack.add(segment);
currentSegment = segment;

final PatternEqualsAdapter<TemplateSegment> adapter = new PatternEqualsAdapter<>(segment);
MatcherLeaveArterfacts<Supplier<? extends T>> nextLeave = currentLeave.children.get(adapter);
Expand Down Expand Up @@ -2079,12 +2076,11 @@ public static <T> SimpleBuilder<T> newBuilder(final T defaultTarget) {
/**
* Creates a new instance of the simple builder.
*
* @param <T> Target type for built routes.
*
* @return Reference to the builder.
*/
public static <T> SimpleBuilder<T> newBuilder() {
return newBuilder(null);
public static SimpleBuilder<Void> newBuilder() {
final Builder<Supplier<Void>, Void> builder = Builder.newBuilder();
return new SimpleBuilder<>(builder);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014 Red Hat, Inc., and individual contributors
* Copyright 2024 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -36,8 +36,7 @@
* Some tests that were specifically used to test during the development of {@link PathTemplateRouter} as well as
* an adaptation of the tests in {@link PathTemplateTestCase} to confirm compatibility with {@link PathTemplateMatcher}.
*
* @author Dirk Roets [email protected]
* @since 2023-03-08
* @author Dirk Roets
*/
@Category(UnitTest.class)
public class PathTemplateRouterTest {
Expand Down Expand Up @@ -433,7 +432,7 @@ private static long routeNew(
"default"
);
for (final String template : templates)
routerBuilder.addTemplate(template, ()->template);
routerBuilder.addTemplate(template, () -> template);
final PathTemplateRouter.Router<String> router = routerBuilder.build();

PathTemplateRouter.RouteResult<String> pathRouteResult;
Expand Down

0 comments on commit 2c81f8f

Please sign in to comment.