Enhanced RouteMatcher so routes can be updated and removed while in use

•	445552  RouteMatcher throws ConcurrentModificationException if updated while route matching
•	445554  RouteMatcher doesn't support updating a route or removing a route

The preexisting API is unchanged. Two new public methods setUpdatable(boolean) and removePattern(pattern, method) were added. Before updating or removing routes, the setUpdatable(true) should be called and a brief delay should occur to allow any in progress route matching to complete. The setUpdatable method adds try/finally and ReenetrantReadWrite.ReadLock lock/unlock overhead to all route
matching until setUpdatable(false) is called. If the setUpdatable(true) is not called RouteMatcher updates and remove will operate, however, NullPointerExceptions or ConcurrentModificationException will occur if existing routes are being iterated. Comprehensive tests including concurrency tests were added to validate the issue before the changes and validate proper operation after the changes.

If you deem these enhancements too substantial, I recommend adding an interface and changing the name of this class to UpdatableRouteMatcher so that both RouteMatcher features are available for users needs. Searching the Google vertx group revealed at least three separate inquires about route updates or removals from in use RouteMatchers.

Signed-off-by: tcollinsworth <tcollinsworth@axeda.com>
Per your request, all changes have been reformatted to be two space
indentation.

Troy

On Thu, Oct 9, 2014 at 5:28 AM, Tim Fox <notifications@github.com> wrote:

> In vertx-core/src/main/java/org/vertx/java/core/http/RouteMatcher.java:
>
> > @@ -311,7 +329,82 @@ public RouteMatcher noMatch(Handler<HttpServerRequest> handler) {
> >      noMatchHandler = handler;
> >      return this;
> >    }
> > -
> > +
> > +	/**
>
> Indentation should be two spaces in all Vert.x code
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/eclipse/vert.x/pull/926/files#r18634891>.
>