Skip to content

Commit

Permalink
Use an array to prevent an iterator allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Apr 8, 2015
1 parent bc76a32 commit bc427a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Expand Up @@ -33,18 +33,18 @@
public class NotificationReceiverHandler implements HttpHandler {

private final HttpHandler next;
private final Collection<NotificationReceiver> receivers;
private final NotificationReceiver[] receivers;

public NotificationReceiverHandler(final HttpHandler next, final Collection<NotificationReceiver> receivers) {
this.next = next;
this.receivers = receivers;
this.receivers = receivers.toArray(new NotificationReceiver[receivers.size()]);
}

@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
SecurityContext sc = exchange.getSecurityContext();
for (NotificationReceiver receiver : receivers) {
sc.registerNotificationReceiver(receiver);
for (int i = 0; i < receivers.length; ++i) {
sc.registerNotificationReceiver(receivers[i]);
}

next.handleRequest(exchange);
Expand Down
Expand Up @@ -142,7 +142,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception {
return;
} else if (info.getType() == ServletPathMatch.Type.REWRITE) {
//this can only happen if the path ends with a /
//otherwise there would be a rewrite instead
//otherwise there would be a redirect instead
exchange.setRelativePath(exchange.getRelativePath() + info.getRewriteLocation());
//exchange.setRequestURI(exchange.getRequestURI() + info.getRewriteLocation()); UNDERTOW-348
exchange.setRequestPath(exchange.getRequestPath() + info.getRewriteLocation());
Expand Down

0 comments on commit bc427a0

Please sign in to comment.