Index: 3rdParty_sources/versions.txt =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/versions.txt,v diff -u -r1.11.2.10 -r1.11.2.11 --- 3rdParty_sources/versions.txt 10 Nov 2014 12:07:42 -0000 1.11.2.10 +++ 3rdParty_sources/versions.txt 25 Nov 2014 10:47:02 -0000 1.11.2.11 @@ -46,6 +46,10 @@ Struts 1.2.9 +Undertow core 1.1.0 + +Undertow servlet 1.1.0 + xmltooling 1.4.0 XStream 1.5.0 \ No newline at end of file Index: 3rdParty_sources/undertow/io/undertow/Handlers.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/Attic/Handlers.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/Handlers.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/Handlers.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow; import io.undertow.attribute.ExchangeAttribute; @@ -6,9 +24,11 @@ import io.undertow.predicate.PredicatesHandler; import io.undertow.server.HttpHandler; import io.undertow.server.JvmRouteHandler; +import io.undertow.server.RoutingHandler; import io.undertow.server.handlers.AccessControlListHandler; import io.undertow.server.handlers.DateHandler; import io.undertow.server.handlers.DisableCacheHandler; +import io.undertow.server.handlers.ExceptionHandler; import io.undertow.server.handlers.GracefulShutdownHandler; import io.undertow.server.handlers.HttpContinueAcceptingHandler; import io.undertow.server.handlers.HttpContinueReadHandler; @@ -21,9 +41,11 @@ import io.undertow.server.handlers.PredicateHandler; import io.undertow.server.handlers.ProxyPeerAddressHandler; import io.undertow.server.handlers.RedirectHandler; +import io.undertow.server.handlers.RequestDumpingHandler; import io.undertow.server.handlers.RequestLimit; import io.undertow.server.handlers.RequestLimitingHandler; import io.undertow.server.handlers.ResponseCodeHandler; +import io.undertow.server.handlers.ResponseRateLimitingHandler; import io.undertow.server.handlers.SetAttributeHandler; import io.undertow.server.handlers.SetHeaderHandler; import io.undertow.server.handlers.URLDecodingHandler; @@ -36,6 +58,7 @@ import io.undertow.websockets.WebSocketProtocolHandshakeHandler; import java.util.List; +import java.util.concurrent.TimeUnit; /** * Utility class with convenience methods for dealing with handlers @@ -74,6 +97,23 @@ /** * * @param rewriteQueryParams If the query params should be rewritten + * @return The routing handler + */ + public static RoutingHandler routing(boolean rewriteQueryParams) { + return new RoutingHandler(rewriteQueryParams); + } + + /** + * + * @return a new routing handler + */ + public static RoutingHandler routing() { + return new RoutingHandler(); + } + + /** + * + * @param rewriteQueryParams If the query params should be rewritten * @return The path template handler */ public static PathTemplateHandler pathTemplate(boolean rewriteQueryParams) { @@ -443,6 +483,38 @@ return new DisableCacheHandler(next); } + /** + * Returns a handler that dumps requests to the log for debugging purposes. + * + * @param next The next handler + * @return The request dumping handler + */ + public static HttpHandler requestDump(final HttpHandler next) { + return new RequestDumpingHandler(next); + } + + /** + * Returns a handler that maps exceptions to additional handlers + * @param next The next handler + * @return The exception handler + */ + public static ExceptionHandler exceptionHandler(final HttpHandler next) { + return new ExceptionHandler(next); + } + + /** + * + * A handler that limits the download speed to a set number of bytes/period + * + * @param next The next handler + * @param bytes The number of bytes per time period + * @param time The time period + * @param timeUnit The units of the time period + */ + public static ResponseRateLimitingHandler responseRateLimitingHandler(HttpHandler next, int bytes,long time, TimeUnit timeUnit) { + return new ResponseRateLimitingHandler(next, bytes, time, timeUnit); + } + private Handlers() { } Index: 3rdParty_sources/undertow/io/undertow/Undertow.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/Attic/Undertow.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/Undertow.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/Undertow.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,17 +1,31 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow; -import java.net.Inet4Address; -import java.net.InetSocketAddress; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - -import io.undertow.server.protocol.ajp.AjpOpenListener; import io.undertow.security.api.AuthenticationMode; import io.undertow.security.api.GSSAPIServerSubjectFactory; import io.undertow.security.idm.IdentityManager; import io.undertow.server.HttpHandler; +import io.undertow.server.protocol.ajp.AjpOpenListener; +import io.undertow.server.protocol.http.AlpnOpenListener; import io.undertow.server.protocol.http.HttpOpenListener; +import io.undertow.server.protocol.spdy.SpdyOpenListener; import org.xnio.BufferAllocator; import org.xnio.ByteBufferSlicePool; import org.xnio.ChannelListener; @@ -32,6 +46,11 @@ import javax.net.ssl.KeyManager; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; +import java.net.Inet4Address; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; /** * Convenience class used to build an Undertow server. @@ -47,7 +66,7 @@ private final int ioThreads; private final int workerThreads; private final boolean directBuffers; - private final List listeners = new ArrayList(); + private final List listeners = new ArrayList<>(); private final HttpHandler rootHandler; private final OptionMap workerOptions; private final OptionMap socketOptions; @@ -79,7 +98,7 @@ public synchronized void start() { xnio = Xnio.getInstance(Undertow.class.getClassLoader()); - channels = new ArrayList>(); + channels = new ArrayList<>(); try { worker = xnio.createWorker(OptionMap.builder() .set(Options.WORKER_IO_THREADS, ioThreads) @@ -102,37 +121,54 @@ .getMap(); - Pool buffers = new ByteBufferSlicePool(directBuffers ? BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR : BufferAllocator.BYTE_BUFFER_ALLOCATOR, bufferSize, bufferSize * buffersPerRegion); for (ListenerConfig listener : listeners) { if (listener.type == ListenerType.AJP) { - AjpOpenListener openListener = new AjpOpenListener(buffers, serverOptions, bufferSize); + AjpOpenListener openListener = new AjpOpenListener(buffers, serverOptions); openListener.setRootHandler(rootHandler); ChannelListener> acceptListener = ChannelListeners.openListenerAdapter(openListener); AcceptingChannel server = worker.createStreamConnectionServer(new InetSocketAddress(Inet4Address.getByName(listener.host), listener.port), acceptListener, socketOptions); server.resumeAccepts(); channels.add(server); - } else if (listener.type == ListenerType.HTTP) { - HttpOpenListener openListener = new HttpOpenListener(buffers, OptionMap.builder().set(UndertowOptions.BUFFER_PIPELINED_DATA, true).addAll(serverOptions).getMap(), bufferSize); - openListener.setRootHandler(rootHandler); - ChannelListener> acceptListener = ChannelListeners.openListenerAdapter(openListener); - AcceptingChannel server = worker.createStreamConnectionServer(new InetSocketAddress(Inet4Address.getByName(listener.host), listener.port), acceptListener, socketOptions); - server.resumeAccepts(); - channels.add(server); - } else if (listener.type == ListenerType.HTTPS){ - HttpOpenListener openListener = new HttpOpenListener(buffers, OptionMap.builder().set(UndertowOptions.BUFFER_PIPELINED_DATA, true).addAll(serverOptions).getMap(), bufferSize); - openListener.setRootHandler(rootHandler); - ChannelListener> acceptListener = ChannelListeners.openListenerAdapter(openListener); - XnioSsl xnioSsl; - if(listener.sslContext != null) { - xnioSsl = new JsseXnioSsl(xnio, OptionMap.create(Options.USE_DIRECT_BUFFERS, true), listener.sslContext); - } else { - xnioSsl = xnio.getSslProvider(listener.keyManagers, listener.trustManagers, OptionMap.create(Options.USE_DIRECT_BUFFERS, true)); + } else { + OptionMap undertowOptions = OptionMap.builder().set(UndertowOptions.BUFFER_PIPELINED_DATA, true).addAll(serverOptions).getMap(); + if (listener.type == ListenerType.HTTP) { + HttpOpenListener openListener = new HttpOpenListener(buffers, undertowOptions, bufferSize); + openListener.setRootHandler(rootHandler); + ChannelListener> acceptListener = ChannelListeners.openListenerAdapter(openListener); + AcceptingChannel server = worker.createStreamConnectionServer(new InetSocketAddress(Inet4Address.getByName(listener.host), listener.port), acceptListener, socketOptions); + server.resumeAccepts(); + channels.add(server); + } else if (listener.type == ListenerType.HTTPS) { + ChannelListener openListener; + + HttpOpenListener httpOpenListener = new HttpOpenListener(buffers, undertowOptions); + httpOpenListener.setRootHandler(rootHandler); + + boolean spdy = serverOptions.get(UndertowOptions.ENABLE_SPDY, false); + if(spdy) { + AlpnOpenListener alpn = new AlpnOpenListener(buffers, httpOpenListener); + if(spdy) { + SpdyOpenListener spdyListener = new SpdyOpenListener(buffers, new ByteBufferSlicePool(BufferAllocator.BYTE_BUFFER_ALLOCATOR, 1024, 1024), undertowOptions); + spdyListener.setRootHandler(rootHandler); + alpn.addProtocol(SpdyOpenListener.SPDY_3_1, spdyListener, 5); + } + openListener = alpn; + } else { + openListener = httpOpenListener; + } + ChannelListener> acceptListener = ChannelListeners.openListenerAdapter(openListener); + XnioSsl xnioSsl; + if (listener.sslContext != null) { + xnioSsl = new JsseXnioSsl(xnio, OptionMap.create(Options.USE_DIRECT_BUFFERS, true), listener.sslContext); + } else { + xnioSsl = xnio.getSslProvider(listener.keyManagers, listener.trustManagers, OptionMap.create(Options.USE_DIRECT_BUFFERS, true)); + } + AcceptingChannel sslServer = xnioSsl.createSslConnectionServer(worker, new InetSocketAddress(Inet4Address.getByName(listener.host), listener.port), (ChannelListener) acceptListener, socketOptions); + sslServer.resumeAccepts(); + channels.add(sslServer); } - AcceptingChannel sslServer = xnioSsl.createSslConnectionServer(worker, new InetSocketAddress(Inet4Address.getByName(listener.host), listener.port), (ChannelListener) acceptListener, socketOptions); - sslServer.resumeAccepts(); - channels.add(sslServer); } } @@ -153,7 +189,6 @@ } - public static enum ListenerType { HTTP, HTTPS, @@ -176,6 +211,7 @@ this.trustManagers = trustManagers; this.sslContext = null; } + private ListenerConfig(final ListenerType type, final int port, final String host, SSLContext sslContext) { this.type = type; this.port = port; @@ -254,7 +290,7 @@ private int ioThreads; private int workerThreads; private boolean directBuffers; - private final List listeners = new ArrayList(); + private final List listeners = new ArrayList<>(); private HttpHandler handler; private final OptionMap.Builder workerOptions = OptionMap.builder(); @@ -311,7 +347,6 @@ return this; } - public Builder addAjpListener(int port, String host) { listeners.add(new ListenerConfig(ListenerType.AJP, port, host, null, null)); return this; Index: 3rdParty_sources/undertow/io/undertow/UndertowLogger.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/Attic/UndertowLogger.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/UndertowLogger.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/UndertowLogger.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow; @@ -142,6 +142,14 @@ void couldNotRegisterChangeListener(@Cause Exception e); @LogMessage(level = Logger.Level.ERROR) + @Message(id = 5025, value = "Could not initiate SPDY connection and no HTTP fallback defined") + void couldNotInitiateSpdyConnection(); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 5026, value = "Jetty ALPN support not found on boot class path, %s client will not be available.") + void jettyALPNNotFound(String protocol); + + @LogMessage(level = Logger.Level.ERROR) @Message(id = 5027, value = "Timing out request to %s") void timingOutRequest(String requestURI); @@ -156,4 +164,24 @@ @LogMessage(level = Logger.Level.ERROR) @Message(id = 5031, value = "Proxy request to %s could not connect to backend server %s") void proxyFailedToConnectToBackend(String requestURI, URI uri); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 5032, value = "Listener not making progress on framed channel, closing channel to prevent infinite loop") + void listenerNotProgressing(); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 5033, value = "Failed to initiate HTTP2 connection") + void couldNotInitiateHttp2Connection(); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 5034, value = "Remote endpoint failed to send initial settings frame in HTTP2 connection") + void remoteEndpointFailedToSendInitialSettings(); + + @LogMessage(level = Logger.Level.DEBUG) + @Message(id = 5035, value = "Closing channel because of parse timeout for remote address %s") + void parseRequestTimedOut(java.net.SocketAddress remoteAddress); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 5036, value = "ALPN negotiation failed for %s and no fallback defined, closing connection") + void noALPNFallback(SocketAddress address); } Index: 3rdParty_sources/undertow/io/undertow/UndertowMessages.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/Attic/UndertowMessages.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/UndertowMessages.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/UndertowMessages.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow; @@ -220,7 +220,7 @@ IllegalStateException fileSystemWatcherNotStarted(); @Message(id = 65, value = "SSL must be specified to connect to a https URL") - IllegalArgumentException sslWasNull(); + IOException sslWasNull(); @Message(id = 66, value = "Incorrect magic number for AJP packet header") IOException wrongMagicNumber(); @@ -282,6 +282,88 @@ @Message(id = 85, value = "Could not generate unique session id") RuntimeException couldNotGenerateUniqueSessionId(); + @Message(id = 86, value = "SPDY needs to be provided with a heap buffer pool, for use in compressing and decompressing headers.") + IllegalArgumentException mustProvideHeapBuffer(); + + @Message(id = 87, value = "Unexpected SPDY frame type %s") + IOException unexpectedFrameType(int type); + + @Message(id = 88, value = "SPDY control frames cannot have body content") + IOException controlFrameCannotHaveBodyContent(); + + @Message(id = 89, value = "SPDY not supported") + IOException spdyNotSupported(); + + @Message(id = 90, value = "Jetty NPN not available") + IOException jettyNPNNotAvailable(); + @Message(id = 91, value = "Buffer has already been freed") IllegalStateException bufferAlreadyFreed(); + + @Message(id = 92, value = "A SPDY header was too large to fit in a response buffer, if you want to support larger headers please increase the buffer size") + IllegalStateException headersTooLargeToFitInHeapBuffer(); + + @Message(id = 93, value = "A SPDY stream was reset by the remote endpoint") + IOException spdyStreamWasReset(); + + @Message(id = 94, value = "Blocking await method called from IO thread. Blocking IO must be dispatched to a worker thread or deadlocks will result.") + IOException awaitCalledFromIoThread(); + + @Message(id = 95, value = "Recursive call to flushSenders()") + RuntimeException recursiveCallToFlushingSenders(); + + @Message(id = 96, value = "More data was written to the channel than specified in the content-length") + IllegalStateException fixedLengthOverflow(); + + @Message(id = 97, value = "AJP request already in progress") + IllegalStateException ajpRequestAlreadyInProgress(); + + @Message(id = 98, value = "HTTP ping data must be 8 bytes in length") + IllegalArgumentException httpPingDataMustBeLength8(); + + @Message(id = 99, value = "Received a ping of size other than 8") + String invalidPingSize(); + + @Message(id = 100, value = "stream id must be zero for frame type %s") + String streamIdMustBeZeroForFrameType(int frameType); + + @Message(id = 101, value = "stream id must not be zero for frame type %s") + String streamIdMustNotBeZeroForFrameType(int frameType); + + @Message(id = 102, value = "RST_STREAM received for idle stream") + String rstStreamReceivedForIdleStream(); + + @Message(id = 103, value = "Http2 stream was reset") + IOException http2StreamWasReset(); + + @Message(id = 104, value = "Incorrect HTTP2 preface") + IOException incorrectHttp2Preface(); + + @Message(id = 105, value = "HTTP2 frame to large") + IOException http2FrameTooLarge(); + + @Message(id = 106, value = "HTTP2 continuation frame received without a corresponding headers or push promise frame") + IOException http2ContinuationFrameNotExpected(); + + //@Message(id = 107, value = "Huffman encoded value in HPACK headers did not end with EOS padding") + //HpackException huffmanEncodedHpackValueDidNotEndWithEOS(); + + //@Message(id = 108, value = "HPACK variable length integer encoded over too many octects, max is %s") + //HpackException integerEncodedOverTooManyOctets(int maxIntegerOctets); + + //@Message(id = 109, value = "Zero is not a valid header table index") + //HpackException zeroNotValidHeaderTableIndex(); + + + @Message(id = 110, value = "Cannot send 100-Continue, getResponseChannel() has already been called") + IOException cannotSendContinueResponse(); + + @Message(id = 111, value = "Parser did not make progress") + IOException parserDidNotMakeProgress(); + + @Message(id = 112, value = "Only client side can call createStream, if you wish to send a PUSH_PROMISE frame use createPushPromiseStream instead") + IOException headersStreamCanOnlyBeCreatedByClient(); + + @Message(id = 114, value = "Invalid IP access control rule %s. Format is: [ip-match] allow|deny") + IllegalArgumentException invalidAclRule(String rule); } Index: 3rdParty_sources/undertow/io/undertow/UndertowOptions.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/Attic/UndertowOptions.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/UndertowOptions.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/UndertowOptions.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow; @@ -51,10 +51,26 @@ /** * The idle timeout in milliseconds after which the channel will be closed. + * + * If the underlying channel already has a read or write timeout set the smaller of the two values will be used + * for read/write timeouts. + * */ - public static final Option IDLE_TIMEOUT = Option.simple(UndertowOptions.class, "IDLE_TIMEOUT", Long.class); + public static final Option IDLE_TIMEOUT = Option.simple(UndertowOptions.class, "IDLE_TIMEOUT", Integer.class); /** + * The maximum allowed time of reading HTTP request in milliseconds. + * + * -1 or missing value disables this functionality. + */ + public static final Option REQUEST_PARSE_TIMEOUT = Option.simple(UndertowOptions.class, "REQUEST_PARSE_TIMEOUT", Integer.class); + + /** + * The amount of time the connection can be idle with no current requests before it is closed; + */ + public static final Option NO_REQUEST_TIMEOUT = Option.simple(UndertowOptions.class, "NO_REQUEST_TIMEOUT", Integer.class); + + /** * The maximum number of parameters that will be parsed. This is used to protect against hash vulnerabilities. *

* This applies to both query parameters, and to POST data, but is not cumulative (i.e. you can potentially have @@ -152,6 +168,11 @@ */ public static final Option ALLOW_EQUALS_IN_COOKIE_VALUE = Option.simple(UndertowOptions.class, "ALLOW_EQUALS_IN_COOKIE_VALUE", Boolean.class); + /** + * If we should attempt to use SPDY for HTTPS connections. + */ + public static final Option ENABLE_SPDY = Option.simple(UndertowOptions.class, "ENABLE_SPDY", Boolean.class); + private UndertowOptions() { } Index: 3rdParty_sources/undertow/io/undertow/Version.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/Attic/Version.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/Version.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/Version.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow; import java.util.Properties; Index: 3rdParty_sources/undertow/io/undertow/attribute/BytesSentAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/BytesSentAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/BytesSentAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/BytesSentAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -22,10 +40,10 @@ @Override public String readAttribute(final HttpServerExchange exchange) { if (attribute.equals(BYTES_SENT_SHORT_LOWER)) { - long bytesSent = exchange.getResponseContentLength(); + long bytesSent = exchange.getResponseBytesSent(); return bytesSent == 0 ? "-" : Long.toString(bytesSent); } else { - return Long.toString(exchange.getResponseContentLength()); + return Long.toString(exchange.getResponseBytesSent()); } } @@ -48,5 +66,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/CompositeExchangeAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/CompositeExchangeAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/CompositeExchangeAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/CompositeExchangeAttribute.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/attribute/ConstantExchangeAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/ConstantExchangeAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/ConstantExchangeAttribute.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/ConstantExchangeAttribute.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/attribute/CookieAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/CookieAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/CookieAttribute.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/CookieAttribute.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -46,5 +64,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/DateTimeAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/DateTimeAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/DateTimeAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/DateTimeAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import java.util.Date; @@ -45,5 +63,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/ExchangeAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttribute.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttributeBuilder.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/ExchangeAttributeBuilder.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttributeBuilder.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttributeBuilder.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.attribute; @@ -43,4 +43,11 @@ */ ExchangeAttribute build(final String token); + /** + * The priority of the builder. Builders will be tried in priority builder. Built in builders use the priority range 0-100, + * + * @return The priority + */ + int priority(); + } Index: 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttributeParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/ExchangeAttributeParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttributeParser.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttributeParser.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,7 +1,26 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.ServiceLoader; @@ -25,10 +44,17 @@ ExchangeAttributeParser(final ClassLoader classLoader, List wrappers) { this.wrappers = wrappers; ServiceLoader loader = ServiceLoader.load(ExchangeAttributeBuilder.class, classLoader); - final List builders = new ArrayList(); + final List builders = new ArrayList<>(); for (ExchangeAttributeBuilder instance : loader) { builders.add(instance); } + //sort with highest priority first + Collections.sort(builders, new Comparator() { + @Override + public int compare(ExchangeAttributeBuilder o1, ExchangeAttributeBuilder o2) { + return Integer.compare(o2.priority(), o1.priority()); + } + }); this.builders = Collections.unmodifiableList(builders); } @@ -46,7 +72,7 @@ * @return */ public ExchangeAttribute parse(final String valueString) { - final List attributes = new ArrayList(); + final List attributes = new ArrayList<>(); int pos = 0; int state = 0; //0 = literal, 1 = %, 2 = %{, 3 = $, 4 = ${ for (int i = 0; i < valueString.length(); ++i) { Index: 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttributes.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/ExchangeAttributes.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttributes.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/ExchangeAttributes.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/attribute/IdentUsernameAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/IdentUsernameAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/IdentUsernameAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/IdentUsernameAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -41,5 +59,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/LocalIPAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/LocalIPAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/LocalIPAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/LocalIPAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import java.net.InetSocketAddress; @@ -45,5 +63,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/LocalPortAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/LocalPortAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/LocalPortAttribute.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/LocalPortAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import java.net.InetSocketAddress; @@ -45,5 +63,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/LocalServerNameAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/LocalServerNameAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/LocalServerNameAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/LocalServerNameAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -43,5 +61,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/attribute/PathParameterAttribute.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/attribute/PredicateContextAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/PredicateContextAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/PredicateContextAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/PredicateContextAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import java.util.Map; @@ -50,5 +68,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/QueryParameterAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/QueryParameterAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/QueryParameterAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/QueryParameterAttribute.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -44,7 +62,7 @@ @Override public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException { - final ArrayDeque value = new ArrayDeque(); + final ArrayDeque value = new ArrayDeque<>(); value.add(newValue); exchange.getQueryParameters().put(parameter, value); } @@ -64,5 +82,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/QueryStringAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/QueryStringAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/QueryStringAttribute.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/QueryStringAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -20,7 +38,11 @@ @Override public String readAttribute(final HttpServerExchange exchange) { - return exchange.getQueryString(); + String qs = exchange.getQueryString(); + if(qs.isEmpty()) { + return qs; + } + return '?' + qs; } @Override @@ -42,5 +64,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/ReadOnlyAttributeException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/ReadOnlyAttributeException.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/ReadOnlyAttributeException.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/ReadOnlyAttributeException.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.UndertowMessages; Index: 3rdParty_sources/undertow/io/undertow/attribute/RelativePathAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/RelativePathAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/RelativePathAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/RelativePathAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -39,7 +57,7 @@ final String newQueryString = newValue.substring(pos); exchange.setQueryString(newQueryString); - exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1))); + exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(exchange))); } } @@ -54,5 +72,10 @@ public ExchangeAttribute build(final String token) { return token.equals(RELATIVE_PATH) || token.equals(RELATIVE_PATH_SHORT) ? INSTANCE : null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/RemoteIPAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/RemoteIPAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/RemoteIPAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/RemoteIPAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import java.net.InetSocketAddress; @@ -46,5 +64,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/RemoteUserAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/RemoteUserAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/RemoteUserAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/RemoteUserAttribute.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.security.api.SecurityContext; @@ -47,5 +65,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/RequestHeaderAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/RequestHeaderAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/RequestHeaderAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/RequestHeaderAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -42,5 +60,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/RequestLineAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/RequestLineAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/RequestLineAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/RequestLineAttribute.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -20,12 +38,17 @@ @Override public String readAttribute(final HttpServerExchange exchange) { - return new StringBuilder() + StringBuilder sb = new StringBuilder() .append(exchange.getRequestMethod().toString()) .append(' ') - .append(exchange.getRequestURI()) - .append(' ') + .append(exchange.getRequestURI()); + if (!exchange.getQueryString().isEmpty()) { + sb.append('?'); + sb.append(exchange.getQueryString()); + } + sb.append(' ') .append(exchange.getProtocol().toString()).toString(); + return sb.toString(); } @Override @@ -47,5 +70,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/RequestMethodAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/RequestMethodAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/RequestMethodAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/RequestMethodAttribute.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -42,5 +60,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/RequestProtocolAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/RequestProtocolAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/RequestProtocolAttribute.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/RequestProtocolAttribute.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -42,5 +60,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/RequestURLAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/RequestURLAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/RequestURLAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/RequestURLAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -40,7 +58,7 @@ exchange.setResolvedPath(""); final String newQueryString = newValue.substring(pos); exchange.setQueryString(newQueryString); - exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1))); + exchange.getQueryParameters().putAll(QueryParameterUtils.parseQueryString(newQueryString.substring(1), QueryParameterUtils.getQueryParamEncoding(exchange))); } } @@ -59,5 +77,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/ResponseCodeAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/ResponseCodeAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/ResponseCodeAttribute.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/ResponseCodeAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -42,5 +60,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/ResponseHeaderAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/ResponseHeaderAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/ResponseHeaderAttribute.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/ResponseHeaderAttribute.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -42,5 +60,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/ResponseTimeAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/ResponseTimeAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/ResponseTimeAttribute.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/ResponseTimeAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -52,6 +70,11 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/SslCipherAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/SslCipherAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/SslCipherAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/SslCipherAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -38,5 +56,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/SslClientCertAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/SslClientCertAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/SslClientCertAttribute.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/SslClientCertAttribute.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -57,5 +75,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/SslSessionIdAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/SslSessionIdAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/SslSessionIdAttribute.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/SslSessionIdAttribute.java 25 Nov 2014 10:46:56 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -39,5 +57,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/attribute/ThreadNameAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/attribute/Attic/ThreadNameAttribute.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/attribute/ThreadNameAttribute.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/attribute/ThreadNameAttribute.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.attribute; import io.undertow.server.HttpServerExchange; @@ -42,5 +60,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Index: 3rdParty_sources/undertow/io/undertow/channels/DelegatingStreamSinkChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/channels/Attic/DelegatingStreamSinkChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/channels/DelegatingStreamSinkChannel.java 8 Sep 2014 10:52:16 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/channels/DelegatingStreamSinkChannel.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.channels; import java.io.IOException; @@ -20,8 +38,8 @@ public abstract class DelegatingStreamSinkChannel implements StreamSinkChannel { protected final StreamSinkChannel delegate; - protected final ChannelListener.SimpleSetter writeSetter = new ChannelListener.SimpleSetter(); - protected final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter(); + protected final ChannelListener.SimpleSetter writeSetter = new ChannelListener.SimpleSetter<>(); + protected final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter<>(); public DelegatingStreamSinkChannel(final StreamSinkChannel delegate) { this.delegate = delegate; Index: 3rdParty_sources/undertow/io/undertow/channels/DelegatingStreamSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/channels/Attic/DelegatingStreamSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/channels/DelegatingStreamSourceChannel.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/channels/DelegatingStreamSourceChannel.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.channels; import java.io.IOException; @@ -19,8 +37,8 @@ */ public abstract class DelegatingStreamSourceChannel implements StreamSourceChannel { - protected final ChannelListener.SimpleSetter readSetter = new ChannelListener.SimpleSetter(); - protected final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter(); + protected final ChannelListener.SimpleSetter readSetter = new ChannelListener.SimpleSetter<>(); + protected final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter<>(); protected final StreamSourceChannel delegate; public DelegatingStreamSourceChannel(final StreamSourceChannel delegate) { Index: 3rdParty_sources/undertow/io/undertow/channels/DetachableStreamSinkChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/channels/Attic/DetachableStreamSinkChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/channels/DetachableStreamSinkChannel.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/channels/DetachableStreamSinkChannel.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.channels; import io.undertow.UndertowMessages; @@ -25,11 +43,11 @@ public abstract class DetachableStreamSinkChannel implements StreamSinkChannel { - protected final ConduitStreamSinkChannel delegate; + protected final StreamSinkChannel delegate; protected ChannelListener.SimpleSetter writeSetter; protected ChannelListener.SimpleSetter closeSetter; - public DetachableStreamSinkChannel(final ConduitStreamSinkChannel delegate) { + public DetachableStreamSinkChannel(final StreamSinkChannel delegate) { this.delegate = delegate; } @@ -119,9 +137,13 @@ @Override public ChannelListener.Setter getWriteSetter() { if (writeSetter == null) { - writeSetter = new ChannelListener.SimpleSetter(); + writeSetter = new ChannelListener.SimpleSetter<>(); if (!isFinished()) { - delegate.setWriteListener(ChannelListeners.delegatingChannelListener(this, writeSetter)); + if(delegate instanceof ConduitStreamSinkChannel) { + ((ConduitStreamSinkChannel) delegate).setWriteListener(ChannelListeners.delegatingChannelListener(this, writeSetter)); + } else { + delegate.getWriteSetter().set(ChannelListeners.delegatingChannelListener(this, writeSetter)); + } } } return writeSetter; @@ -130,9 +152,9 @@ @Override public ChannelListener.Setter getCloseSetter() { if (closeSetter == null) { - closeSetter = new ChannelListener.SimpleSetter(); + closeSetter = new ChannelListener.SimpleSetter<>(); if (!isFinished()) { - delegate.setCloseListener(ChannelListeners.delegatingChannelListener(this, closeSetter)); + delegate.getCloseSetter().set(ChannelListeners.delegatingChannelListener(this, closeSetter)); } } return closeSetter; @@ -234,8 +256,13 @@ } public void responseDone() { - delegate.setCloseListener(null); - delegate.setWriteListener(null); + if(delegate instanceof ConduitStreamSinkChannel) { + ((ConduitStreamSinkChannel) delegate).setCloseListener(null); + ((ConduitStreamSinkChannel) delegate).setWriteListener(null); + } else { + delegate.getCloseSetter().set(null); + delegate.getWriteSetter().set(null); + } if (delegate.isWriteResumed()) { delegate.suspendWrites(); } Index: 3rdParty_sources/undertow/io/undertow/channels/DetachableStreamSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/channels/Attic/DetachableStreamSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/channels/DetachableStreamSourceChannel.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/channels/DetachableStreamSourceChannel.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,27 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.channels; -import io.undertow.UndertowMessages; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.util.concurrent.TimeUnit; import org.xnio.ChannelListener; import org.xnio.ChannelListeners; import org.xnio.Option; @@ -11,10 +32,7 @@ import org.xnio.channels.StreamSourceChannel; import org.xnio.conduits.ConduitStreamSourceChannel; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.util.concurrent.TimeUnit; +import io.undertow.UndertowMessages; /** * A stream source channel that can be marked as detached. Once this is marked as detached then @@ -24,12 +42,12 @@ */ public abstract class DetachableStreamSourceChannel implements StreamSourceChannel{ - protected final ConduitStreamSourceChannel delegate; + protected final StreamSourceChannel delegate; protected ChannelListener.SimpleSetter readSetter; protected ChannelListener.SimpleSetter closeSetter; - public DetachableStreamSourceChannel(final ConduitStreamSourceChannel delegate) { + public DetachableStreamSourceChannel(final StreamSourceChannel delegate) { this.delegate = delegate; } @@ -103,9 +121,13 @@ public ChannelListener.Setter getReadSetter() { if (readSetter == null) { - readSetter = new ChannelListener.SimpleSetter(); + readSetter = new ChannelListener.SimpleSetter<>(); if (!isFinished()) { - delegate.setReadListener(ChannelListeners.delegatingChannelListener(this, readSetter)); + if(delegate instanceof ConduitStreamSourceChannel) { + ((ConduitStreamSourceChannel)delegate).setReadListener(ChannelListeners.delegatingChannelListener(this, readSetter)); + } else { + delegate.getReadSetter().set(ChannelListeners.delegatingChannelListener(this, readSetter)); + } } } return readSetter; @@ -152,9 +174,13 @@ public ChannelListener.Setter getCloseSetter() { if (closeSetter == null) { - closeSetter = new ChannelListener.SimpleSetter(); + closeSetter = new ChannelListener.SimpleSetter<>(); if (!isFinished()) { - delegate.setCloseListener(ChannelListeners.delegatingChannelListener(this, closeSetter)); + if(delegate instanceof ConduitStreamSourceChannel) { + ((ConduitStreamSourceChannel)delegate).setCloseListener(ChannelListeners.delegatingChannelListener(this, closeSetter)); + } else { + delegate.getCloseSetter().set(ChannelListeners.delegatingChannelListener(this, closeSetter)); + } } } return closeSetter; Index: 3rdParty_sources/undertow/io/undertow/channels/GatedStreamSinkChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/channels/Attic/GatedStreamSinkChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/channels/GatedStreamSinkChannel.java 8 Sep 2014 10:52:16 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/channels/GatedStreamSinkChannel.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.channels; @@ -48,8 +48,8 @@ */ public final class GatedStreamSinkChannel implements StreamSinkChannel { private final StreamSinkChannel delegate; - private final ChannelListener.SimpleSetter writeSetter = new ChannelListener.SimpleSetter(); - private final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter(); + private final ChannelListener.SimpleSetter writeSetter = new ChannelListener.SimpleSetter<>(); + private final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter<>(); /** * Construct a new instance. Index: 3rdParty_sources/undertow/io/undertow/channels/GatedStreamSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/channels/Attic/GatedStreamSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/channels/GatedStreamSourceChannel.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/channels/GatedStreamSourceChannel.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.channels; @@ -47,8 +47,8 @@ */ public final class GatedStreamSourceChannel implements StreamSourceChannel { private final StreamSourceChannel delegate; - private final ChannelListener.SimpleSetter readSetter = new ChannelListener.SimpleSetter(); - private final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter(); + private final ChannelListener.SimpleSetter readSetter = new ChannelListener.SimpleSetter<>(); + private final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter<>(); /** * Construct a new instance. Index: 3rdParty_sources/undertow/io/undertow/channels/ReadTimeoutStreamSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/channels/Attic/ReadTimeoutStreamSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/channels/ReadTimeoutStreamSourceChannel.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/channels/ReadTimeoutStreamSourceChannel.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.channels; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/channels/WriteTimeoutStreamSinkChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/channels/Attic/WriteTimeoutStreamSinkChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/channels/WriteTimeoutStreamSinkChannel.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/channels/WriteTimeoutStreamSinkChannel.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.channels; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/client/ClientCallback.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/Attic/ClientCallback.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/ClientCallback.java 8 Sep 2014 10:52:09 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/ClientCallback.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/client/ClientConnection.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/Attic/ClientConnection.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/ClientConnection.java 8 Sep 2014 10:52:09 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/ClientConnection.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client; import org.xnio.ChannelListener; Index: 3rdParty_sources/undertow/io/undertow/client/ClientExchange.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/Attic/ClientExchange.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/ClientExchange.java 8 Sep 2014 10:52:09 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/ClientExchange.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client; import io.undertow.util.Attachable; Index: 3rdParty_sources/undertow/io/undertow/client/ClientProvider.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/Attic/ClientProvider.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/ClientProvider.java 8 Sep 2014 10:52:09 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/ClientProvider.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client; import org.xnio.OptionMap; @@ -6,6 +24,7 @@ import org.xnio.XnioWorker; import org.xnio.ssl.XnioSsl; +import java.net.InetSocketAddress; import java.net.URI; import java.nio.ByteBuffer; import java.util.Set; @@ -22,6 +41,10 @@ void connect(final ClientCallback listener, final URI uri, final XnioWorker worker, XnioSsl ssl, Pool bufferPool, OptionMap options); + void connect(final ClientCallback listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, XnioSsl ssl, Pool bufferPool, OptionMap options); + void connect(final ClientCallback listener, final URI uri, final XnioIoThread ioThread, XnioSsl ssl, Pool bufferPool, OptionMap options); + void connect(final ClientCallback listener, InetSocketAddress bindAddress, final URI uri, final XnioIoThread ioThread, XnioSsl ssl, Pool bufferPool, OptionMap options); + } Index: 3rdParty_sources/undertow/io/undertow/client/ClientRequest.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/Attic/ClientRequest.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/ClientRequest.java 8 Sep 2014 10:52:09 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/ClientRequest.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client; import io.undertow.util.AbstractAttachable; Index: 3rdParty_sources/undertow/io/undertow/client/ClientResponse.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/Attic/ClientResponse.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/ClientResponse.java 8 Sep 2014 10:52:09 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/ClientResponse.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client; import io.undertow.util.AbstractAttachable; Index: 3rdParty_sources/undertow/io/undertow/client/ContinueNotification.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/Attic/ContinueNotification.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/ContinueNotification.java 8 Sep 2014 10:52:09 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/ContinueNotification.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client; /** Index: 3rdParty_sources/undertow/io/undertow/client/ProxiedRequestAttachments.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/Attic/ProxiedRequestAttachments.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/ProxiedRequestAttachments.java 8 Sep 2014 10:52:09 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/ProxiedRequestAttachments.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client; import io.undertow.util.AttachmentKey; @@ -23,6 +41,5 @@ public static final AttachmentKey SSL_SESSION_ID = AttachmentKey.create(byte[].class); public static final AttachmentKey SSL_KEY_SIZE = AttachmentKey.create(Integer.class); public static final AttachmentKey SECRET = AttachmentKey.create(String.class); - public static final AttachmentKey STORED_METHOD = AttachmentKey.create(String.class); } Index: 3rdParty_sources/undertow/io/undertow/client/UndertowClient.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/Attic/UndertowClient.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/UndertowClient.java 8 Sep 2014 10:52:09 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/UndertowClient.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client; import org.xnio.FutureResult; @@ -6,8 +24,10 @@ import org.xnio.Pool; import org.xnio.XnioIoThread; import org.xnio.XnioWorker; +import org.xnio.ssl.XnioSsl; import java.io.IOException; +import java.net.InetSocketAddress; import java.net.URI; import java.nio.ByteBuffer; import java.util.Collections; @@ -33,7 +53,7 @@ private UndertowClient(final ClassLoader classLoader) { ServiceLoader providers = ServiceLoader.load(ClientProvider.class, classLoader); - final Map map = new HashMap(); + final Map map = new HashMap<>(); for (ClientProvider provider : providers) { for (String scheme : provider.handlesSchemes()) { map.put(scheme, provider); @@ -43,8 +63,20 @@ } public IoFuture connect(final URI uri, final XnioWorker worker, Pool bufferPool, OptionMap options) { + return connect(uri, worker, null, bufferPool, options); + } + + public IoFuture connect(InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, Pool bufferPool, OptionMap options) { + return connect(bindAddress, uri, worker, null, bufferPool, options); + } + + public IoFuture connect(final URI uri, final XnioWorker worker, XnioSsl ssl, Pool bufferPool, OptionMap options) { + return connect((InetSocketAddress) null, uri, worker, ssl, bufferPool, options); + } + + public IoFuture connect(InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, XnioSsl ssl, Pool bufferPool, OptionMap options) { ClientProvider provider = getClientProvider(uri); - final FutureResult result = new FutureResult(); + final FutureResult result = new FutureResult<>(); provider.connect(new ClientCallback() { @Override public void completed(ClientConnection r) { @@ -55,14 +87,26 @@ public void failed(IOException e) { result.setException(e); } - }, uri, worker, null, bufferPool, options - ); + }, bindAddress, uri, worker, ssl, bufferPool, options); return result.getIoFuture(); } public IoFuture connect(final URI uri, final XnioIoThread ioThread, Pool bufferPool, OptionMap options) { + return connect((InetSocketAddress) null, uri, ioThread, null, bufferPool, options); + } + + + public IoFuture connect(InetSocketAddress bindAddress, final URI uri, final XnioIoThread ioThread, Pool bufferPool, OptionMap options) { + return connect(bindAddress, uri, ioThread, null, bufferPool, options); + } + + public IoFuture connect(final URI uri, final XnioIoThread ioThread, XnioSsl ssl, Pool bufferPool, OptionMap options) { + return connect((InetSocketAddress) null, uri, ioThread, ssl, bufferPool, options); + } + + public IoFuture connect(InetSocketAddress bindAddress, final URI uri, final XnioIoThread ioThread, XnioSsl ssl, Pool bufferPool, OptionMap options) { ClientProvider provider = getClientProvider(uri); - final FutureResult result = new FutureResult(); + final FutureResult result = new FutureResult<>(); provider.connect(new ClientCallback() { @Override public void completed(ClientConnection r) { @@ -73,22 +117,47 @@ public void failed(IOException e) { result.setException(e); } - }, uri, ioThread, null, bufferPool, options - ); + }, bindAddress, uri, ioThread, ssl, bufferPool, options); return result.getIoFuture(); } - public void connect(final ClientCallback listener, final URI uri, final XnioWorker worker, Pool bufferPool, OptionMap options) { + connect(listener, uri, worker, null, bufferPool, options); + } + + public void connect(final ClientCallback listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, Pool bufferPool, OptionMap options) { + connect(listener, bindAddress, uri, worker, null, bufferPool, options); + } + + public void connect(final ClientCallback listener, final URI uri, final XnioWorker worker, XnioSsl ssl, Pool bufferPool, OptionMap options) { ClientProvider provider = getClientProvider(uri); - provider.connect(listener, uri, worker, null, bufferPool, options); + provider.connect(listener, uri, worker, ssl, bufferPool, options); } + public void connect(final ClientCallback listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, XnioSsl ssl, Pool bufferPool, OptionMap options) { + ClientProvider provider = getClientProvider(uri); + provider.connect(listener, bindAddress, uri, worker, ssl, bufferPool, options); + } + public void connect(final ClientCallback listener, final URI uri, final XnioIoThread ioThread, Pool bufferPool, OptionMap options) { + connect(listener, uri, ioThread, null, bufferPool, options); + } + + + public void connect(final ClientCallback listener, InetSocketAddress bindAddress, final URI uri, final XnioIoThread ioThread, Pool bufferPool, OptionMap options) { + connect(listener, bindAddress, uri, ioThread, null, bufferPool, options); + } + + public void connect(final ClientCallback listener, final URI uri, final XnioIoThread ioThread, XnioSsl ssl, Pool bufferPool, OptionMap options) { ClientProvider provider = getClientProvider(uri); - provider.connect(listener, uri, ioThread, null, bufferPool, options); + provider.connect(listener, uri, ioThread, ssl, bufferPool, options); } + public void connect(final ClientCallback listener, InetSocketAddress bindAddress, final URI uri, final XnioIoThread ioThread, XnioSsl ssl, Pool bufferPool, OptionMap options) { + ClientProvider provider = getClientProvider(uri); + provider.connect(listener, bindAddress, uri, ioThread, ssl, bufferPool, options); + } + private ClientProvider getClientProvider(URI uri) { ClientProvider provider = clientProviders.get(uri.getScheme()); if (provider == null) { Index: 3rdParty_sources/undertow/io/undertow/client/UndertowClientMessages.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/Attic/UndertowClientMessages.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/UndertowClientMessages.java 8 Sep 2014 10:52:09 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/UndertowClientMessages.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client; import io.undertow.util.HttpString; Index: 3rdParty_sources/undertow/io/undertow/client/ajp/AjpClientConnection.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/ajp/Attic/AjpClientConnection.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/ajp/AjpClientConnection.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/ajp/AjpClientConnection.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,101 +1,89 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012, Red Hat, Inc., and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * http://www.apache.org/licenses/LICENSE-2.0 * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.client.ajp; -import io.undertow.UndertowLogger; -import io.undertow.client.ClientCallback; -import io.undertow.client.ClientConnection; -import io.undertow.client.ClientExchange; -import io.undertow.client.ClientRequest; -import io.undertow.client.ClientResponse; -import io.undertow.client.UndertowClientMessages; -import io.undertow.conduits.ConduitListener; -import io.undertow.util.AbstractAttachable; -import io.undertow.util.Protocols; +import static io.undertow.util.Headers.CLOSE; +import static io.undertow.util.Headers.CONNECTION; +import static io.undertow.util.Headers.CONTENT_LENGTH; +import static io.undertow.util.Headers.TRANSFER_ENCODING; +import static io.undertow.util.Headers.UPGRADE; +import static org.xnio.Bits.anyAreSet; +import static org.xnio.IoUtils.safeClose; + +import java.io.Closeable; +import java.io.IOException; +import java.net.SocketAddress; +import java.nio.ByteBuffer; +import java.util.ArrayDeque; +import java.util.Deque; import org.xnio.ChannelExceptionHandler; import org.xnio.ChannelListener; import org.xnio.ChannelListeners; -import org.xnio.IoUtils; import org.xnio.Option; import org.xnio.OptionMap; import org.xnio.Pool; -import org.xnio.Pooled; import org.xnio.StreamConnection; import org.xnio.XnioIoThread; import org.xnio.XnioWorker; +import org.xnio.channels.Channels; import org.xnio.channels.StreamSinkChannel; -import org.xnio.channels.StreamSourceChannel; -import org.xnio.conduits.ConduitStreamSinkChannel; -import org.xnio.conduits.ConduitStreamSourceChannel; -import org.xnio.conduits.PushBackStreamSourceConduit; -import org.xnio.conduits.StreamSinkConduit; -import org.xnio.conduits.StreamSourceConduit; -import java.io.Closeable; -import java.io.IOException; -import java.net.SocketAddress; -import java.nio.ByteBuffer; -import java.util.ArrayDeque; -import java.util.Deque; +import io.undertow.UndertowLogger; +import io.undertow.UndertowMessages; +import io.undertow.client.ClientCallback; +import io.undertow.client.ClientConnection; +import io.undertow.client.ClientExchange; +import io.undertow.client.ClientRequest; +import io.undertow.client.ClientResponse; +import io.undertow.client.UndertowClientMessages; +import io.undertow.protocols.ajp.AbstractAjpClientStreamSourceChannel; +import io.undertow.protocols.ajp.AjpClientChannel; +import io.undertow.protocols.ajp.AjpClientRequestClientStreamSinkChannel; +import io.undertow.protocols.ajp.AjpClientResponseStreamSourceChannel; +import io.undertow.util.AbstractAttachable; +import io.undertow.util.Protocols; -import static io.undertow.client.UndertowClientMessages.MESSAGES; -import static io.undertow.util.Headers.CLOSE; -import static io.undertow.util.Headers.CONNECTION; -import static io.undertow.util.Headers.CONTENT_LENGTH; -import static io.undertow.util.Headers.TRANSFER_ENCODING; -import static io.undertow.util.Headers.UPGRADE; -import static org.xnio.Bits.allAreSet; -import static org.xnio.Bits.anyAreSet; -import static org.xnio.IoUtils.safeClose; - /** * @author David M. Lloyd */ class AjpClientConnection extends AbstractAttachable implements Closeable, ClientConnection { - public final ConduitListener requestFinishListener = new ConduitListener() { + public final ChannelListener requestFinishListener = new ChannelListener() { @Override - public void handleEvent(StreamSinkConduit channel) { + public void handleEvent(AjpClientRequestClientStreamSinkChannel channel) { currentRequest.terminateRequest(); } }; - public final ConduitListener responseFinishedListener = new ConduitListener() { + public final ChannelListener responseFinishedListener = new ChannelListener() { @Override - public void handleEvent(StreamSourceConduit channel) { + public void handleEvent(AjpClientResponseStreamSourceChannel channel) { currentRequest.terminateResponse(); } }; - private final Deque pendingQueue = new ArrayDeque(); + private final Deque pendingQueue = new ArrayDeque<>(); private AjpClientExchange currentRequest; - private AjpResponseBuilder pendingResponse; private final OptionMap options; - private final StreamConnection connection; - private final PushBackStreamSourceConduit pushBackStreamSourceConduit; + private final AjpClientChannel connection; private final Pool bufferPool; - private final StreamSinkConduit originalSinkConduit; private static final int UPGRADED = 1 << 28; private static final int UPGRADE_REQUESTED = 1 << 29; @@ -104,23 +92,22 @@ private int state; - private final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter(); - private final ClientReadListener clientReadListener = new ClientReadListener(); + private final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter<>(); + private final ClientReceiveListener clientReceiveListener = new ClientReceiveListener(); - AjpClientConnection(final StreamConnection connection, final OptionMap options, final Pool bufferPool) { + AjpClientConnection(final AjpClientChannel connection, final OptionMap options, final Pool bufferPool) { this.options = options; this.connection = connection; - this.pushBackStreamSourceConduit = new PushBackStreamSourceConduit(connection.getSourceChannel().getConduit()); - this.connection.getSourceChannel().setConduit(pushBackStreamSourceConduit); this.bufferPool = bufferPool; - this.originalSinkConduit = connection.getSinkChannel().getConduit(); - connection.getCloseSetter().set(new ChannelListener() { - - public void handleEvent(StreamConnection channel) { + connection.addCloseTask(new ChannelListener() { + @Override + public void handleEvent(AjpClientChannel channel) { ChannelListeners.invokeChannelListener(AjpClientConnection.this, closeSetter.get()); } }); + connection.getReceiveSetter().set(new ClientReceiveListener()); + connection.resumeReceives(); } @Override @@ -134,10 +121,6 @@ return connection.getPeerAddress(); } - StreamConnection getConnection() { - return connection; - } - @Override public A getPeerAddress(Class type) { return connection.getPeerAddress(type); @@ -210,7 +193,6 @@ private void initiateRequest(AjpClientExchange AjpClientExchange) { currentRequest = AjpClientExchange; - pendingResponse = new AjpResponseBuilder(); ClientRequest request = AjpClientExchange.getRequest(); String connectionString = request.getRequestHeaders().getFirst(CONNECTION); @@ -225,13 +207,7 @@ state |= UPGRADE_REQUESTED; } - //setup the client request conduits - final ConduitStreamSourceChannel sourceChannel = connection.getSourceChannel(); - sourceChannel.setReadListener(clientReadListener); - sourceChannel.resumeReads(); - long length = 0; - ConduitStreamSinkChannel sinkChannel = connection.getSinkChannel(); String fixedLengthString = request.getRequestHeaders().getFirst(CONTENT_LENGTH); String transferEncodingString = request.getRequestHeaders().getLast(TRANSFER_ENCODING); @@ -240,65 +216,42 @@ } else if (transferEncodingString != null) { length = -1; } - final AjpClientRequestConduit ajpClientRequestConduit = new AjpClientRequestConduit(originalSinkConduit, bufferPool, currentRequest, requestFinishListener, length); - currentRequest.setAjpClientRequestConduit(ajpClientRequestConduit); - sinkChannel.setConduit(ajpClientRequestConduit); + AjpClientRequestClientStreamSinkChannel sinkChannel = connection.sendRequest(request.getMethod(), request.getPath(), request.getProtocol(), request.getRequestHeaders(), request, requestFinishListener); + currentRequest.setRequestChannel(sinkChannel); + AjpClientExchange.invokeReadReadyCallback(AjpClientExchange); if (length == 0) { //if there is no content we flush the response channel. //otherwise it is up to the user try { sinkChannel.shutdownWrites(); if (!sinkChannel.flush()) { - sinkChannel.setWriteListener(ChannelListeners.flushingChannelListener(null, new ChannelExceptionHandler() { - @Override - public void handleException(ConduitStreamSinkChannel channel, IOException exception) { - handleError(exception); - } - })); + handleFailedFlush(sinkChannel); } } catch (IOException e) { handleError(e); } - } else if (!sinkChannel.isWriteResumed()) { - try { - //TODO: this needs some more thought - if (!sinkChannel.flush()) { - sinkChannel.setWriteListener(new ChannelListener() { - @Override - public void handleEvent(ConduitStreamSinkChannel channel) { - try { - if (channel.flush()) { - channel.suspendWrites(); - } - } catch (IOException e) { - handleError(e); - } - } - }); - sinkChannel.resumeWrites(); - } - } catch (IOException e) { - handleError(e); - } } } + private void handleFailedFlush(AjpClientRequestClientStreamSinkChannel sinkChannel) { + sinkChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, new ChannelExceptionHandler() { + @Override + public void handleException(StreamSinkChannel channel, IOException exception) { + handleError(exception); + } + })); + sinkChannel.resumeWrites(); + } + private void handleError(IOException exception) { currentRequest.setFailed(exception); - IoUtils.safeClose(connection); + safeClose(connection); } public StreamConnection performUpgrade() throws IOException { - - // Upgrade the connection - // Set the upgraded flag already to prevent new requests after this one - if (allAreSet(state, UPGRADED | CLOSE_REQ | CLOSED)) { - throw new IOException(UndertowClientMessages.MESSAGES.connectionClosed()); - } - state |= UPGRADED; - return connection; + throw UndertowMessages.MESSAGES.upgradeNotSupported(); } public void close() throws IOException { @@ -313,28 +266,18 @@ * Notification that the current request is finished */ public void requestDone() { + currentRequest = null; - connection.getSinkChannel().setConduit(originalSinkConduit); - connection.getSourceChannel().setConduit(pushBackStreamSourceConduit); - connection.getSinkChannel().suspendWrites(); - connection.getSinkChannel().setWriteListener(null); - if (anyAreSet(state, CLOSE_REQ)) { - currentRequest = null; - IoUtils.safeClose(connection); + safeClose(connection); } else if (anyAreSet(state, UPGRADE_REQUESTED)) { - connection.getSourceChannel().suspendReads(); - currentRequest = null; + safeClose(connection); //we don't support upgrade, just close the connection to be safe return; } - currentRequest = null; AjpClientExchange next = pendingQueue.poll(); - if (next == null) { - connection.getSourceChannel().setReadListener(clientReadListener); - connection.getSourceChannel().resumeReads(); - } else { + if (next != null) { initiateRequest(next); } } @@ -343,219 +286,36 @@ state |= CLOSE_REQ; } - public void installReadBodyListener() { - connection.getSourceChannel().setConduit(pushBackStreamSourceConduit); - connection.getSourceChannel().setReadListener(new ResponseReceivedReadListener()); - connection.getSourceChannel().resumeReads(); - } - class ClientReadListener implements ChannelListener { + class ClientReceiveListener implements ChannelListener { - public void handleEvent(StreamSourceChannel channel) { - - AjpResponseBuilder builder = pendingResponse; - final Pooled pooled = bufferPool.allocate(); - final ByteBuffer buffer = pooled.getResource(); - buffer.clear(); - boolean free = true; - + public void handleEvent(AjpClientChannel channel) { try { - if (builder == null) { - //read ready when no request pending - buffer.clear(); - try { - int res = channel.read(buffer); - if (res == -1) { - UndertowLogger.CLIENT_LOGGER.debugf("Connection to %s was closed by the target server", connection.getPeerAddress()); - IoUtils.safeClose(AjpClientConnection.this); - } else if (res != 0) { - UndertowLogger.CLIENT_LOGGER.debugf("Target server %s sent unexpected data when no request pending, closing connection", connection.getPeerAddress()); - IoUtils.safeClose(AjpClientConnection.this); - } - //otherwise it is a spurious notification - } catch (IOException e) { - if (UndertowLogger.CLIENT_LOGGER.isDebugEnabled()) { - UndertowLogger.CLIENT_LOGGER.debugf(e, "Connection closed with IOException"); - } - safeClose(connection); - } + AbstractAjpClientStreamSourceChannel result = channel.receive(); + if(result == null) { return; } - final AjpResponseParseState state = builder.getParseState(); - int res; - do { - try { - res = channel.read(buffer); - } catch (IOException e) { - if (UndertowLogger.CLIENT_LOGGER.isDebugEnabled()) { - UndertowLogger.CLIENT_LOGGER.debugf(e, "Connection closed with IOException"); - } - safeClose(channel); - currentRequest.setFailed(new IOException(MESSAGES.connectionClosed())); - return; - } - buffer.flip(); - - if (res == 0 && !buffer.hasRemaining()) { - if (!channel.isReadResumed()) { - channel.getReadSetter().set(this); - channel.resumeReads(); - } - return; - } else if (res == -1 && !buffer.hasRemaining()) { - channel.suspendReads(); - IoUtils.safeClose(AjpClientConnection.this); - try { - final StreamSinkChannel requestChannel = connection.getSinkChannel(); - requestChannel.shutdownWrites(); - // will return false if there's a response queued ahead of this one, so we'll set up a listener then - if (!requestChannel.flush()) { - requestChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener(null, null)); - requestChannel.resumeWrites(); - } - // Cancel the current active request - currentRequest.setFailed(new IOException(MESSAGES.connectionClosed())); - } catch (IOException e) { - if (UndertowLogger.CLIENT_LOGGER.isDebugEnabled()) { - UndertowLogger.CLIENT_LOGGER.debugf(e, "Connection closed with IOException when attempting to shut down reads"); - } - // Cancel the current active request - currentRequest.setFailed(e); - IoUtils.safeClose(channel); - return; - } - return; - } - - AjpResponseParser.INSTANCE.parse(buffer, state, builder); - - //this is a bit hacky - //if the state=6 it is a ready body chunk response and not headers - //in which case we notify the conduit and reset the state - if (state.isComplete()) { - if (state.prefix == 6) { - currentRequest.getAjpClientRequestConduit().setBodyChunkRequested(state.currentIntegerPart); - state.reset(); - buffer.compact(); - } else if (buffer.hasRemaining()) { - free = false; - pushBackStreamSourceConduit.pushBack(pooled); - } + if(result instanceof AjpClientResponseStreamSourceChannel) { + AjpClientResponseStreamSourceChannel response = (AjpClientResponseStreamSourceChannel) result; + response.setFinishListener(responseFinishedListener); + ClientResponse cr = new ClientResponse(response.getStatusCode(), response.getReasonPhrase(), currentRequest.getRequest().getProtocol(), response.getHeaders()); + if (response.getStatusCode() == 100) { + currentRequest.setContinueResponse(cr); } else { - buffer.clear(); + currentRequest.setResponseChannel(response); + currentRequest.setResponse(cr); } - - } while (!state.isComplete()); - - final ClientResponse response = builder.build(); - - //check if an updated worked - if (anyAreSet(AjpClientConnection.this.state, UPGRADE_REQUESTED)) { - String connectionString = response.getResponseHeaders().getFirst(CONNECTION); - if (connectionString == null || !UPGRADE.equalToString(connectionString)) { - //just unset the upgrade requested flag - AjpClientConnection.this.state &= ~UPGRADE_REQUESTED; - } - } - - if (builder.getStatusCode() == 100) { - pendingResponse = new AjpResponseBuilder(); - currentRequest.setContinueResponse(response); } else { - connection.getSourceChannel().setConduit(new AjpClientResponseConduit(connection.getSourceChannel().getConduit(), AjpClientConnection.this, currentRequest.getAjpClientRequestConduit(), responseFinishedListener)); - channel.getReadSetter().set(null); - channel.suspendReads(); - pendingResponse = null; - currentRequest.setResponse(response); + //TODO: ping, pong ETC + Channels.drain(result, Long.MAX_VALUE); } - } catch (Exception e) { UndertowLogger.CLIENT_LOGGER.exceptionProcessingRequest(e); - IoUtils.safeClose(connection); - currentRequest.setFailed( e instanceof IOException ? (IOException) e : new IOException(e)); - } finally { - if (free) pooled.free(); + safeClose(connection); + currentRequest.setFailed(e instanceof IOException ? (IOException) e : new IOException(e)); } } } - - /** - * Listener that only listens for read body chunk messages, as even after the response is done the server - * can still be reading the request. - */ - class ResponseReceivedReadListener implements ChannelListener { - - private AjpResponseBuilder builder = new AjpResponseBuilder(); - - public void handleEvent(StreamSourceChannel channel) { - - final Pooled pooled = bufferPool.allocate(); - final ByteBuffer buffer = pooled.getResource(); - buffer.clear(); - boolean free = true; - - try { - final AjpResponseParseState state = builder.getParseState(); - int res; - do { - try { - res = channel.read(buffer); - } catch (IOException e) { - if (UndertowLogger.CLIENT_LOGGER.isDebugEnabled()) { - UndertowLogger.CLIENT_LOGGER.debugf(e, "Connection closed with IOException"); - } - safeClose(channel); - currentRequest.setFailed(new IOException(MESSAGES.connectionClosed())); - return; - } - - buffer.flip(); - - if (res == 0 && !buffer.hasRemaining()) { - if (!channel.isReadResumed()) { - channel.getReadSetter().set(this); - channel.resumeReads(); - } - return; - } else if (res == -1 && !buffer.hasRemaining()) { - channel.suspendReads(); - IoUtils.safeClose(connection); - currentRequest.setFailed(new IOException(UndertowClientMessages.MESSAGES.connectionClosed())); - return; - } - - AjpResponseParser.INSTANCE.parse(buffer, state, builder); - - //this is a bit hacky - //if the state=6 it is a ready body chunk response and not headers - //in which case we notify the conduit and reset the state - if (state.isComplete()) { - if (state.prefix == 6) { - currentRequest.getAjpClientRequestConduit().setBodyChunkRequested(state.currentIntegerPart); - state.reset(); - buffer.compact(); - } else { - //todo: ping? - UndertowLogger.CLIENT_LOGGER.debugf("Received invalid AJP response code %s with no request active, closing connection", state.prefix); - //invalid, at this point read body chunk is all the server should be sending - IoUtils.safeClose(connection); - currentRequest.setFailed(UndertowClientMessages.MESSAGES.receivedInvalidChunk(state.prefix)); - } - } else { - buffer.clear(); - } - - } while (!state.isComplete()); - - } catch (Exception e) { - UndertowLogger.CLIENT_LOGGER.exceptionProcessingRequest(e); - IoUtils.safeClose(connection); - } finally { - if (free) pooled.free(); - } - } - } - } Index: 3rdParty_sources/undertow/io/undertow/client/ajp/AjpClientExchange.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/ajp/Attic/AjpClientExchange.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/ajp/AjpClientExchange.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/ajp/AjpClientExchange.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client.ajp; import io.undertow.channels.DetachableStreamSinkChannel; @@ -8,6 +26,9 @@ import io.undertow.client.ClientRequest; import io.undertow.client.ClientResponse; import io.undertow.client.ContinueNotification; +import io.undertow.protocols.ajp.AjpClientChannel; +import io.undertow.protocols.ajp.AjpClientRequestClientStreamSinkChannel; +import io.undertow.protocols.ajp.AjpClientResponseStreamSourceChannel; import io.undertow.util.AbstractAttachable; import io.undertow.util.Headers; import org.xnio.channels.StreamSinkChannel; @@ -29,12 +50,15 @@ private ClientCallback responseCallback; private ClientCallback readyCallback; private ContinueNotification continueNotification; - private AjpClientRequestConduit ajpClientRequestConduit; + private AjpClientChannel ajpClientChannel; private ClientResponse response; private ClientResponse continueResponse; private IOException failedReason; + private AjpClientResponseStreamSourceChannel responseChannel; + private AjpClientRequestClientStreamSinkChannel requestChannel; + private int state = 0; private static final int REQUEST_TERMINATED = 1; private static final int RESPONSE_TERMINATED = 1 << 1; @@ -65,8 +89,6 @@ state |= RESPONSE_TERMINATED; if (anyAreSet(state, REQUEST_TERMINATED)) { clientConnection.requestDone(); - } else { - clientConnection.installReadBodyListener(); } } @@ -120,7 +142,7 @@ @Override public StreamSinkChannel getRequestChannel() { - return new DetachableStreamSinkChannel(clientConnection.getConnection().getSinkChannel()) { + return new DetachableStreamSinkChannel(requestChannel) { @Override protected boolean isFinished() { return anyAreSet(state, REQUEST_TERMINATED); @@ -130,7 +152,7 @@ @Override public StreamSourceChannel getResponseChannel() { - return new DetachableStreamSourceChannel(clientConnection.getConnection().getSourceChannel()) { + return new DetachableStreamSourceChannel(responseChannel) { @Override protected boolean isFinished() { return anyAreSet(state, RESPONSE_TERMINATED); @@ -158,18 +180,18 @@ return clientConnection; } + void setResponseChannel(AjpClientResponseStreamSourceChannel responseChannel) { + this.responseChannel = responseChannel; + } + + void setRequestChannel(AjpClientRequestClientStreamSinkChannel requestChannel) { + this.requestChannel = requestChannel; + } + void invokeReadReadyCallback(final ClientExchange result) { if(readyCallback != null) { readyCallback.completed(result); readyCallback = null; } } - - public AjpClientRequestConduit getAjpClientRequestConduit() { - return ajpClientRequestConduit; - } - - public void setAjpClientRequestConduit(AjpClientRequestConduit ajpClientRequestConduit) { - this.ajpClientRequestConduit = ajpClientRequestConduit; - } } Index: 3rdParty_sources/undertow/io/undertow/client/ajp/AjpClientProvider.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/ajp/Attic/AjpClientProvider.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/ajp/AjpClientProvider.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/ajp/AjpClientProvider.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,8 +1,28 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client.ajp; import io.undertow.client.ClientCallback; import io.undertow.client.ClientConnection; import io.undertow.client.ClientProvider; +import io.undertow.protocols.ajp.AjpClientChannel; + import org.xnio.ChannelListener; import org.xnio.IoFuture; import org.xnio.OptionMap; @@ -26,45 +46,67 @@ @Override public Set handlesSchemes() { - return new HashSet(Arrays.asList(new String[]{"ajp"})); + return new HashSet<>(Arrays.asList(new String[]{"ajp"})); } @Override public void connect(final ClientCallback listener, final URI uri, final XnioWorker worker, final XnioSsl ssl, final Pool bufferPool, final OptionMap options) { - worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), new ChannelListener() { + connect(listener, null, uri, worker, ssl, bufferPool, options); + } + + @Override + public void connect(final ClientCallback listener, final URI uri, final XnioIoThread ioThread, final XnioSsl ssl, final Pool bufferPool, final OptionMap options) { + connect(listener, null, uri, ioThread, ssl, bufferPool, options); + } + + @Override + public void connect(final ClientCallback listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, final XnioSsl ssl, final Pool bufferPool, final OptionMap options) { + ChannelListener openListener = new ChannelListener() { @Override public void handleEvent(StreamConnection connection) { handleConnected(connection, listener, uri, ssl, bufferPool, options); } - }, options).addNotifier(new IoFuture.Notifier() { + }; + IoFuture.Notifier notifier = new IoFuture.Notifier() { @Override public void notify(IoFuture ioFuture, Object o) { if (ioFuture.getStatus() == IoFuture.Status.FAILED) { listener.failed(ioFuture.getException()); } } - }, null); + }; + if(bindAddress == null) { + worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, options).addNotifier(notifier, null); + } else { + worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, null, options).addNotifier(notifier, null); + } } @Override - public void connect(final ClientCallback listener, final URI uri, final XnioIoThread ioThread, final XnioSsl ssl, final Pool bufferPool, final OptionMap options) { - ioThread.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), new ChannelListener() { + public void connect(final ClientCallback listener, InetSocketAddress bindAddress,final URI uri, final XnioIoThread ioThread, final XnioSsl ssl, final Pool bufferPool, final OptionMap options) { + ChannelListener openListener = new ChannelListener() { @Override public void handleEvent(StreamConnection connection) { handleConnected(connection, listener, uri, ssl, bufferPool, options); } - }, options).addNotifier(new IoFuture.Notifier() { + }; + IoFuture.Notifier notifier = new IoFuture.Notifier() { @Override public void notify(IoFuture ioFuture, Object o) { - if(ioFuture.getStatus() == IoFuture.Status.FAILED) { + if (ioFuture.getStatus() == IoFuture.Status.FAILED) { listener.failed(ioFuture.getException()); } } - }, null); + }; + if(bindAddress == null) { + ioThread.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, options).addNotifier(notifier, null); + } else { + ioThread.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, null, options).addNotifier(notifier, null); + } } private void handleConnected(StreamConnection connection, ClientCallback listener, URI uri, XnioSsl ssl, Pool bufferPool, OptionMap options) { - listener.completed(new AjpClientConnection(connection, options, bufferPool)); + listener.completed(new AjpClientConnection(new AjpClientChannel(connection, bufferPool) , options, bufferPool)); } Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/client/ajp/AjpClientRequestConduit.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/client/ajp/AjpClientResponseConduit.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/client/ajp/AjpResponseBuilder.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/client/ajp/AjpResponseParseState.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/client/ajp/AjpResponseParser.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/client/http/ClientFixedLengthStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/http/Attic/ClientFixedLengthStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/http/ClientFixedLengthStreamSinkConduit.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/http/ClientFixedLengthStreamSinkConduit.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client.http; import io.undertow.conduits.AbstractFixedLengthStreamSinkConduit; Index: 3rdParty_sources/undertow/io/undertow/client/http/HttpClientConnection.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/http/Attic/HttpClientConnection.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/http/HttpClientConnection.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/http/HttpClientConnection.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,23 +1,19 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012, Red Hat, Inc., and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * http://www.apache.org/licenses/LICENSE-2.0 * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.client.http; @@ -41,7 +37,6 @@ import org.xnio.ChannelExceptionHandler; import org.xnio.ChannelListener; import org.xnio.ChannelListeners; -import org.xnio.IoUtils; import org.xnio.Option; import org.xnio.OptionMap; import org.xnio.Pool; @@ -93,7 +88,7 @@ } }; - private final Deque pendingQueue = new ArrayDeque(); + private final Deque pendingQueue = new ArrayDeque<>(); private HttpClientExchange currentRequest; private HttpResponseBuilder pendingResponse; @@ -113,7 +108,7 @@ private int state; - private final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter(); + private final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter<>(); HttpClientConnection(final StreamConnection connection, final OptionMap options, final Pool bufferPool) { this.options = options; @@ -290,27 +285,6 @@ } catch (IOException e) { handleError(e); } - } else if (!sinkChannel.isWriteResumed()) { - try { - //TODO: this needs some more thought - if (!sinkChannel.flush()) { - sinkChannel.setWriteListener(new ChannelListener() { - @Override - public void handleEvent(ConduitStreamSinkChannel channel) { - try { - if (channel.flush()) { - channel.suspendWrites(); - } - } catch (IOException e) { - handleError(e); - } - } - }); - sinkChannel.resumeWrites(); - } - } catch (IOException e) { - handleError(e); - } } } @@ -352,7 +326,7 @@ if (anyAreSet(state, CLOSE_REQ)) { currentRequest = null; this.state |= CLOSED; - IoUtils.safeClose(connection); + safeClose(connection); } else if (anyAreSet(state, UPGRADE_REQUESTED)) { connection.getSourceChannel().suspendReads(); currentRequest = null; @@ -389,10 +363,10 @@ int res = channel.read(buffer); if(res == -1) { UndertowLogger.CLIENT_LOGGER.debugf("Connection to %s was closed by the target server", connection.getPeerAddress()); - IoUtils.safeClose(HttpClientConnection.this); + safeClose(HttpClientConnection.this); } else if(res != 0) { UndertowLogger.CLIENT_LOGGER.debugf("Target server %s sent unexpected data when no request pending, closing connection", connection.getPeerAddress()); - IoUtils.safeClose(HttpClientConnection.this); + safeClose(HttpClientConnection.this); } //otherwise it is a spurious notification } catch (IOException e) { @@ -426,7 +400,7 @@ return; } else if (res == -1) { channel.suspendReads(); - IoUtils.safeClose(HttpClientConnection.this); + safeClose(HttpClientConnection.this); // Cancel the current active request currentRequest.setFailed(new IOException(MESSAGES.connectionClosed())); return; @@ -474,7 +448,7 @@ } catch (Exception e) { UndertowLogger.CLIENT_LOGGER.exceptionProcessingRequest(e); - IoUtils.safeClose(connection); + safeClose(connection); currentRequest.setFailed(new IOException(e)); } finally { if (free) pooled.free(); Index: 3rdParty_sources/undertow/io/undertow/client/http/HttpClientExchange.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/http/Attic/HttpClientExchange.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/http/HttpClientExchange.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/http/HttpClientExchange.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client.http; import io.undertow.channels.DetachableStreamSinkChannel; Index: 3rdParty_sources/undertow/io/undertow/client/http/HttpClientProvider.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/http/Attic/HttpClientProvider.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/http/HttpClientProvider.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/http/HttpClientProvider.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,16 +1,37 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client.http; import io.undertow.UndertowMessages; +import io.undertow.UndertowOptions; import io.undertow.client.ClientCallback; import io.undertow.client.ClientConnection; import io.undertow.client.ClientProvider; +import io.undertow.client.spdy.SpdyClientProvider; import org.xnio.ChannelListener; import org.xnio.IoFuture; import org.xnio.OptionMap; import org.xnio.Pool; import org.xnio.StreamConnection; import org.xnio.XnioIoThread; import org.xnio.XnioWorker; +import org.xnio.ssl.SslConnection; import org.xnio.ssl.XnioSsl; import java.io.IOException; @@ -28,63 +49,96 @@ @Override public Set handlesSchemes() { - return new HashSet(Arrays.asList(new String[]{"http", "https"})); + return new HashSet<>(Arrays.asList(new String[]{"http", "https"})); } @Override public void connect(final ClientCallback listener, final URI uri, final XnioWorker worker, final XnioSsl ssl, final Pool bufferPool, final OptionMap options) { - if(uri.getScheme().equals("https")) { - if(ssl == null) { - throw UndertowMessages.MESSAGES.sslWasNull(); - } + connect(listener, null, uri, worker, ssl, bufferPool, options); + } + @Override + public void connect(final ClientCallback listener, final URI uri, final XnioIoThread ioThread, final XnioSsl ssl, final Pool bufferPool, final OptionMap options) { + connect(listener, null, uri, ioThread, ssl, bufferPool, options); + } + + @Override + public void connect(ClientCallback listener, InetSocketAddress bindAddress, URI uri, XnioWorker worker, XnioSsl ssl, Pool bufferPool, OptionMap options) { + if (uri.getScheme().equals("https")) { + if (ssl == null) { + listener.failed(UndertowMessages.MESSAGES.sslWasNull()); + return; + } + if (bindAddress == null) { + ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null); + } else { + ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null); + } + } else { + if (bindAddress == null) { + worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null); + } else { + worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options), null, options).addNotifier(createNotifier(listener), null); + } } - worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80: uri.getPort()), new ChannelListener() { - @Override - public void handleEvent(StreamConnection connection) { - handleConnected(connection, listener, uri, ssl, bufferPool, options); + } + + @Override + public void connect(ClientCallback listener, InetSocketAddress bindAddress, URI uri, XnioIoThread ioThread, XnioSsl ssl, Pool bufferPool, OptionMap options) { + if (uri.getScheme().equals("https")) { + if (ssl == null) { + listener.failed(UndertowMessages.MESSAGES.sslWasNull()); + return; } - }, options).addNotifier(new IoFuture.Notifier() { + if (bindAddress == null) { + ssl.openSslConnection(ioThread, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null); + } else { + ssl.openSslConnection(ioThread, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null); + } + } else { + if (bindAddress == null) { + ioThread.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null); + } else { + ioThread.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options), null, options).addNotifier(createNotifier(listener), null); + } + } + } + private IoFuture.Notifier createNotifier(final ClientCallback listener) { + return new IoFuture.Notifier() { @Override public void notify(IoFuture ioFuture, Object o) { - if(ioFuture.getStatus() == IoFuture.Status.FAILED) { + if (ioFuture.getStatus() == IoFuture.Status.FAILED) { listener.failed(ioFuture.getException()); } } - }, null); + }; } - @Override - public void connect(final ClientCallback listener, final URI uri, final XnioIoThread ioThread, final XnioSsl ssl, final Pool bufferPool, final OptionMap options) { - if(uri.getScheme().equals("https")) { - if(ssl == null) { - throw UndertowMessages.MESSAGES.sslWasNull(); - } - } - ioThread.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort()), new ChannelListener() { + private ChannelListener createOpenListener(final ClientCallback listener, final Pool bufferPool, final OptionMap options) { + return new ChannelListener() { @Override public void handleEvent(StreamConnection connection) { - handleConnected(connection, listener, uri, ssl, bufferPool, options); + handleConnected(connection, listener, bufferPool, options); } - }, options).addNotifier(new IoFuture.Notifier() { - @Override - public void notify(IoFuture ioFuture, Object o) { - if(ioFuture.getStatus() == IoFuture.Status.FAILED) { - listener.failed(ioFuture.getException()); - } - } - }, null); + }; } - private void handleConnected(StreamConnection connection, ClientCallback listener, URI uri, XnioSsl ssl, Pool bufferPool, OptionMap options) { - if(uri.getScheme().equals("https")) { - listener.failed(new IOException("ssl not implemented yet")); + + private void handleConnected(final StreamConnection connection, final ClientCallback listener, final Pool bufferPool, final OptionMap options) { + if (options.get(UndertowOptions.ENABLE_SPDY, false) && connection instanceof SslConnection && SpdyClientProvider.isEnabled()) { + try { + SpdyClientProvider.handlePotentialSpdyConnection(connection, listener, bufferPool, options, new ChannelListener() { + @Override + public void handleEvent(SslConnection channel) { + listener.completed(new HttpClientConnection(connection, options, bufferPool)); + } + }); + } catch (Exception e) { + listener.failed(new IOException(e)); + } } else { listener.completed(new HttpClientConnection(connection, options, bufferPool)); } - } - - } Index: 3rdParty_sources/undertow/io/undertow/client/http/HttpRequestConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/http/Attic/HttpRequestConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/http/HttpRequestConduit.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/http/HttpRequestConduit.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.client.http; Index: 3rdParty_sources/undertow/io/undertow/client/http/HttpResponseBuilder.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/http/Attic/HttpResponseBuilder.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/http/HttpResponseBuilder.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/http/HttpResponseBuilder.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client.http; import io.undertow.client.ClientResponse; Index: 3rdParty_sources/undertow/io/undertow/client/http/HttpResponseParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/http/Attic/HttpResponseParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/http/HttpResponseParser.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/http/HttpResponseParser.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client.http; import io.undertow.annotationprocessor.HttpResponseParserConfig; @@ -92,7 +110,7 @@ static { try { - final Class cls = HttpResponseParser.class.getClassLoader().loadClass(HttpResponseParser.class.getName() + "$$generated"); + final Class cls = Class.forName(HttpResponseParser.class.getName() + "$$generated", false, HttpResponseParser.class.getClassLoader()); INSTANCE = (HttpResponseParser) cls.newInstance(); } catch (Exception e) { throw new RuntimeException(e); @@ -332,7 +350,7 @@ * @return */ protected static Map httpStrings() { - final Map results = new HashMap(); + final Map results = new HashMap<>(); final Class[] classs = {Headers.class, Methods.class, Protocols.class}; for (Class c : classs) { Index: 3rdParty_sources/undertow/io/undertow/client/http/ResponseParseState.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/client/http/Attic/ResponseParseState.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/client/http/ResponseParseState.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/client/http/ResponseParseState.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.client.http; import io.undertow.util.HttpString; Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/client/spdy/SpdyClientConnection.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/client/spdy/SpdyClientExchange.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/client/spdy/SpdyClientProvider.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/conduits/AbstractFixedLengthStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/AbstractFixedLengthStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/AbstractFixedLengthStreamSinkConduit.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/AbstractFixedLengthStreamSinkConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.conduits; @@ -48,6 +48,8 @@ private long state; + private boolean broken = false; + private static final int CONF_FLAG_CONFIGURABLE = 1 << 0; private static final int CONF_FLAG_PASS_CLOSE = 1 << 1; @@ -102,6 +104,9 @@ int res = 0; try { return res = next.write(src); + } catch (IOException e) { + broken = true; + throw e; } finally { src.limit(oldLimit); exitWrite(val, (long) res); @@ -141,6 +146,9 @@ long res = 0L; try { return res = next.write(srcs, offset, length); + } catch (IOException e) { + broken = true; + throw e; } finally { if (limits != null) { for (int i = offset; i < offset + length; ++i) { @@ -153,12 +161,22 @@ @Override public long writeFinal(ByteBuffer[] srcs, int offset, int length) throws IOException { - return Conduits.writeFinalBasic(this, srcs, offset, length); + try { + return Conduits.writeFinalBasic(this, srcs, offset, length); + } catch (IOException e) { + broken = true; + throw e; + } } @Override public int writeFinal(ByteBuffer src) throws IOException { - return Conduits.writeFinalBasic(this, src); + try { + return Conduits.writeFinalBasic(this, src); + } catch (IOException e) { + broken = true; + throw e; + } } public long transferFrom(final FileChannel src, final long position, final long count) throws IOException { @@ -173,6 +191,9 @@ long res = 0L; try { return res = next.transferFrom(src, position, min(count, (val & MASK_COUNT))); + } catch (IOException e) { + broken = true; + throw e; } finally { exitWrite(val, res); } @@ -190,6 +211,9 @@ long res = 0L; try { return res = next.transferFrom(source, min(count, (val & MASK_COUNT)), throughBuffer); + } catch (IOException e) { + broken = true; + throw e; } finally { exitWrite(val, res); } @@ -203,6 +227,9 @@ boolean flushed = false; try { return flushed = next.flush(); + } catch (IOException e) { + broken = true; + throw e; } finally { exitFlush(val, flushed); } @@ -223,7 +250,7 @@ public void terminateWrites() throws IOException { final long val = enterShutdown(); - if (anyAreSet(val, MASK_COUNT)) { + if (anyAreSet(val, MASK_COUNT) && !broken) { try { throw new FixedLengthUnderflowException((val & MASK_COUNT) + " bytes remaining"); } finally { Index: 3rdParty_sources/undertow/io/undertow/conduits/AbstractFramedStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/AbstractFramedStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/AbstractFramedStreamSinkConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/AbstractFramedStreamSinkConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.conduits; import io.undertow.UndertowMessages; @@ -30,7 +48,7 @@ */ public class AbstractFramedStreamSinkConduit extends AbstractStreamSinkConduit { - private final Deque frameQueue = new ArrayDeque(); + private final Deque frameQueue = new ArrayDeque<>(); /** * The total amount of data that has been queued to be written out */ Index: 3rdParty_sources/undertow/io/undertow/conduits/BrokenStreamSourceConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/BrokenStreamSourceConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/BrokenStreamSourceConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/BrokenStreamSourceConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.conduits; Index: 3rdParty_sources/undertow/io/undertow/conduits/ChunkReader.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/ChunkReader.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/ChunkReader.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/ChunkReader.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.conduits; import io.undertow.UndertowMessages; Index: 3rdParty_sources/undertow/io/undertow/conduits/ChunkedStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/ChunkedStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/ChunkedStreamSinkConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/ChunkedStreamSinkConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.conduits; @@ -100,8 +100,6 @@ private static final int FLAG_FIRST_DATA_WRITTEN = 1 << 4; //set on first flush or write call private static final int FLAG_FINISHED = 1 << 5; - int written = 0; - /** * Construct a new instance. * @@ -140,7 +138,6 @@ int oldLimit = src.limit(); if (chunkleft == 0 && !chunkingSepBuffer.hasRemaining()) { chunkingBuffer.clear(); - written += src.remaining(); putIntAsHexString(chunkingBuffer, src.remaining()); chunkingBuffer.put(CRLF); chunkingBuffer.flip(); @@ -197,6 +194,13 @@ } + @Override + public void truncateWrites() throws IOException { + if(lastChunkBuffer != null) { + lastChunkBuffer.free(); + } + super.truncateWrites(); + } @Override public long write(final ByteBuffer[] srcs, final int offset, final int length) throws IOException { @@ -339,7 +343,7 @@ ByteBuffer data = ByteBuffer.allocate(lastChunkBuffer.remaining()); data.put(lastChunkBuffer); data.flip(); - this.lastChunkBuffer = new ImmediatePooled(data); + this.lastChunkBuffer = new ImmediatePooled<>(data); lastChunkBufferPooled.free(); } Index: 3rdParty_sources/undertow/io/undertow/conduits/ChunkedStreamSourceConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/ChunkedStreamSourceConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/ChunkedStreamSourceConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/ChunkedStreamSourceConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,17 +9,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.conduits; -import io.undertow.UndertowLogger; import io.undertow.UndertowMessages; +import io.undertow.server.Connectors; import io.undertow.server.HttpServerExchange; import io.undertow.server.protocol.http.HttpAttachments; import io.undertow.server.protocol.http.HttpServerConnection; @@ -95,7 +95,7 @@ this.bufferWrapper = bufferWrapper; this.finishListener = finishListener; this.remainingAllowed = Long.MIN_VALUE; - this.chunkReader = new ChunkReader(attachable, HttpAttachments.REQUEST_TRAILERS, finishListener, this); + this.chunkReader = new ChunkReader<>(attachable, HttpAttachments.REQUEST_TRAILERS, finishListener, this); this.exchange = exchange; } @@ -118,15 +118,10 @@ remainingAllowed -= written; if (remainingAllowed < 0) { //max entity size is exceeded - //we need to forcibly close the read side - try { - next.terminateReads(); - } catch (IOException e) { - UndertowLogger.REQUEST_LOGGER.debug("Exception terminating reads due to exceeding max size", e); - } + Connectors.terminateRequest(exchange); closed = true; - finishListener.handleEvent(this); exchange.setPersistent(false); + finishListener.handleEvent(this); throw UndertowMessages.MESSAGES.requestEntityWasTooLarge(exchange.getMaxEntitySize()); } } Index: 3rdParty_sources/undertow/io/undertow/conduits/ConduitListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/ConduitListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/ConduitListener.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/ConduitListener.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.conduits; import java.util.EventListener; Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/conduits/DebuggingStreamSinkConduit.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/conduits/DebuggingStreamSourceConduit.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/conduits/DeflatingStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/DeflatingStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/DeflatingStreamSinkConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/DeflatingStreamSinkConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,15 +1,33 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.conduits; +import static org.xnio.Bits.allAreClear; +import static org.xnio.Bits.allAreSet; +import static org.xnio.Bits.anyAreSet; + import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; import java.util.concurrent.TimeUnit; import java.util.zip.Deflater; - -import io.undertow.server.HttpServerExchange; -import io.undertow.util.ConduitFactory; -import io.undertow.util.Headers; import org.xnio.IoUtils; import org.xnio.Pooled; import org.xnio.XnioIoThread; @@ -20,8 +38,10 @@ import org.xnio.conduits.StreamSinkConduit; import org.xnio.conduits.WriteReadyHandler; -import static org.xnio.Bits.allAreClear; -import static org.xnio.Bits.anyAreSet; +import io.undertow.UndertowLogger; +import io.undertow.server.HttpServerExchange; +import io.undertow.util.ConduitFactory; +import io.undertow.util.Headers; /** * Channel that handles deflate compression @@ -41,7 +61,7 @@ /** * The streams buffer. This is freed when the next is shutdown */ - protected final Pooled currentBuffer; + protected Pooled currentBuffer; /** * there may have been some additional data that did not fit into the first buffer */ @@ -61,7 +81,6 @@ } protected DeflatingStreamSinkConduit(final ConduitFactory conduitFactory, final HttpServerExchange exchange, int deflateLevel) { - deflater = new Deflater(deflateLevel, true); this.currentBuffer = exchange.getConnection().getBufferPool().allocate(); this.exchange = exchange; @@ -70,28 +89,33 @@ @Override public int write(final ByteBuffer src) throws IOException { - if (anyAreSet(SHUTDOWN | CLOSED, state)) { + if (anyAreSet(state, SHUTDOWN | CLOSED) || currentBuffer == null) { throw new ClosedChannelException(); } - if (!performFlushIfRequired()) { - return 0; - } - if (src.remaining() == 0) { - return 0; - } - //we may already have some input, if so compress it - if(!deflater.needsInput()) { - deflateData(); - if(!deflater.needsInput()) { + try { + if (!performFlushIfRequired()) { return 0; } + if (src.remaining() == 0) { + return 0; + } + //we may already have some input, if so compress it + if (!deflater.needsInput()) { + deflateData(); + if (!deflater.needsInput()) { + return 0; + } + } + byte[] data = new byte[src.remaining()]; + src.get(data); + preDeflate(data); + deflater.setInput(data); + deflateData(); + return data.length; + } catch (IOException e) { + freeBuffer(); + throw e; } - byte[] data = new byte[src.remaining()]; - src.get(data); - preDeflate(data); - deflater.setInput(data); - deflateData(); - return data.length; } protected void preDeflate(byte[] data) { @@ -100,20 +124,25 @@ @Override public long write(final ByteBuffer[] srcs, final int offset, final int length) throws IOException { - if (anyAreSet(SHUTDOWN | CLOSED, state)) { + if (anyAreSet(state, SHUTDOWN | CLOSED) || currentBuffer == null) { throw new ClosedChannelException(); } - int total = 0; - for (int i = offset; i < offset + length; ++i) { - if (srcs[i].hasRemaining()) { - int ret = write(srcs[i]); - total += ret; - if (ret == 0) { - return total; + try { + int total = 0; + for (int i = offset; i < offset + length; ++i) { + if (srcs[i].hasRemaining()) { + int ret = write(srcs[i]); + total += ret; + if (ret == 0) { + return total; + } } } + return total; + } catch (IOException e) { + freeBuffer(); + throw e; } - return total; } @Override @@ -128,7 +157,7 @@ @Override public long transferFrom(final FileChannel src, final long position, final long count) throws IOException { - if (anyAreSet(SHUTDOWN | CLOSED, state)) { + if (anyAreSet(state, SHUTDOWN | CLOSED)) { throw new ClosedChannelException(); } if (!performFlushIfRequired()) { @@ -140,7 +169,7 @@ @Override public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException { - if (anyAreSet(SHUTDOWN | CLOSED, state)) { + if (anyAreSet(state, SHUTDOWN | CLOSED)) { throw new ClosedChannelException(); } if (!performFlushIfRequired()) { @@ -167,7 +196,7 @@ @Override public boolean isWriteResumed() { if (next == null) { - return anyAreSet(WRITES_RESUMED, state); + return anyAreSet(state, WRITES_RESUMED); } else { return next.isWriteResumed(); } @@ -210,7 +239,6 @@ }); } - @Override public void terminateWrites() throws IOException { deflater.finish(); @@ -252,73 +280,89 @@ @Override public boolean flush() throws IOException { - boolean nextCreated = false; + if (currentBuffer == null) { + if (anyAreSet(state, NEXT_SHUTDOWN)) { + return next.flush(); + } else { + return true; + } + } try { - if (anyAreSet(SHUTDOWN, state)) { - if (anyAreSet(NEXT_SHUTDOWN, state)) { - return next.flush(); - } else { - if (!performFlushIfRequired()) { - return false; - } - //if the deflater has not been fully flushed we need to flush it - if (!deflater.finished()) { - deflateData(); - //if could not fully flush - if (!deflater.finished()) { + boolean nextCreated = false; + try { + if (anyAreSet(state, SHUTDOWN)) { + if (anyAreSet(state, NEXT_SHUTDOWN)) { + return next.flush(); + } else { + if (!performFlushIfRequired()) { return false; } - } - final ByteBuffer buffer = currentBuffer.getResource(); - if (allAreClear(WRITTEN_TRAILER, state)) { - state |= WRITTEN_TRAILER; - byte[] data = getTrailer(); - if(data != null) { - if(data.length <= buffer.remaining()) { - buffer.put(data); - } else if(additionalBuffer == null) { - additionalBuffer = ByteBuffer.wrap(data); - } else { - byte[] newData = new byte[additionalBuffer.remaining() + data.length]; - int pos = 0; - while (additionalBuffer.hasRemaining()) { - newData[pos++] = additionalBuffer.get(); + //if the deflater has not been fully flushed we need to flush it + if (!deflater.finished()) { + deflateData(); + //if could not fully flush + if (!deflater.finished()) { + return false; + } + } + final ByteBuffer buffer = currentBuffer.getResource(); + if (allAreClear(state, WRITTEN_TRAILER)) { + state |= WRITTEN_TRAILER; + byte[] data = getTrailer(); + if (data != null) { + if (data.length <= buffer.remaining()) { + buffer.put(data); + } else if (additionalBuffer == null) { + additionalBuffer = ByteBuffer.wrap(data); + } else { + byte[] newData = new byte[additionalBuffer.remaining() + data.length]; + int pos = 0; + while (additionalBuffer.hasRemaining()) { + newData[pos++] = additionalBuffer.get(); + } + for (byte aData : data) { + newData[pos++] = aData; + } + this.additionalBuffer = ByteBuffer.wrap(newData); } - for (byte aData : data) { - newData[pos++] = aData; - } - this.additionalBuffer = ByteBuffer.wrap(newData); } } - } - //ok the deflater is flushed, now we need to flush the buffer - if (!anyAreSet(FLUSHING_BUFFER, state)) { - buffer.flip(); - state |= FLUSHING_BUFFER; - if (next == null) { - nextCreated = true; - this.next = createNextChannel(); + //ok the deflater is flushed, now we need to flush the buffer + if (!anyAreSet(state, FLUSHING_BUFFER)) { + buffer.flip(); + state |= FLUSHING_BUFFER; + if (next == null) { + nextCreated = true; + this.next = createNextChannel(); + } } + if (performFlushIfRequired()) { + state |= NEXT_SHUTDOWN; + freeBuffer(); + next.terminateWrites(); + return next.flush(); + } else { + return false; + } } - if (performFlushIfRequired()) { - state |= NEXT_SHUTDOWN; - currentBuffer.free(); - next.terminateWrites(); - return next.flush(); - } else { - return false; + } else { + return performFlushIfRequired(); + } + } finally { + if (nextCreated) { + if (anyAreSet(state, WRITES_RESUMED) && !anyAreSet(state ,NEXT_SHUTDOWN)) { + try { + next.resumeWrites(); + } catch (Exception e) { + UndertowLogger.REQUEST_LOGGER.debug("Failed to resume", e); + } } } - } else { - return performFlushIfRequired(); } - } finally { - if (nextCreated) { - if (anyAreSet(WRITES_RESUMED, state) && !anyAreSet(NEXT_SHUTDOWN, state)) { - next.resumeWrites(); - } - } + } catch (IOException e) { + freeBuffer(); + throw e; } } @@ -335,7 +379,7 @@ * @return false if there is still more to flush */ private boolean performFlushIfRequired() throws IOException { - if (anyAreSet(FLUSHING_BUFFER, state)) { + if (anyAreSet(state, FLUSHING_BUFFER)) { final ByteBuffer[] bufs = new ByteBuffer[additionalBuffer == null ? 1 : 2]; long totalLength = 0; bufs[0] = currentBuffer.getResource(); @@ -364,7 +408,7 @@ private StreamSinkConduit createNextChannel() { - if (deflater.finished()) { + if (deflater.finished() && allAreSet(state, WRITTEN_TRAILER)) { //the deflater was fully flushed before we created the channel. This means that what is in the buffer is //all there is int remaining = currentBuffer.getResource().remaining(); @@ -392,7 +436,7 @@ Pooled pooled = this.currentBuffer; final ByteBuffer outputBuffer = pooled.getResource(); - final boolean shutdown = anyAreSet(SHUTDOWN, state); + final boolean shutdown = anyAreSet(state, SHUTDOWN); byte[] buffer = new byte[1024]; //TODO: we should pool this and make it configurable or something while (!deflater.needsInput() || (shutdown && !deflater.finished())) { @@ -422,7 +466,7 @@ } } finally { if (nextCreated) { - if (anyAreSet(WRITES_RESUMED, state)) { + if (anyAreSet(state, WRITES_RESUMED)) { next.resumeWrites(); } } @@ -432,10 +476,15 @@ @Override public void truncateWrites() throws IOException { - if (!anyAreSet(NEXT_SHUTDOWN, state)) { - currentBuffer.free(); - } + freeBuffer(); state |= CLOSED; next.truncateWrites(); } + + private void freeBuffer() { + if (currentBuffer != null) { + currentBuffer.free(); + currentBuffer = null; + } + } } Index: 3rdParty_sources/undertow/io/undertow/conduits/EmptyStreamSourceConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/EmptyStreamSourceConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/EmptyStreamSourceConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/EmptyStreamSourceConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.conduits; Index: 3rdParty_sources/undertow/io/undertow/conduits/FinishableStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/FinishableStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/FinishableStreamSinkConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/FinishableStreamSinkConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.conduits; Index: 3rdParty_sources/undertow/io/undertow/conduits/FinishableStreamSourceConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/FinishableStreamSourceConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/FinishableStreamSourceConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/FinishableStreamSourceConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,20 +1,19 @@ /* * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. * - * Copyright 2012 Red Hat, Inc. and/or its affiliates, and individual - * contributors as indicated by the @author tags. - * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.conduits; Index: 3rdParty_sources/undertow/io/undertow/conduits/FixedLengthStreamSourceConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/FixedLengthStreamSourceConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/FixedLengthStreamSourceConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/FixedLengthStreamSourceConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,26 +1,25 @@ /* * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. * - * Copyright 2012 Red Hat, Inc. and/or its affiliates, and individual - * contributors as indicated by the @author tags. - * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.conduits; -import io.undertow.UndertowLogger; import io.undertow.UndertowMessages; +import io.undertow.server.Connectors; import io.undertow.server.HttpServerExchange; import org.xnio.channels.StreamSinkChannel; import org.xnio.conduits.AbstractStreamSourceConduit; @@ -155,14 +154,10 @@ if (exchange.getMaxEntitySize() > 0 && exchange.getMaxEntitySize() < (state & MASK_COUNT)) { //max entity size is exceeded //we need to forcibly close the read side - try { - next.terminateReads(); - } catch (IOException e) { - UndertowLogger.REQUEST_LOGGER.debug("Exception terminating reads due to exceeding max size", e); - } - finishListener.handleEvent(this); - state |= FLAG_FINISHED | FLAG_CLOSED; + Connectors.terminateRequest(exchange); exchange.setPersistent(false); + finishListener.handleEvent(this); + this.state |= FLAG_FINISHED | FLAG_CLOSED; throw UndertowMessages.MESSAGES.requestEntityWasTooLarge(exchange.getMaxEntitySize()); } } Index: 3rdParty_sources/undertow/io/undertow/conduits/GzipStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/GzipStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/GzipStreamSinkConduit.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/GzipStreamSinkConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.conduits; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/conduits/HeadStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/HeadStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/HeadStreamSinkConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/HeadStreamSinkConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.conduits; Index: 3rdParty_sources/undertow/io/undertow/conduits/IdleTimeoutConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/IdleTimeoutConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/IdleTimeoutConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/IdleTimeoutConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.conduits; @@ -30,9 +30,9 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; /** * Conduit that adds support to close a channel once for a specified time no @@ -41,10 +41,12 @@ * @author Norman Maurer */ public class IdleTimeoutConduit implements StreamSinkConduit, StreamSourceConduit { - private volatile XnioExecutor.Key handle; - private static final AtomicReferenceFieldUpdater KEY_UPDATER = AtomicReferenceFieldUpdater.newUpdater(IdleTimeoutConduit.class, XnioExecutor.Key.class, "handle"); + private static final int DELTA = 100; + private volatile XnioExecutor.Key handle; private volatile long idleTimeout; + private volatile long expireTime = -1; + private volatile boolean timedOut = false; private final StreamSinkConduit sink; private final StreamSourceConduit source; @@ -55,9 +57,20 @@ private final Runnable timeoutCommand = new Runnable() { @Override public void run() { + handle = null; + if(expireTime == -1) { + return; + } + long current = System.currentTimeMillis(); + if(current < expireTime) { + //timeout has been bumped, re-schedule + handle = sink.getWriteThread().executeAfter(timeoutCommand, (expireTime - current) + DELTA, TimeUnit.MILLISECONDS); + return; + } + UndertowLogger.REQUEST_LOGGER.tracef("Timing out channel %s due to inactivity"); - safeClose(sink); - safeClose(source); + timedOut = true; + doClose(); if (sink.isWriteResumed()) { if(writeReadyHandler != null) { writeReadyHandler.writeReady(); @@ -71,92 +84,105 @@ } }; + protected void doClose() { + safeClose(sink); + safeClose(source); + } + public IdleTimeoutConduit(StreamSinkConduit sink, StreamSourceConduit source) { this.sink = sink; this.source = source; } - private void handleIdleTimeout() { + private void handleIdleTimeout() throws ClosedChannelException { + if(timedOut) { + return; + } long idleTimeout = this.idleTimeout; - XnioExecutor.Key key = handle; - if (key != null) { - key.remove(); + if(idleTimeout <= 0) { + return; } - if (idleTimeout > 0) { - XnioExecutor.Key k = sink.getWriteThread().executeAfter(timeoutCommand, idleTimeout, TimeUnit.MILLISECONDS); - if (!KEY_UPDATER.compareAndSet(this, key, k)) { - k.remove(); - } + long currentTime = System.currentTimeMillis(); + long expireTimeVar = expireTime; + if(expireTimeVar != -1 && currentTime > expireTimeVar) { + timedOut = true; + doClose(); + throw new ClosedChannelException(); } + expireTime = currentTime + idleTimeout; + XnioExecutor.Key key = handle; + if (key == null) { + handle = sink.getWriteThread().executeAfter(timeoutCommand, idleTimeout, TimeUnit.MILLISECONDS); + } } @Override public int write(ByteBuffer src) throws IOException { - int w = sink.write(src); handleIdleTimeout(); + int w = sink.write(src); return w; } @Override public long write(ByteBuffer[] srcs, int offset, int length) throws IOException { - long w = sink.write(srcs, offset, length); handleIdleTimeout(); + long w = sink.write(srcs, offset, length); return w; } @Override public int writeFinal(ByteBuffer src) throws IOException { - int w = sink.writeFinal(src); handleIdleTimeout(); + int w = sink.writeFinal(src); return w; } @Override public long writeFinal(ByteBuffer[] srcs, int offset, int length) throws IOException { - long w = sink.writeFinal(srcs, offset, length); handleIdleTimeout(); + long w = sink.writeFinal(srcs, offset, length); return w; } @Override public long transferTo(long position, long count, FileChannel target) throws IOException { - long w = source.transferTo(position, count, target); handleIdleTimeout(); + long w = source.transferTo(position, count, target); return w; } @Override public long transferTo(long count, ByteBuffer throughBuffer, StreamSinkChannel target) throws IOException { - long w = source.transferTo(count, throughBuffer, target); handleIdleTimeout(); + long w = source.transferTo(count, throughBuffer, target); return w; } @Override public long read(ByteBuffer[] dsts, int offset, int length) throws IOException { - long r = source.read(dsts, offset, length); handleIdleTimeout(); + long r = source.read(dsts, offset, length); return r; } @Override public int read(ByteBuffer dst) throws IOException { - int r = source.read(dst); handleIdleTimeout(); + int r = source.read(dst); return r; } @Override public long transferFrom(FileChannel src, long position, long count) throws IOException { - long r = sink.transferFrom(src, position, count); handleIdleTimeout(); + long r = sink.transferFrom(src, position, count); return r; } @Override public long transferFrom(StreamSourceChannel source, long count, ByteBuffer throughBuffer) throws IOException { - long r = sink.transferFrom(source, count, throughBuffer); handleIdleTimeout(); + long r = sink.transferFrom(source, count, throughBuffer); return r; } @@ -296,15 +322,13 @@ public void setIdleTimeout(long idleTimeout) { this.idleTimeout = idleTimeout; - XnioExecutor.Key key = handle; - if (key != null) { - key.remove(); + if(idleTimeout > 0) { + expireTime = System.currentTimeMillis() + idleTimeout; + } else { + expireTime = -1; } - if (idleTimeout > 0) { - XnioExecutor.Key k = sink.getWriteThread().executeAfter(timeoutCommand, idleTimeout, TimeUnit.MILLISECONDS); - if (!KEY_UPDATER.compareAndSet(this, key, k)) { - k.remove(); - } + if (idleTimeout > 0 && handle == null) { + handle = sink.getWriteThread().executeAfter(timeoutCommand, idleTimeout + DELTA, TimeUnit.MILLISECONDS); } } } Index: 3rdParty_sources/undertow/io/undertow/conduits/PreChunkedStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/PreChunkedStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/PreChunkedStreamSinkConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/PreChunkedStreamSinkConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.conduits; @@ -65,7 +65,7 @@ public PreChunkedStreamSinkConduit(final StreamSinkConduit next, final ConduitListener finishListener, final Attachable attachable) { super(next); //we don't want the reader to call the finish listener, so we pass null - this.chunkReader = new ChunkReader(attachable, HttpAttachments.RESPONSE_TRAILERS, null, this); + this.chunkReader = new ChunkReader<>(attachable, HttpAttachments.RESPONSE_TRAILERS, null, this); this.finishListener = finishListener; } Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/conduits/RateLimitingStreamSinkConduit.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/conduits/ReadDataStreamSourceConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/ReadDataStreamSourceConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/ReadDataStreamSourceConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/ReadDataStreamSourceConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.conduits; import io.undertow.server.AbstractServerConnection; Index: 3rdParty_sources/undertow/io/undertow/conduits/ReadTimeoutStreamSourceConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/ReadTimeoutStreamSourceConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/ReadTimeoutStreamSourceConduit.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/ReadTimeoutStreamSourceConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,27 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.conduits; import io.undertow.UndertowLogger; +import io.undertow.UndertowOptions; +import io.undertow.server.OpenListener; + import org.xnio.ChannelListeners; import org.xnio.IoUtils; import org.xnio.Options; @@ -12,6 +33,7 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; import java.util.concurrent.TimeUnit; @@ -25,37 +47,63 @@ private XnioExecutor.Key handle; private final StreamConnection connection; + private volatile long expireTime = -1; + private final OpenListener openListener; private static final int FUZZ_FACTOR = 50; //we add 50ms to the timeout to make sure the underlying channel has actually timed out private final Runnable timeoutCommand = new Runnable() { @Override public void run() { + handle = null; + if (expireTime == -1) { + return; + } + long current = System.currentTimeMillis(); + if (current < expireTime) { + //timeout has been bumped, re-schedule + handle = connection.getIoThread().executeAfter(timeoutCommand, (expireTime - current) + FUZZ_FACTOR, TimeUnit.MILLISECONDS); + return; + } UndertowLogger.REQUEST_LOGGER.tracef("Timing out channel %s due to inactivity"); IoUtils.safeClose(connection); if (connection.getSourceChannel().isReadResumed()) { ChannelListeners.invokeChannelListener(connection.getSourceChannel(), connection.getSourceChannel().getReadListener()); } - if(connection.getSinkChannel().isWriteResumed()) { + if (connection.getSinkChannel().isWriteResumed()) { ChannelListeners.invokeChannelListener(connection.getSinkChannel(), connection.getSinkChannel().getWriteListener()); } } }; - public ReadTimeoutStreamSourceConduit(final StreamSourceConduit delegate, StreamConnection connection) { + public ReadTimeoutStreamSourceConduit(final StreamSourceConduit delegate, StreamConnection connection, OpenListener openListener) { super(delegate); this.connection = connection; + this.openListener = openListener; } private void handleReadTimeout(final long ret) throws IOException { - Integer readTimeout = connection.getOption(Options.READ_TIMEOUT); - if (readTimeout != null && readTimeout > 0) { - if (ret == 0 && handle == null) { - handle = super.getReadThread().executeAfter(timeoutCommand, readTimeout + FUZZ_FACTOR, TimeUnit.MILLISECONDS); - } else if (ret > 0 && handle != null) { - handle.remove(); - } + if (!connection.isOpen()) { + return; } + if (ret == 0 && handle != null) { + return; + } + Integer timeout = getTimeout(); + if (timeout == null || timeout <= 0) { + return; + } + long currentTime = System.currentTimeMillis(); + long expireTimeVar = expireTime; + if (expireTimeVar != -1 && currentTime > expireTimeVar) { + IoUtils.safeClose(connection); + throw new ClosedChannelException(); + } + expireTime = currentTime + timeout; + XnioExecutor.Key key = handle; + if (key == null) { + handle = connection.getIoThread().executeAfter(timeoutCommand, timeout, TimeUnit.MILLISECONDS); + } } @Override @@ -88,7 +136,7 @@ @Override public void awaitReadable() throws IOException { - Integer timeout = connection.getOption(Options.READ_TIMEOUT); + Integer timeout = getTimeout(); if (timeout != null && timeout > 0) { super.awaitReadable(timeout + FUZZ_FACTOR, TimeUnit.MILLISECONDS); } else { @@ -98,12 +146,23 @@ @Override public void awaitReadable(long time, TimeUnit timeUnit) throws IOException { - Integer timeout = connection.getOption(Options.READ_TIMEOUT); + Integer timeout = getTimeout(); if (timeout != null && timeout > 0) { long millis = timeUnit.toMillis(time); super.awaitReadable(Math.min(millis, timeout + FUZZ_FACTOR), TimeUnit.MILLISECONDS); } else { super.awaitReadable(time, timeUnit); } } + + private Integer getTimeout() throws IOException { + Integer timeout = connection.getSourceChannel().getOption(Options.READ_TIMEOUT); + Integer idleTimeout = openListener.getUndertowOptions().get(UndertowOptions.IDLE_TIMEOUT); + if ((timeout == null || timeout <= 0) && idleTimeout != null) { + timeout = idleTimeout; + } else if (timeout != null && idleTimeout != null && idleTimeout > 0) { + timeout = Math.min(timeout, idleTimeout); + } + return timeout; + } } Index: 3rdParty_sources/undertow/io/undertow/conduits/WriteTimeoutStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/conduits/Attic/WriteTimeoutStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/conduits/WriteTimeoutStreamSinkConduit.java 8 Sep 2014 10:52:10 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/conduits/WriteTimeoutStreamSinkConduit.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,27 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.conduits; import io.undertow.UndertowLogger; +import io.undertow.UndertowOptions; +import io.undertow.server.OpenListener; + import org.xnio.ChannelListeners; import org.xnio.IoUtils; import org.xnio.Options; @@ -12,11 +33,12 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; import java.nio.channels.FileChannel; import java.util.concurrent.TimeUnit; /** - * Wrapper for read timeout. This should always be the first wrapper applied to the underlying channel. + * Wrapper for write timeout. This should always be the first wrapper applied to the underlying channel. * * @author Stuart Douglas * @see org.xnio.Options#READ_TIMEOUT @@ -25,37 +47,63 @@ private XnioExecutor.Key handle; private final StreamConnection connection; + private volatile long expireTime = -1; + private final OpenListener openListener; private static final int FUZZ_FACTOR = 50; //we add 50ms to the timeout to make sure the underlying channel has actually timed out private final Runnable timeoutCommand = new Runnable() { @Override public void run() { + handle = null; + if (expireTime == -1) { + return; + } + long current = System.currentTimeMillis(); + if (current < expireTime) { + //timeout has been bumped, re-schedule + handle = connection.getIoThread().executeAfter(timeoutCommand, (expireTime - current) + FUZZ_FACTOR, TimeUnit.MILLISECONDS); + return; + } UndertowLogger.REQUEST_LOGGER.tracef("Timing out channel %s due to inactivity"); IoUtils.safeClose(connection); if (connection.getSourceChannel().isReadResumed()) { ChannelListeners.invokeChannelListener(connection.getSourceChannel(), connection.getSourceChannel().getReadListener()); } - if(connection.getSinkChannel().isWriteResumed()) { + if (connection.getSinkChannel().isWriteResumed()) { ChannelListeners.invokeChannelListener(connection.getSinkChannel(), connection.getSinkChannel().getWriteListener()); } } }; - public WriteTimeoutStreamSinkConduit(final StreamSinkConduit delegate, StreamConnection connection) { + public WriteTimeoutStreamSinkConduit(final StreamSinkConduit delegate, StreamConnection connection, OpenListener openListener) { super(delegate); this.connection = connection; + this.openListener = openListener; } private void handleWriteTimeout(final long ret) throws IOException { - Integer writeTimout = connection.getOption(Options.WRITE_TIMEOUT); - if (writeTimout != null && writeTimout > 0) { - if (ret == 0 && handle == null) { - handle = super.getWriteThread().executeAfter(timeoutCommand, writeTimout + FUZZ_FACTOR, TimeUnit.MILLISECONDS); - } else if (ret > 0 && handle != null) { - handle.remove(); - } + if (!connection.isOpen()) { + return; } + if (ret == 0 && handle != null) { + return; + } + Integer timeout = getTimeout(); + if (timeout == null || timeout <= 0) { + return; + } + long currentTime = System.currentTimeMillis(); + long expireTimeVar = expireTime; + if (expireTimeVar != -1 && currentTime > expireTimeVar) { + IoUtils.safeClose(connection); + throw new ClosedChannelException(); + } + expireTime = currentTime + timeout; + XnioExecutor.Key key = handle; + if (key == null) { + handle = connection.getIoThread().executeAfter(timeoutCommand, timeout, TimeUnit.MILLISECONDS); + } } @Override @@ -102,7 +150,7 @@ @Override public void awaitWritable() throws IOException { - Integer timeout = connection.getOption(Options.WRITE_TIMEOUT); + Integer timeout = getTimeout(); if (timeout != null && timeout > 0) { super.awaitWritable(timeout + FUZZ_FACTOR, TimeUnit.MILLISECONDS); } else { @@ -112,12 +160,23 @@ @Override public void awaitWritable(long time, TimeUnit timeUnit) throws IOException { - Integer timeout = connection.getOption(Options.WRITE_TIMEOUT); + Integer timeout = getTimeout(); if (timeout != null && timeout > 0) { long millis = timeUnit.toMillis(time); super.awaitWritable(Math.min(millis, timeout + FUZZ_FACTOR), TimeUnit.MILLISECONDS); } else { super.awaitWritable(time, timeUnit); } } + + private Integer getTimeout() throws IOException { + Integer timeout = connection.getSourceChannel().getOption(Options.WRITE_TIMEOUT); + Integer idleTimeout = openListener.getUndertowOptions().get(UndertowOptions.IDLE_TIMEOUT); + if ((timeout == null || timeout <= 0) && idleTimeout != null) { + timeout = idleTimeout; + } else if (timeout != null && idleTimeout != null && idleTimeout > 0) { + timeout = Math.min(timeout, idleTimeout); + } + return timeout; + } } Index: 3rdParty_sources/undertow/io/undertow/io/AsyncSenderImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/io/Attic/AsyncSenderImpl.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/io/AsyncSenderImpl.java 8 Sep 2014 10:52:16 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/io/AsyncSenderImpl.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.io; import java.io.IOException; @@ -255,22 +273,26 @@ @Override public void send(final String data, final Charset charset, final IoCallback callback) { ByteBuffer bytes = ByteBuffer.wrap(data.getBytes(charset)); - int i = 0; - ByteBuffer[] bufs = null; - while (bytes.hasRemaining()) { - Pooled pooled = exchange.getConnection().getBufferPool().allocate(); - if (bufs == null) { - int noBufs = (bytes.remaining() + pooled.getResource().remaining() - 1) / pooled.getResource().remaining(); //round up division trick - pooledBuffers = new Pooled[noBufs]; - bufs = new ByteBuffer[noBufs]; + if (bytes.remaining() == 0) { + callback.onComplete(exchange, this); + } else { + int i = 0; + ByteBuffer[] bufs = null; + while (bytes.hasRemaining()) { + Pooled pooled = exchange.getConnection().getBufferPool().allocate(); + if (bufs == null) { + int noBufs = (bytes.remaining() + pooled.getResource().remaining() - 1) / pooled.getResource().remaining(); //round up division trick + pooledBuffers = new Pooled[noBufs]; + bufs = new ByteBuffer[noBufs]; + } + pooledBuffers[i] = pooled; + bufs[i] = pooled.getResource(); + Buffers.copy(pooled.getResource(), bytes); + pooled.getResource().flip(); + ++i; } - pooledBuffers[i] = pooled; - bufs[i] = pooled.getResource(); - Buffers.copy(pooled.getResource(), bytes); - pooled.getResource().flip(); - ++i; + send(bufs, callback); } - send(bufs, callback); } @Override Index: 3rdParty_sources/undertow/io/undertow/io/BlockingSenderImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/io/Attic/BlockingSenderImpl.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/io/BlockingSenderImpl.java 8 Sep 2014 10:52:16 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/io/BlockingSenderImpl.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.io; Index: 3rdParty_sources/undertow/io/undertow/io/BufferWritableOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/io/Attic/BufferWritableOutputStream.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/io/BufferWritableOutputStream.java 8 Sep 2014 10:52:16 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/io/BufferWritableOutputStream.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.io; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/io/DefaultIoCallback.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/io/Attic/DefaultIoCallback.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/io/DefaultIoCallback.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/io/DefaultIoCallback.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.io; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/io/IoCallback.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/io/Attic/IoCallback.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/io/IoCallback.java 8 Sep 2014 10:52:16 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/io/IoCallback.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.io; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/io/Sender.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/io/Attic/Sender.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/io/Sender.java 8 Sep 2014 10:52:16 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/io/Sender.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.io; import java.nio.ByteBuffer; Index: 3rdParty_sources/undertow/io/undertow/io/UndertowInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/io/Attic/UndertowInputStream.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/io/UndertowInputStream.java 8 Sep 2014 10:52:16 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/io/UndertowInputStream.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.io; import io.undertow.UndertowMessages; Index: 3rdParty_sources/undertow/io/undertow/io/UndertowOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/io/Attic/UndertowOutputStream.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/io/UndertowOutputStream.java 8 Sep 2014 10:52:16 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/io/UndertowOutputStream.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.io; @@ -313,6 +313,9 @@ if (channel == null) { channel = exchange.getResponseChannel(); } + if(channel == null) { + return; + } StreamSinkChannel channel = this.channel; channel.shutdownWrites(); Channels.flushBlocking(channel); Index: 3rdParty_sources/undertow/io/undertow/predicate/AndPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/AndPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/AndPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/AndPredicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/predicate/AuthenticationRequiredPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/AuthenticationRequiredPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/AuthenticationRequiredPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/AuthenticationRequiredPredicate.java 25 Nov 2014 10:46:53 -0000 1.1.2.3 @@ -36,13 +36,13 @@ @Override public Map> parameters() { - final Map> params = new HashMap>(); + final Map> params = new HashMap<>(); return params; } @Override public Set requiredParameters() { - final Set params = new HashSet(); + final Set params = new HashSet<>(); return params; } Index: 3rdParty_sources/undertow/io/undertow/predicate/ContainsPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/ContainsPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/ContainsPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/ContainsPredicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.predicate; @@ -65,15 +65,15 @@ @Override public Map> parameters() { - final Map> params = new HashMap>(); + final Map> params = new HashMap<>(); params.put("value", ExchangeAttribute.class); params.put("search", String[].class); return params; } @Override public Set requiredParameters() { - final Set params = new HashSet(); + final Set params = new HashSet<>(); params.add("value"); params.add("search"); return params; Index: 3rdParty_sources/undertow/io/undertow/predicate/EqualsPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/EqualsPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/EqualsPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/EqualsPredicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.predicate; @@ -69,7 +69,7 @@ @Override public Map> parameters() { - final Map> params = new HashMap>(); + final Map> params = new HashMap<>(); params.put("value", ExchangeAttribute[].class); return params; } Index: 3rdParty_sources/undertow/io/undertow/predicate/ExistsPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/ExistsPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/ExistsPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/ExistsPredicate.java 25 Nov 2014 10:46:53 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.predicate; @@ -57,7 +57,7 @@ @Override public Map> parameters() { - final Map> params = new HashMap>(); + final Map> params = new HashMap<>(); params.put("value", ExchangeAttribute.class); return params; } Index: 3rdParty_sources/undertow/io/undertow/predicate/FalsePredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/FalsePredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/FalsePredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/FalsePredicate.java 25 Nov 2014 10:46:53 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/predicate/MaxContentSizePredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/MaxContentSizePredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/MaxContentSizePredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/MaxContentSizePredicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,5 +1,27 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + import io.undertow.server.HttpServerExchange; import io.undertow.util.Headers; @@ -20,9 +42,38 @@ @Override public boolean resolve(final HttpServerExchange value) { final String length = value.getResponseHeaders().getFirst(Headers.CONTENT_LENGTH); - if(length == null) { + if (length == null) { return false; } return Long.parseLong(length) > maxSize; } + + public static class Builder implements PredicateBuilder { + + @Override + public String name() { + return "max-content-size"; + } + + @Override + public Map> parameters() { + return Collections.>singletonMap("value", Long.class); + } + + @Override + public Set requiredParameters() { + return Collections.singleton("value"); + } + + @Override + public String defaultParameter() { + return "value"; + } + + @Override + public Predicate build(final Map config) { + Long max = (Long) config.get("value"); + return new MaxContentSizePredicate(max); + } + } } Index: 3rdParty_sources/undertow/io/undertow/predicate/MethodPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/MethodPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/MethodPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/MethodPredicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/predicate/MinContentSizePredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/MinContentSizePredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/MinContentSizePredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/MinContentSizePredicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,5 +1,27 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + import io.undertow.server.HttpServerExchange; import io.undertow.util.Headers; @@ -20,9 +42,38 @@ @Override public boolean resolve(final HttpServerExchange value) { final String length = value.getResponseHeaders().getFirst(Headers.CONTENT_LENGTH); - if(length == null) { + if (length == null) { return false; } return Long.parseLong(length) < minSize; } + + public static class Builder implements PredicateBuilder { + + @Override + public String name() { + return "min-content-size"; + } + + @Override + public Map> parameters() { + return Collections.>singletonMap("value", Long.class); + } + + @Override + public Set requiredParameters() { + return Collections.singleton("value"); + } + + @Override + public String defaultParameter() { + return "value"; + } + + @Override + public Predicate build(final Map config) { + Long max = (Long) config.get("value"); + return new MinContentSizePredicate(max); + } + } } Index: 3rdParty_sources/undertow/io/undertow/predicate/NotPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/NotPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/NotPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/NotPredicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/predicate/OrPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/OrPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/OrPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/OrPredicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/predicate/PathMatchPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/PathMatchPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/PathMatchPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/PathMatchPredicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import java.util.Collections; @@ -15,7 +33,7 @@ private final PathMatcher pathMatcher; public PathMatchPredicate(final String... paths) { - PathMatcher matcher = new PathMatcher(); + PathMatcher matcher = new PathMatcher<>(); for(String path : paths) { if(!path.startsWith("/")) { matcher.addExactPath("/" + path, Boolean.TRUE); Index: 3rdParty_sources/undertow/io/undertow/predicate/PathPrefixPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/PathPrefixPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/PathPrefixPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/PathPrefixPredicate.java 25 Nov 2014 10:46:53 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import java.util.Collections; @@ -15,7 +33,7 @@ private final PathMatcher pathMatcher; public PathPrefixPredicate(final String... paths) { - PathMatcher matcher = new PathMatcher(); + PathMatcher matcher = new PathMatcher<>(); for(String path : paths) { if(!path.startsWith("/")) { matcher.addPrefixPath("/" + path, Boolean.TRUE); @@ -30,7 +48,13 @@ public boolean resolve(final HttpServerExchange value) { final String relativePath = value.getRelativePath(); PathMatcher.PathMatch result = pathMatcher.match(relativePath); - return result.getValue() == Boolean.TRUE; + + boolean matches = result.getValue() == Boolean.TRUE; + if(matches) { + Map context = value.getAttachment(PREDICATE_CONTEXT); + context.put("remaining", result.getRemaining()); + } + return matches; } public static class Builder implements PredicateBuilder { Index: 3rdParty_sources/undertow/io/undertow/predicate/PathSuffixPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/PathSuffixPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/PathSuffixPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/PathSuffixPredicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import java.util.Collections; Index: 3rdParty_sources/undertow/io/undertow/predicate/PathTemplatePredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/PathTemplatePredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/PathTemplatePredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/PathTemplatePredicate.java 25 Nov 2014 10:46:53 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import java.util.HashMap; @@ -25,7 +43,7 @@ @Override public boolean resolve(final HttpServerExchange exchange) { - final Map params = new HashMap(); + final Map params = new HashMap<>(); boolean result = this.value.matches(attribute.readAttribute(exchange), params); if (result) { Map context = exchange.getAttachment(PREDICATE_CONTEXT); @@ -45,15 +63,15 @@ @Override public Map> parameters() { - final Map> params = new HashMap>(); + final Map> params = new HashMap<>(); params.put("value", String.class); params.put("match", ExchangeAttribute.class); return params; } @Override public Set requiredParameters() { - final Set params = new HashSet(); + final Set params = new HashSet<>(); params.add("value"); return params; } Index: 3rdParty_sources/undertow/io/undertow/predicate/Predicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/Predicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/Predicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/Predicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import java.util.Map; Index: 3rdParty_sources/undertow/io/undertow/predicate/PredicateBuilder.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/PredicateBuilder.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/PredicateBuilder.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/PredicateBuilder.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.predicate; Index: 3rdParty_sources/undertow/io/undertow/predicate/PredicateParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/PredicateParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/PredicateParser.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/PredicateParser.java 25 Nov 2014 10:46:53 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.predicate; @@ -73,7 +73,7 @@ private static Map loadBuilders(final ClassLoader classLoader) { ServiceLoader loader = ServiceLoader.load(PredicateBuilder.class, classLoader); - final Map ret = new HashMap(); + final Map ret = new HashMap<>(); for (PredicateBuilder builder : loader) { if (ret.containsKey(builder.name())) { if (ret.get(builder.name()).getClass() != builder.getClass()) { @@ -102,11 +102,11 @@ //shunting yard algorithm //gets rid or parentheses and fixes up operator ordering Deque tokens = tokenize(string); - Deque operatorStack = new ArrayDeque(); + Deque operatorStack = new ArrayDeque<>(); //the output, consisting of predicate nodes and string representations of operators //it is a bit yuck mixing up the types, but whatever - Deque output = new ArrayDeque(); + Deque output = new ArrayDeque<>(); while (!tokens.isEmpty()) { Token token = tokens.poll(); @@ -198,7 +198,7 @@ } Token next = tokens.peek(); if (next.token.equals("[")) { - final Map values = new HashMap(); + final Map values = new HashMap<>(); tokens.poll(); next = tokens.poll(); @@ -296,7 +296,7 @@ } Class componentType = type.getComponentType(); - final List values = new ArrayList(); + final List values = new ArrayList<>(); Token token = tokens.poll(); while (token != null) { Token commaOrEnd = tokens.poll(); @@ -327,7 +327,7 @@ } private static void checkParameters(final String string, int pos, final Map values, final PredicateBuilder builder) { - final Set required = new HashSet(builder.requiredParameters()); + final Set required = new HashSet<>(builder.requiredParameters()); for (String key : values.keySet()) { required.remove(key); } @@ -414,7 +414,7 @@ int pos = 0; StringBuilder current = new StringBuilder(); - Deque ret = new ArrayDeque(); + Deque ret = new ArrayDeque<>(); while (pos < string.length()) { char c = string.charAt(pos); if (currentStringDelim != 0) { Index: 3rdParty_sources/undertow/io/undertow/predicate/Predicates.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/Predicates.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/Predicates.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/Predicates.java 25 Nov 2014 10:46:53 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import io.undertow.attribute.ExchangeAttribute; Index: 3rdParty_sources/undertow/io/undertow/predicate/PredicatesHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/PredicatesHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/PredicatesHandler.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/PredicatesHandler.java 25 Nov 2014 10:46:53 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import io.undertow.server.HandlerWrapper; @@ -17,7 +35,7 @@ public class PredicatesHandler implements HttpHandler { private volatile Holder[] handlers = new Holder[0]; - private final HttpHandler next; + private volatile HttpHandler next; //non-static, so multiple handlers can co-exist private final AttachmentKey CURRENT_POSITION = AttachmentKey.create(Integer.class); @@ -69,6 +87,14 @@ return addPredicatedHandler(handler.getPredicate(), handler.getHandler()); } + public void setNext(HttpHandler next) { + this.next = next; + } + + public HttpHandler getNext() { + return next; + } + private static final class Holder { final Predicate predicate; final HttpHandler handler; Index: 3rdParty_sources/undertow/io/undertow/predicate/RegularExpressionPredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/RegularExpressionPredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/RegularExpressionPredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/RegularExpressionPredicate.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import java.util.HashMap; @@ -67,7 +85,7 @@ @Override public Map> parameters() { - final Map> params = new HashMap>(); + final Map> params = new HashMap<>(); params.put("pattern", String.class); params.put("value", ExchangeAttribute.class); params.put("full-match", Boolean.class); @@ -76,7 +94,7 @@ @Override public Set requiredParameters() { - final Set params = new HashSet(); + final Set params = new HashSet<>(); params.add("pattern"); return params; } Index: 3rdParty_sources/undertow/io/undertow/predicate/TruePredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/predicate/Attic/TruePredicate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/predicate/TruePredicate.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/predicate/TruePredicate.java 25 Nov 2014 10:46:53 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.predicate; import io.undertow.server.HttpServerExchange; Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/ajp/AbstractAjpClientStreamSinkChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/ajp/AbstractAjpClientStreamSourceChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/ajp/AbstractAjpParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/ajp/AjpClientChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/ajp/AjpClientFramePriority.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/ajp/AjpClientRequestClientStreamSinkChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/ajp/AjpClientResponseStreamSourceChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/ajp/AjpConstants.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/ajp/AjpResponseParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/ajp/AjpUtils.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyControlFrameStreamSinkChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyFramePriority.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyGoAwayParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyGoAwayStreamSinkChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyGoAwayStreamSourceChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyHeaderBlockParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyHeadersParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyPingParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyPingStreamSinkChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyPingStreamSourceChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyProtocolUtils.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyPushBackParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyRstStreamParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyRstStreamSinkChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyRstStreamStreamSourceChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdySetting.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdySettingsParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdySettingsStreamSourceChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyStreamSinkChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyStreamSourceChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyStreamStreamSinkChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyStreamStreamSourceChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdySynReplyParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdySynReplyStreamSinkChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdySynReplyStreamSourceChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdySynStreamParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdySynStreamStreamSinkChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdySynStreamStreamSourceChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyWindowUpdateParser.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/SpdyWindowUpdateStreamSinkChannel.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/protocols/spdy/StreamErrorException.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/security/api/AuthenticatedSessionManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/api/Attic/AuthenticatedSessionManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/api/AuthenticatedSessionManager.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/api/AuthenticatedSessionManager.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.api; Index: 3rdParty_sources/undertow/io/undertow/security/api/AuthenticationMechanism.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/api/Attic/AuthenticationMechanism.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/api/AuthenticationMechanism.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/api/AuthenticationMechanism.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.api; Index: 3rdParty_sources/undertow/io/undertow/security/api/AuthenticationMechanismFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/api/Attic/AuthenticationMechanismFactory.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/api/AuthenticationMechanismFactory.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/api/AuthenticationMechanismFactory.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.security.api; import io.undertow.server.handlers.form.FormParserFactory; Index: 3rdParty_sources/undertow/io/undertow/security/api/AuthenticationMode.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/api/Attic/AuthenticationMode.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/api/AuthenticationMode.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/api/AuthenticationMode.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.api; Index: 3rdParty_sources/undertow/io/undertow/security/api/GSSAPIServerSubjectFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/api/Attic/GSSAPIServerSubjectFactory.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/api/GSSAPIServerSubjectFactory.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/api/GSSAPIServerSubjectFactory.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.api; Index: 3rdParty_sources/undertow/io/undertow/security/api/NonceManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/api/Attic/NonceManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/api/NonceManager.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/api/NonceManager.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.api; Index: 3rdParty_sources/undertow/io/undertow/security/api/NotificationReceiver.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/api/Attic/NotificationReceiver.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/api/NotificationReceiver.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/api/NotificationReceiver.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.api; Index: 3rdParty_sources/undertow/io/undertow/security/api/SecurityContext.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/api/Attic/SecurityContext.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/api/SecurityContext.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/api/SecurityContext.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.api; Index: 3rdParty_sources/undertow/io/undertow/security/api/SecurityContextFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/api/Attic/SecurityContextFactory.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/api/SecurityContextFactory.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/api/SecurityContextFactory.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.api; Index: 3rdParty_sources/undertow/io/undertow/security/api/SecurityNotification.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/api/Attic/SecurityNotification.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/api/SecurityNotification.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/api/SecurityNotification.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.api; Index: 3rdParty_sources/undertow/io/undertow/security/api/SessionNonceManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/api/Attic/SessionNonceManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/api/SessionNonceManager.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/api/SessionNonceManager.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.api; Index: 3rdParty_sources/undertow/io/undertow/security/handlers/AbstractConfidentialityHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/handlers/Attic/AbstractConfidentialityHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/handlers/AbstractConfidentialityHandler.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/handlers/AbstractConfidentialityHandler.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.handlers; @@ -41,15 +41,15 @@ @Override public void handleRequest(HttpServerExchange exchange) throws Exception { - if (isConfidential(exchange) || (confidentialityRequired(exchange) == false)) { + if (isConfidential(exchange) || !confidentialityRequired(exchange)) { next.handleRequest(exchange); } else { try { URI redirectUri = getRedirectURI(exchange); exchange.setResponseCode(302); exchange.getResponseHeaders().put(Headers.LOCATION, redirectUri.toString()); - } catch (URISyntaxException e) { + } catch (Exception e) { UndertowLogger.REQUEST_LOGGER.exceptionProcessingRequest(e); exchange.setResponseCode(500); } @@ -74,6 +74,8 @@ * * This method currently returns true for all requests, sub-classes can override this to provide a custom check. * + * TODO: we should deprecate this and just use a predicate to decide to execute the handler instead + * * @param exchange - The {@see HttpServerExchange} for the request being processed. * @return true if the request requires confidentiality, false otherwise. */ Index: 3rdParty_sources/undertow/io/undertow/security/handlers/AuthenticationCallHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/handlers/Attic/AuthenticationCallHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/handlers/AuthenticationCallHandler.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/handlers/AuthenticationCallHandler.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.handlers; Index: 3rdParty_sources/undertow/io/undertow/security/handlers/AuthenticationConstraintHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/handlers/Attic/AuthenticationConstraintHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/handlers/AuthenticationConstraintHandler.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/handlers/AuthenticationConstraintHandler.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.handlers; Index: 3rdParty_sources/undertow/io/undertow/security/handlers/AuthenticationMechanismsHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/handlers/Attic/AuthenticationMechanismsHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/handlers/AuthenticationMechanismsHandler.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/handlers/AuthenticationMechanismsHandler.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.handlers; Index: 3rdParty_sources/undertow/io/undertow/security/handlers/NotificationReceiverHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/handlers/Attic/NotificationReceiverHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/handlers/NotificationReceiverHandler.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/handlers/NotificationReceiverHandler.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.handlers; Index: 3rdParty_sources/undertow/io/undertow/security/handlers/SecurityActions.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/handlers/Attic/SecurityActions.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/handlers/SecurityActions.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/handlers/SecurityActions.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.handlers; Index: 3rdParty_sources/undertow/io/undertow/security/handlers/SecurityInitialHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/handlers/Attic/SecurityInitialHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/handlers/SecurityInitialHandler.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/handlers/SecurityInitialHandler.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.handlers; Index: 3rdParty_sources/undertow/io/undertow/security/handlers/SinglePortConfidentialityHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/handlers/Attic/SinglePortConfidentialityHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/handlers/SinglePortConfidentialityHandler.java 8 Sep 2014 10:52:17 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/handlers/SinglePortConfidentialityHandler.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.handlers; Index: 3rdParty_sources/undertow/io/undertow/security/idm/Account.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/idm/Attic/Account.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/idm/Account.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/idm/Account.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.idm; Index: 3rdParty_sources/undertow/io/undertow/security/idm/Credential.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/idm/Attic/Credential.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/idm/Credential.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/idm/Credential.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.idm; Index: 3rdParty_sources/undertow/io/undertow/security/idm/DigestAlgorithm.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/idm/Attic/DigestAlgorithm.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/idm/DigestAlgorithm.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/idm/DigestAlgorithm.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.idm; @@ -37,7 +37,7 @@ static { DigestAlgorithm[] algorithms = DigestAlgorithm.values(); - Map byToken = new HashMap(algorithms.length); + Map byToken = new HashMap<>(algorithms.length); for (DigestAlgorithm current : algorithms) { byToken.put(current.token, current); } Index: 3rdParty_sources/undertow/io/undertow/security/idm/DigestCredential.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/idm/Attic/DigestCredential.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/idm/DigestCredential.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/idm/DigestCredential.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.idm; Index: 3rdParty_sources/undertow/io/undertow/security/idm/ExternalCredential.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/idm/Attic/ExternalCredential.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/idm/ExternalCredential.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/idm/ExternalCredential.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.security.idm; import java.io.Serializable; Index: 3rdParty_sources/undertow/io/undertow/security/idm/GSSContextCredential.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/idm/Attic/GSSContextCredential.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/idm/GSSContextCredential.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/idm/GSSContextCredential.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.idm; Index: 3rdParty_sources/undertow/io/undertow/security/idm/IdentityManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/idm/Attic/IdentityManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/idm/IdentityManager.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/idm/IdentityManager.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.idm; Index: 3rdParty_sources/undertow/io/undertow/security/idm/PasswordCredential.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/idm/Attic/PasswordCredential.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/idm/PasswordCredential.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/idm/PasswordCredential.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.idm; Index: 3rdParty_sources/undertow/io/undertow/security/idm/X509CertificateCredential.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/idm/Attic/X509CertificateCredential.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/idm/X509CertificateCredential.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/idm/X509CertificateCredential.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.idm; Index: 3rdParty_sources/undertow/io/undertow/security/impl/AuthenticationInfoToken.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/AuthenticationInfoToken.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/AuthenticationInfoToken.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/AuthenticationInfoToken.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; @@ -41,13 +41,13 @@ private static final HeaderTokenParser TOKEN_PARSER; static { - Map expected = new LinkedHashMap( + Map expected = new LinkedHashMap<>( AuthenticationInfoToken.values().length); for (AuthenticationInfoToken current : AuthenticationInfoToken.values()) { expected.put(current.getName(), current); } - TOKEN_PARSER = new HeaderTokenParser(Collections.unmodifiableMap(expected)); + TOKEN_PARSER = new HeaderTokenParser<>(Collections.unmodifiableMap(expected)); } private final String name; Index: 3rdParty_sources/undertow/io/undertow/security/impl/BasicAuthenticationMechanism.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/BasicAuthenticationMechanism.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/BasicAuthenticationMechanism.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/BasicAuthenticationMechanism.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; Index: 3rdParty_sources/undertow/io/undertow/security/impl/CachedAuthenticatedSessionMechanism.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/CachedAuthenticatedSessionMechanism.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/CachedAuthenticatedSessionMechanism.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/CachedAuthenticatedSessionMechanism.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; Index: 3rdParty_sources/undertow/io/undertow/security/impl/ClientCertAuthenticationMechanism.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/ClientCertAuthenticationMechanism.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/ClientCertAuthenticationMechanism.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/ClientCertAuthenticationMechanism.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; Index: 3rdParty_sources/undertow/io/undertow/security/impl/DigestAuthenticationMechanism.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/DigestAuthenticationMechanism.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/DigestAuthenticationMechanism.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/DigestAuthenticationMechanism.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,5 +1,6 @@ /* - * Copyright 2012 Red Hat, Inc., and individual contributors + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; @@ -72,7 +73,7 @@ private static final Set MANDATORY_REQUEST_TOKENS; static { - Set mandatoryTokens = new HashSet(); + Set mandatoryTokens = new HashSet<>(); mandatoryTokens.add(DigestAuthorizationToken.USERNAME); mandatoryTokens.add(DigestAuthorizationToken.REALM); mandatoryTokens.add(DigestAuthorizationToken.NONCE); @@ -112,7 +113,7 @@ this.nonceManager = nonceManager; this.mechanismName = mechanismName; - if (supportedQops.size() > 0) { + if (!supportedQops.isEmpty()) { StringBuilder sb = new StringBuilder(); Iterator it = supportedQops.iterator(); sb.append(it.next().getToken()); @@ -166,12 +167,12 @@ DigestContext context = exchange.getAttachment(DigestContext.ATTACHMENT_KEY); Map parsedHeader = context.getParsedHeader(); // Step 1 - Verify the set of tokens received to ensure valid values. - Set mandatoryTokens = new HashSet(MANDATORY_REQUEST_TOKENS); - if (supportedAlgorithms.contains(DigestAlgorithm.MD5) == false) { + Set mandatoryTokens = new HashSet<>(MANDATORY_REQUEST_TOKENS); + if (!supportedAlgorithms.contains(DigestAlgorithm.MD5)) { // If we don't support MD5 then the client must choose an algorithm as we can not fall back to MD5. mandatoryTokens.add(DigestAuthorizationToken.ALGORITHM); } - if (supportedQops.isEmpty() == false && supportedQops.contains(DigestQop.AUTH) == false) { + if (!supportedQops.isEmpty() && !supportedQops.contains(DigestQop.AUTH)) { // If we do not support auth then we are mandating auth-int so force the client to send a QOP mandatoryTokens.add(DigestAuthorizationToken.MESSAGE_QOP); } @@ -180,7 +181,7 @@ // This check is early as is increases the list of mandatory tokens. if (parsedHeader.containsKey(DigestAuthorizationToken.MESSAGE_QOP)) { qop = DigestQop.forName(parsedHeader.get(DigestAuthorizationToken.MESSAGE_QOP)); - if (qop == null || supportedQops.contains(qop) == false) { + if (qop == null || !supportedQops.contains(qop)) { // We are also ensuring the client is not trying to force a qop that has been disabled. REQUEST_LOGGER.invalidTokenReceived(DigestAuthorizationToken.MESSAGE_QOP.getName(), parsedHeader.get(DigestAuthorizationToken.MESSAGE_QOP)); @@ -205,7 +206,7 @@ } // Perform some validation of the remaining tokens. - if (realmName.equals(parsedHeader.get(DigestAuthorizationToken.REALM)) == false) { + if (!realmName.equals(parsedHeader.get(DigestAuthorizationToken.REALM))) { REQUEST_LOGGER.invalidTokenReceived(DigestAuthorizationToken.REALM.getName(), parsedHeader.get(DigestAuthorizationToken.REALM)); // TODO - This actually needs to result in a HTTP 400 Bad Request response and not a new challenge. @@ -215,7 +216,7 @@ // TODO - Validate the URI if (parsedHeader.containsKey(DigestAuthorizationToken.OPAQUE)) { - if (OPAQUE_VALUE.equals(parsedHeader.get(DigestAuthorizationToken.OPAQUE)) == false) { + if (!OPAQUE_VALUE.equals(parsedHeader.get(DigestAuthorizationToken.OPAQUE))) { REQUEST_LOGGER.invalidTokenReceived(DigestAuthorizationToken.OPAQUE.getName(), parsedHeader.get(DigestAuthorizationToken.OPAQUE)); return AuthenticationMechanismOutcome.NOT_AUTHENTICATED; @@ -225,7 +226,7 @@ DigestAlgorithm algorithm; if (parsedHeader.containsKey(DigestAuthorizationToken.ALGORITHM)) { algorithm = DigestAlgorithm.forName(parsedHeader.get(DigestAuthorizationToken.ALGORITHM)); - if (algorithm == null || supportedAlgorithms.contains(algorithm) == false) { + if (algorithm == null || !supportedAlgorithms.contains(algorithm)) { // We are also ensuring the client is not trying to force an algorithm that has been disabled. REQUEST_LOGGER.invalidTokenReceived(DigestAuthorizationToken.ALGORITHM.getName(), parsedHeader.get(DigestAuthorizationToken.ALGORITHM)); @@ -273,7 +274,7 @@ } // Step 3 - Verify that the nonce was eligible to be used. - if (validateNonceUse(context, parsedHeader, exchange) == false) { + if (!validateNonceUse(context, parsedHeader, exchange)) { // TODO - This is the right place to make use of the decision but the check needs to be much much sooner // otherwise a failure server // side could leave a packet that could be 're-played' after the failed auth. @@ -425,12 +426,12 @@ String theChallenge = rb.toString(); HeaderMap responseHeader = exchange.getResponseHeaders(); - if (supportedAlgorithms.size() > 0) { + if (supportedAlgorithms.isEmpty()) { + responseHeader.add(WWW_AUTHENTICATE, theChallenge); + } else { for (DigestAlgorithm current : supportedAlgorithms) { responseHeader.add(WWW_AUTHENTICATE, String.format(theChallenge, current.getToken())); } - } else { - responseHeader.add(WWW_AUTHENTICATE, theChallenge); } return new ChallengeResult(true, UNAUTHORIZED); @@ -441,7 +442,7 @@ DigestQop qop = context.getQop(); String currentNonce = context.getNonce(); String nextNonce = nonceManager.nextNonce(currentNonce, exchange); - if (qop != null || nextNonce.equals(currentNonce) == false) { + if (qop != null || !nextNonce.equals(currentNonce)) { StringBuilder sb = new StringBuilder(); sb.append(NEXT_NONCE).append("=\"").append(nextNonce).append("\""); if (qop != null) { @@ -585,7 +586,7 @@ @Override public byte[] getSessionData() { - if (context.getAlgorithm().isSession() == false) { + if (!context.getAlgorithm().isSession()) { throw MESSAGES.noSessionData(); } Index: 3rdParty_sources/undertow/io/undertow/security/impl/DigestAuthorizationToken.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/DigestAuthorizationToken.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/DigestAuthorizationToken.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/DigestAuthorizationToken.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; @@ -48,13 +48,13 @@ private static final HeaderTokenParser TOKEN_PARSER; static { - Map expected = new LinkedHashMap( + Map expected = new LinkedHashMap<>( DigestAuthorizationToken.values().length); for (DigestAuthorizationToken current : DigestAuthorizationToken.values()) { expected.put(current.getName(), current); } - TOKEN_PARSER = new HeaderTokenParser(Collections.unmodifiableMap(expected)); + TOKEN_PARSER = new HeaderTokenParser<>(Collections.unmodifiableMap(expected)); } private final String name; Index: 3rdParty_sources/undertow/io/undertow/security/impl/DigestQop.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/DigestQop.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/DigestQop.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/DigestQop.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; @@ -35,7 +35,7 @@ static { DigestQop[] qops = DigestQop.values(); - Map byToken = new HashMap(qops.length); + Map byToken = new HashMap<>(qops.length); for (DigestQop current : qops) { byToken.put(current.token, current); } Index: 3rdParty_sources/undertow/io/undertow/security/impl/DigestWWWAuthenticateToken.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/DigestWWWAuthenticateToken.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/DigestWWWAuthenticateToken.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/DigestWWWAuthenticateToken.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; @@ -45,13 +45,13 @@ private static final HeaderTokenParser TOKEN_PARSER; static { - Map expected = new LinkedHashMap( + Map expected = new LinkedHashMap<>( DigestWWWAuthenticateToken.values().length); for (DigestWWWAuthenticateToken current : DigestWWWAuthenticateToken.values()) { expected.put(current.getName(), current); } - TOKEN_PARSER = new HeaderTokenParser(Collections.unmodifiableMap(expected)); + TOKEN_PARSER = new HeaderTokenParser<>(Collections.unmodifiableMap(expected)); } private final String name; Index: 3rdParty_sources/undertow/io/undertow/security/impl/ExternalAuthenticationMechanism.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/ExternalAuthenticationMechanism.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/ExternalAuthenticationMechanism.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/ExternalAuthenticationMechanism.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.security.impl; import io.undertow.security.api.AuthenticationMechanism; Index: 3rdParty_sources/undertow/io/undertow/security/impl/FormAuthenticationMechanism.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/FormAuthenticationMechanism.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/FormAuthenticationMechanism.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/FormAuthenticationMechanism.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; Index: 3rdParty_sources/undertow/io/undertow/security/impl/GSSAPIAuthenticationMechanism.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/GSSAPIAuthenticationMechanism.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/GSSAPIAuthenticationMechanism.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/GSSAPIAuthenticationMechanism.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; @@ -142,6 +142,16 @@ if (responseChallenge != null) { header = NEGOTIATE_PREFIX + FlexBase64.encodeString(responseChallenge, false); } + } else { + Subject server = null; + try { + server = subjectFactory.getSubjectForHost(getHostName(exchange)); + } catch (GeneralSecurityException e) { + // Deliberately ignore - no Subject so don't offer GSSAPI is our main concern here. + } + if (server == null) { + return new ChallengeResult(false); + } } exchange.getResponseHeaders().add(WWW_AUTHENTICATE, header); @@ -267,7 +277,7 @@ } Principal getPrincipal() { - if (isEstablished() == false) { + if (!isEstablished()) { throw new IllegalStateException("No established GSSContext to use for the Principal."); } Index: 3rdParty_sources/undertow/io/undertow/security/impl/InMemorySingleSignOnManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/InMemorySingleSignOnManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/InMemorySingleSignOnManager.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/InMemorySingleSignOnManager.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.security.impl; import java.util.Collections; @@ -19,7 +37,7 @@ private static final SecureRandomSessionIdGenerator SECURE_RANDOM_SESSION_ID_GENERATOR = new SecureRandomSessionIdGenerator(); - private final Map ssoEntries = new ConcurrentHashMap(); + private final Map ssoEntries = new ConcurrentHashMap<>(); @Override public SingleSignOn findSingleSignOn(String ssoId) { @@ -43,7 +61,7 @@ private final String id; private final Account account; private final String mechanismName; - private final Map sessions = new CopyOnWriteMap(); + private final Map sessions = new CopyOnWriteMap<>(); SimpleSingleSignOnEntry(String id, Account account, String mechanismName) { this.id = id; Index: 3rdParty_sources/undertow/io/undertow/security/impl/SecurityActions.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/SecurityActions.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/SecurityActions.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/SecurityActions.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; Index: 3rdParty_sources/undertow/io/undertow/security/impl/SecurityContextFactoryImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/SecurityContextFactoryImpl.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/SecurityContextFactoryImpl.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/SecurityContextFactoryImpl.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; Index: 3rdParty_sources/undertow/io/undertow/security/impl/SecurityContextImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/SecurityContextImpl.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/SecurityContextImpl.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/SecurityContextImpl.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; @@ -55,9 +55,9 @@ private String programaticMechName = "Programatic"; private AuthenticationState authenticationState = AuthenticationState.NOT_ATTEMPTED; private final HttpServerExchange exchange; - private final List authMechanisms = new ArrayList(); + private final List authMechanisms = new ArrayList<>(); private final IdentityManager identityManager; - private final List notificationReceivers = new ArrayList(); + private final List notificationReceivers = new ArrayList<>(); // Maybe this will need to be a custom mechanism that doesn't exchange tokens with the client but will then Index: 3rdParty_sources/undertow/io/undertow/security/impl/SimpleNonceManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/SimpleNonceManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/SimpleNonceManager.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/SimpleNonceManager.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.security.impl; Index: 3rdParty_sources/undertow/io/undertow/security/impl/SingleSignOn.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/SingleSignOn.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/SingleSignOn.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/SingleSignOn.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,7 +1,23 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.security.impl; -import java.io.Closeable; - import io.undertow.security.idm.Account; import io.undertow.server.session.Session; import io.undertow.server.session.SessionManager; @@ -10,7 +26,7 @@ * @author Stuart Douglas * @author Paul Ferraro */ -public interface SingleSignOn extends Iterable, Closeable { +public interface SingleSignOn extends Iterable, AutoCloseable { /** * Returns the unique identifier for this SSO. Index: 3rdParty_sources/undertow/io/undertow/security/impl/SingleSignOnAuthenticationMechanism.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/SingleSignOnAuthenticationMechanism.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/SingleSignOnAuthenticationMechanism.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/SingleSignOnAuthenticationMechanism.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.security.impl; import io.undertow.security.api.AuthenticationMechanism; @@ -50,9 +68,9 @@ public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange, SecurityContext securityContext) { Cookie cookie = exchange.getRequestCookies().get(cookieName); if (cookie != null) { - final SingleSignOn sso = this.manager.findSingleSignOn(cookie.getValue()); - if (sso != null) { - try { + final String ssoId = cookie.getValue(); + try (SingleSignOn sso = this.manager.findSingleSignOn(ssoId)) { + if (sso != null) { Account verified = securityContext.getIdentityManager().verify(sso.getAccount()); if (verified == null) { //we return not attempted here to allow other mechanisms to proceed as normal @@ -65,21 +83,11 @@ @Override public void handleNotification(SecurityNotification notification) { if (notification.getEventType() == SecurityNotification.EventType.LOGGED_OUT) { - try { - sso.remove(session); - for (Session associatedSession : sso) { - associatedSession.invalidate(null); - } - manager.removeSingleSignOn(sso.getId()); - } finally { - sso.close(); - } + manager.removeSingleSignOn(ssoId); } } }); return AuthenticationMechanismOutcome.AUTHENTICATED; - } finally { - sso.close(); } } clearSsoCookie(exchange); @@ -119,14 +127,10 @@ SecurityContext sc = exchange.getSecurityContext(); Account account = sc.getAuthenticatedAccount(); if (account != null) { - SingleSignOn sso = manager.createSingleSignOn(account, sc.getMechanismName()); - try { - + try (SingleSignOn sso = manager.createSingleSignOn(account, sc.getMechanismName())) { Session session = getSession(exchange); registerSessionIfRequired(sso, session); exchange.getResponseCookies().put(cookieName, new CookieImpl(cookieName, sso.getId()).setHttpOnly(httpOnly).setSecure(secure).setDomain(domain).setPath(path)); - } finally { - sso.close(); } } return factory.create(); @@ -144,18 +148,19 @@ public void sessionDestroyed(Session session, HttpServerExchange exchange, SessionDestroyedReason reason) { String ssoId = (String) session.getAttribute(SSO_SESSION_ATTRIBUTE); if (ssoId != null) { - SingleSignOn sso = manager.findSingleSignOn(ssoId); - if (sso != null) { - try { + try (SingleSignOn sso = manager.findSingleSignOn(ssoId)) { + if (sso != null) { sso.remove(session); if (reason == SessionDestroyedReason.INVALIDATED) { for (Session associatedSession : sso) { associatedSession.invalidate(null); + sso.remove(associatedSession); } + } + // If there are no more associated sessions, remove the SSO altogether + if (!sso.iterator().hasNext()) { manager.removeSingleSignOn(ssoId); } - } finally { - sso.close(); } } } Index: 3rdParty_sources/undertow/io/undertow/security/impl/SingleSignOnManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/security/impl/Attic/SingleSignOnManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/security/impl/SingleSignOnManager.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/security/impl/SingleSignOnManager.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.security.impl; import io.undertow.security.idm.Account; Index: 3rdParty_sources/undertow/io/undertow/server/AbstractServerConnection.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/AbstractServerConnection.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/AbstractServerConnection.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/AbstractServerConnection.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server; @@ -48,7 +48,7 @@ protected final OptionMap undertowOptions; protected final StreamSourceConduit originalSourceConduit; protected final StreamSinkConduit originalSinkConduit; - protected final List closeListeners = new LinkedList(); + protected final List closeListeners = new LinkedList<>(); protected HttpServerExchange current; @@ -272,6 +272,10 @@ throw UndertowMessages.MESSAGES.upgradeNotSupported(); } + @Override + protected void maxEntitySizeUpdated(HttpServerExchange exchange) { + } + private class CloseSetter implements ChannelListener.Setter, ChannelListener { private ChannelListener listener; Index: 3rdParty_sources/undertow/io/undertow/server/BasicSSLSessionInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/BasicSSLSessionInfo.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/BasicSSLSessionInfo.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/BasicSSLSessionInfo.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; import io.undertow.UndertowMessages; Index: 3rdParty_sources/undertow/io/undertow/server/BlockingHttpExchange.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/BlockingHttpExchange.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/BlockingHttpExchange.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/BlockingHttpExchange.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,5 +1,24 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; +import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -12,7 +31,7 @@ * * @author Stuart Douglas */ -public interface BlockingHttpExchange { +public interface BlockingHttpExchange extends Closeable { /** * Returns the input stream that is in use for this exchange. Index: 3rdParty_sources/undertow/io/undertow/server/ConduitWrapper.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/ConduitWrapper.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/ConduitWrapper.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/ConduitWrapper.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server; Index: 3rdParty_sources/undertow/io/undertow/server/ConnectionSSLSessionInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/ConnectionSSLSessionInfo.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/ConnectionSSLSessionInfo.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/ConnectionSSLSessionInfo.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; import io.undertow.UndertowOptions; Index: 3rdParty_sources/undertow/io/undertow/server/Connectors.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/Connectors.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/Connectors.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/Connectors.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; import io.undertow.UndertowLogger; @@ -62,7 +80,9 @@ Pooled[] bufs = exchange.getAttachment(HttpServerExchange.BUFFERED_REQUEST_DATA); if (bufs != null) { for (Pooled i : bufs) { - i.free(); + if(i != null) { + i.free(); + } } } nextListener.proceed(); @@ -126,7 +146,7 @@ header.append(DateUtils.toOldCookieDateString(expires)); } else if (cookie.getMaxAge() > 0) { Date expires = new Date(); - expires.setTime(expires.getTime() + cookie.getMaxAge() * 1000); + expires.setTime(expires.getTime() + cookie.getMaxAge() * 1000L); header.append("; Expires="); header.append(DateUtils.toOldCookieDateString(expires)); } @@ -197,7 +217,7 @@ if (!exchange.isResponseStarted()) { exchange.setResponseCode(500); } - UndertowLogger.REQUEST_LOGGER.errorf(t, "Blocking request failed %s", exchange); + UndertowLogger.REQUEST_LOGGER.errorf(t, "Undertow request failed %s", exchange); exchange.endExchange(); } } Index: 3rdParty_sources/undertow/io/undertow/server/DefaultResponseListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/DefaultResponseListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/DefaultResponseListener.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/DefaultResponseListener.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; /** Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/DelegateOpenListener.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/server/ExchangeCompletionListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/ExchangeCompletionListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/ExchangeCompletionListener.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/ExchangeCompletionListener.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; /** Index: 3rdParty_sources/undertow/io/undertow/server/HandlerWrapper.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/HandlerWrapper.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/HandlerWrapper.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/HandlerWrapper.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; /** Index: 3rdParty_sources/undertow/io/undertow/server/HttpHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/HttpHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/HttpHandler.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/HttpHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server; Index: 3rdParty_sources/undertow/io/undertow/server/HttpServerExchange.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/HttpServerExchange.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/HttpServerExchange.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/HttpServerExchange.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server; @@ -99,8 +99,8 @@ static final AttachmentKey[]> BUFFERED_REQUEST_DATA = AttachmentKey.create(Pooled[].class); private final ServerConnection connection; - private final HeaderMap requestHeaders = new HeaderMap(); - private final HeaderMap responseHeaders = new HeaderMap(); + private final HeaderMap requestHeaders; + private final HeaderMap responseHeaders; private int exchangeCompletionListenersCount = 0; private ExchangeCompletionListener[] exchangeCompleteListeners; @@ -216,7 +216,13 @@ */ private Executor dispatchExecutor; + /** + * The number of bytes that have been sent to the remote client. This does not include headers, + * only the entity body, and does not take any transfer or content encoding into account. + */ + private long responseBytesSent = 0; + private static final int MASK_RESPONSE_CODE = intBitMask(0, 9); /** @@ -282,14 +288,20 @@ private InetSocketAddress destinationAddress; public HttpServerExchange(final ServerConnection connection, long maxEntitySize) { - this.connection = connection; - this.maxEntitySize = maxEntitySize; + this(connection, new HeaderMap(), new HeaderMap(), maxEntitySize); } public HttpServerExchange(final ServerConnection connection) { this(connection, 0); } + public HttpServerExchange(final ServerConnection connection, final HeaderMap requestHeaders, final HeaderMap responseHeaders, long maxEntitySize) { + this.connection = connection; + this.maxEntitySize = maxEntitySize; + this.requestHeaders = requestHeaders; + this.responseHeaders = responseHeaders; + } + /** * Get the request protocol string. Normally this is one of the strings listed in {@link Protocols}. * @@ -492,6 +504,10 @@ return this; } + /** + * + * @return The query string, without the leading ? + */ public String getQueryString() { return queryString; } @@ -636,14 +652,30 @@ return anyAreSet(state, FLAG_PERSISTENT); } + /** + * + * @return true If the current thread in the IO thread for the exchange + */ public boolean isInIoThread() { return getIoThread() == Thread.currentThread(); } + /** + * + * @return True if this exchange represents an upgrade response + */ public boolean isUpgrade() { return getResponseCode() == 101; } + /** + * + * @return The number of bytes sent in the entity body + */ + public long getResponseBytesSent() { + return responseBytesSent; + } + public HttpServerExchange setPersistent(final boolean persistent) { if (persistent) { this.state = this.state | FLAG_PERSISTENT; @@ -953,18 +985,18 @@ */ public Map> getQueryParameters() { if (queryParameters == null) { - queryParameters = new TreeMap>(); + queryParameters = new TreeMap<>(); } return queryParameters; } public HttpServerExchange addQueryParam(final String name, final String param) { if (queryParameters == null) { - queryParameters = new TreeMap>(); + queryParameters = new TreeMap<>(); } Deque list = queryParameters.get(name); if (list == null) { - queryParameters.put(name, list = new ArrayDeque(2)); + queryParameters.put(name, list = new ArrayDeque<>(2)); } list.add(param); return this; @@ -978,18 +1010,18 @@ */ public Map> getPathParameters() { if (pathParameters == null) { - pathParameters = new TreeMap>(); + pathParameters = new TreeMap<>(); } return pathParameters; } public HttpServerExchange addPathParam(final String name, final String param) { if (pathParameters == null) { - pathParameters = new TreeMap>(); + pathParameters = new TreeMap<>(); } Deque list = pathParameters.get(name); if (list == null) { - pathParameters.put(name, list = new ArrayDeque(2)); + pathParameters.put(name, list = new ArrayDeque<>(2)); } list.add(param); return this; @@ -1015,7 +1047,7 @@ */ public HttpServerExchange setResponseCookie(final Cookie cookie) { if (responseCookies == null) { - responseCookies = new TreeMap(); //hashmap is slow to allocate in JDK7 + responseCookies = new TreeMap<>(); //hashmap is slow to allocate in JDK7 } responseCookies.put(cookie.getName(), cookie); return this; @@ -1026,7 +1058,7 @@ */ public Map getResponseCookies() { if (responseCookies == null) { - responseCookies = new TreeMap(); + responseCookies = new TreeMap<>(); } return responseCookies; } @@ -1066,7 +1098,7 @@ final ConduitStreamSourceChannel sourceChannel = connection.getSourceChannel(); if (wrappers != null) { this.requestWrappers = null; - final WrapperConduitFactory factory = new WrapperConduitFactory(wrappers, requestWrapperCount, sourceChannel.getConduit(), this); + final WrapperConduitFactory factory = new WrapperConduitFactory<>(wrappers, requestWrapperCount, sourceChannel.getConduit(), this); sourceChannel.setConduit(factory.create()); } return requestChannel = new ReadDispatchChannel(sourceChannel); @@ -1246,7 +1278,7 @@ public HttpServerExchange addResponseWrapper(final ConduitWrapper wrapper) { ConduitWrapper[] wrappers = responseWrappers; if (responseChannel != null) { - throw UndertowMessages.MESSAGES.requestChannelAlreadyProvided(); + throw UndertowMessages.MESSAGES.responseChannelAlreadyProvided(); } if(wrappers == null) { this.responseWrappers = wrappers = new ConduitWrapper[2]; @@ -1378,6 +1410,10 @@ public HttpServerExchange endExchange() { final int state = this.state; if (allAreSet(state, FLAG_REQUEST_TERMINATED | FLAG_RESPONSE_TERMINATED)) { + if(blockingHttpExchange != null) { + //we still have to close the blocking exchange in this case, + IoUtils.safeClose(blockingHttpExchange); + } return this; } if(defaultResponseListeners != null) { @@ -1398,6 +1434,10 @@ } } + if (anyAreClear(state, FLAG_REQUEST_TERMINATED)) { + connection.terminateRequestChannel(this); + } + if (blockingHttpExchange != null) { try { //TODO: can we end up in this situation in a IO thread? @@ -1410,7 +1450,6 @@ //417 means that we are rejecting the request //so the client should not actually send any data - //TODO: how if (anyAreClear(state, FLAG_REQUEST_TERMINATED)) { //not really sure what the best thing to do here is @@ -1509,6 +1548,7 @@ } } catch (IOException e) { UndertowLogger.REQUEST_IO_LOGGER.ioException(e); + IoUtils.safeClose(connection); } } @@ -1564,6 +1604,7 @@ throw UndertowMessages.MESSAGES.requestChannelAlreadyProvided(); } this.maxEntitySize = maxEntitySize; + connection.maxEntitySizeUpdated(this); return this; } @@ -1654,8 +1695,11 @@ @Override public void close() throws IOException { - IoUtils.safeClose(getInputStream()); - IoUtils.safeClose(getOutputStream()); + try { + getInputStream().close(); + } finally { + getOutputStream().close(); + } } } @@ -1726,13 +1770,87 @@ } private void invokeListener() { - getIoThread().execute(new Runnable() { - @Override - public void run() { - ChannelListeners.invokeChannelListener(WriteDispatchChannel.this, writeSetter.get()); - } - }); + if(writeSetter != null) { + getIoThread().execute(new Runnable() { + @Override + public void run() { + ChannelListeners.invokeChannelListener(WriteDispatchChannel.this, writeSetter.get()); + } + }); + } } + + @Override + public void awaitWritable() throws IOException { + if(Thread.currentThread() == getIoThread()) { + throw UndertowMessages.MESSAGES.awaitCalledFromIoThread(); + } + super.awaitWritable(); + } + + @Override + public void awaitWritable(long time, TimeUnit timeUnit) throws IOException { + if(Thread.currentThread() == getIoThread()) { + throw UndertowMessages.MESSAGES.awaitCalledFromIoThread(); + } + super.awaitWritable(time, timeUnit); + } + + @Override + public long transferFrom(FileChannel src, long position, long count) throws IOException { + long l = super.transferFrom(src, position, count); + responseBytesSent += l; + return l; + } + + @Override + public long transferFrom(StreamSourceChannel source, long count, ByteBuffer throughBuffer) throws IOException { + long l = super.transferFrom(source, count, throughBuffer); + responseBytesSent += l; + return l; + } + + @Override + public long write(ByteBuffer[] srcs, int offset, int length) throws IOException { + long l = super.write(srcs, offset, length); + responseBytesSent += l; + return l; + } + + @Override + public long write(ByteBuffer[] srcs) throws IOException { + long l = super.write(srcs); + responseBytesSent += l; + return l; + } + + @Override + public int writeFinal(ByteBuffer src) throws IOException { + int l = super.writeFinal(src); + responseBytesSent += l; + return l; + } + + @Override + public long writeFinal(ByteBuffer[] srcs, int offset, int length) throws IOException { + long l = super.writeFinal(srcs, offset, length); + responseBytesSent += l; + return l; + } + + @Override + public long writeFinal(ByteBuffer[] srcs) throws IOException { + long l = super.writeFinal(srcs); + responseBytesSent += l; + return l; + } + + @Override + public int write(ByteBuffer src) throws IOException { + int l = super.write(src); + responseBytesSent += l; + return l; + } } /** @@ -1787,17 +1905,24 @@ } private void invokeListener() { - getIoThread().execute(new Runnable() { - @Override - public void run() { - ChannelListeners.invokeChannelListener(ReadDispatchChannel.this, readSetter.get()); - } - }); + if(readSetter != null) { + getIoThread().execute(new Runnable() { + @Override + public void run() { + ChannelListeners.invokeChannelListener(ReadDispatchChannel.this, readSetter.get()); + } + }); + } } public void requestDone() { - delegate.setReadListener(null); - delegate.setCloseListener(null); + if(delegate instanceof ConduitStreamSourceChannel) { + ((ConduitStreamSourceChannel)delegate).setReadListener(null); + ((ConduitStreamSourceChannel)delegate).setCloseListener(null); + } else { + delegate.getReadSetter().set(null); + delegate.getCloseSetter().set(null); + } } @Override @@ -1811,6 +1936,9 @@ @Override public void awaitReadable() throws IOException { + if(Thread.currentThread() == getIoThread()) { + throw UndertowMessages.MESSAGES.awaitCalledFromIoThread(); + } Pooled[] buffered = getAttachment(BUFFERED_REQUEST_DATA); if (buffered == null) { super.awaitReadable(); @@ -1865,6 +1993,9 @@ @Override public void awaitReadable(long time, TimeUnit timeUnit) throws IOException { + if(Thread.currentThread() == getIoThread()) { + throw UndertowMessages.MESSAGES.awaitCalledFromIoThread(); + } Pooled[] buffered = getAttachment(BUFFERED_REQUEST_DATA); if (buffered == null) { super.awaitReadable(time, timeUnit); Index: 3rdParty_sources/undertow/io/undertow/server/HttpUpgradeListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/HttpUpgradeListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/HttpUpgradeListener.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/HttpUpgradeListener.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; import org.xnio.StreamConnection; Index: 3rdParty_sources/undertow/io/undertow/server/JvmRouteHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/JvmRouteHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/JvmRouteHandler.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/JvmRouteHandler.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,10 +1,37 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + import io.undertow.server.handlers.Cookie; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.ConduitFactory; import org.xnio.conduits.StreamSinkConduit; /** + * + * Handler that appends the JVM route to the session id. + * * @author Stuart Douglas */ public class JvmRouteHandler implements HttpHandler { @@ -40,14 +67,65 @@ @Override public StreamSinkConduit wrap(ConduitFactory factory, HttpServerExchange exchange) { - Cookie sessionId = exchange.getResponseCookies().get(sessionCookieName); - if (sessionId != null) { - StringBuilder sb = new StringBuilder(sessionId.getValue()); - sb.append('.'); - sb.append(jvmRoute); - sessionId.setValue(sb.toString()); - } + Cookie sessionId = exchange.getResponseCookies().get(sessionCookieName); + if (sessionId != null) { + StringBuilder sb = new StringBuilder(sessionId.getValue()); + sb.append('.'); + sb.append(jvmRoute); + sessionId.setValue(sb.toString()); + } return factory.create(); } } + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "jvm-route"; + } + + @Override + public Map> parameters() { + Map> params = new HashMap<>(); + params.put("value", String.class); + params.put("session-cookie-name", String.class); + + return params; + } + + @Override + public Set requiredParameters() { + return Collections.singleton("value"); + } + + @Override + public String defaultParameter() { + return "value"; + } + + @Override + public HandlerWrapper build(Map config) { + String sessionCookieName = (String) config.get("session-cookie-name"); + + return new Wrapper((String)config.get("value"), sessionCookieName == null ? "JSESSIONID" : sessionCookieName); + } + + } + + private static class Wrapper implements HandlerWrapper { + + private final String value; + private final String sessionCookieName; + + private Wrapper(String value, String sessionCookieName) { + this.value = value; + this.sessionCookieName = sessionCookieName; + } + + @Override + public HttpHandler wrap(HttpHandler handler) { + return new JvmRouteHandler(handler, sessionCookieName, value); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/ListenerRegistry.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/ListenerRegistry.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/ListenerRegistry.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/ListenerRegistry.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; import java.net.InetSocketAddress; @@ -21,7 +39,7 @@ */ public class ListenerRegistry { - private final ConcurrentMap listeners = new CopyOnWriteMap(); + private final ConcurrentMap listeners = new CopyOnWriteMap<>(); public Listener getListener(final String name) { return listeners.get(name); @@ -47,12 +65,12 @@ /** * Map that can be used to store additional listener metadata */ - private final Map contextInformation = new CopyOnWriteMap(); + private final Map contextInformation = new CopyOnWriteMap<>(); /** * Information about any HTTP upgrade handlers that are registered on this handler. */ - private final Set httpUpgradeMetadata = new CopyOnWriteArraySet(); + private final Set httpUpgradeMetadata = new CopyOnWriteArraySet<>(); public Listener(final String protocol, final String name, final String serverName, final InetSocketAddress bindAddress) { this.protocol = protocol; @@ -122,7 +140,7 @@ private final String protocol; private final String subProtocol; - private final Map contextInformation = new CopyOnWriteMap(); + private final Map contextInformation = new CopyOnWriteMap<>(); public HttpUpgradeMetadata(final String protocol, final String subProtocol) { Index: 3rdParty_sources/undertow/io/undertow/server/OpenListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/OpenListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/OpenListener.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/OpenListener.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; import org.xnio.ChannelListener; Index: 3rdParty_sources/undertow/io/undertow/server/RenegotiationRequiredException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/RenegotiationRequiredException.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/RenegotiationRequiredException.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/RenegotiationRequiredException.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; /** Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/RoutingHandler.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/server/SSLSessionInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/SSLSessionInfo.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/SSLSessionInfo.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/SSLSessionInfo.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; import org.xnio.SslClientAuthMode; Index: 3rdParty_sources/undertow/io/undertow/server/ServerConnection.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/ServerConnection.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/ServerConnection.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/ServerConnection.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,25 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server; import io.undertow.util.AbstractAttachable; + import org.xnio.Option; import org.xnio.OptionMap; import org.xnio.Pool; @@ -56,7 +75,18 @@ public abstract HttpServerExchange sendOutOfBandResponse(HttpServerExchange exchange); /** + * Invoked when the exchange is complete, and there is still data in the request channel. Some implementations + * (such as SPDY and HTTP2) have more efficient ways to drain the request than simply reading all data + * (e.g. RST_STREAM). * + * After this method is invoked the stream will be drained normally. + * + * @param exchange The current exchange. + */ + public abstract void terminateRequestChannel(HttpServerExchange exchange); + + /** + * * @return true if the connection is open */ public abstract boolean isOpen(); @@ -147,6 +177,10 @@ */ protected abstract StreamSinkConduit getSinkConduit(HttpServerExchange exchange, final StreamSinkConduit conduit); + /** + * + * @return true if this connection supports HTTP upgrade + */ protected abstract boolean isUpgradeSupported(); /** @@ -156,6 +190,13 @@ protected abstract void setUpgradeListener(HttpUpgradeListener upgradeListener); + /** + * Callback that is invoked if the max entity size is updated. + * + * @param exchange The current exchange + */ + protected abstract void maxEntitySizeUpdated(HttpServerExchange exchange); + public interface CloseListener { void closed(final ServerConnection connection); Index: 3rdParty_sources/undertow/io/undertow/server/TruncatedResponseException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/Attic/TruncatedResponseException.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/TruncatedResponseException.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/TruncatedResponseException.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,23 +1,19 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012, Red Hat, Inc., and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * http://www.apache.org/licenses/LICENSE-2.0 * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/AccessControlListHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/AccessControlListHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/AccessControlListHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/AccessControlListHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import io.undertow.UndertowMessages; @@ -23,7 +41,7 @@ private volatile HttpHandler next; private volatile boolean defaultAllow = false; private final ExchangeAttribute attribute; - private final List acl = new CopyOnWriteArrayList(); + private final List acl = new CopyOnWriteArrayList<>(); public AccessControlListHandler(final HttpHandler next, ExchangeAttribute attribute) { this.next = next; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/AllowedMethodsHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/AllowedMethodsHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/AllowedMethodsHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/AllowedMethodsHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,11 +1,33 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; +import java.util.Map; import java.util.Set; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.HttpString; import io.undertow.util.StatusCodes; @@ -21,12 +43,12 @@ private final HttpHandler next; public AllowedMethodsHandler(final HttpHandler next, final Set allowedMethods) { - this.allowedMethods = new HashSet(allowedMethods); + this.allowedMethods = new HashSet<>(allowedMethods); this.next = next; } public AllowedMethodsHandler(final HttpHandler next, final HttpString... allowedMethods) { - this.allowedMethods = new HashSet(Arrays.asList(allowedMethods)); + this.allowedMethods = new HashSet<>(Arrays.asList(allowedMethods)); this.next = next; } @@ -40,4 +62,51 @@ } } + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "allowed-methods"; + } + + @Override + public Map> parameters() { + return Collections.>singletonMap("methods", String[].class); + } + + @Override + public Set requiredParameters() { + return Collections.singleton("methods"); + } + + @Override + public String defaultParameter() { + return "methods"; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper((String[]) config.get("methods")); + } + + } + + private static class Wrapper implements HandlerWrapper { + + private final String[] methods; + + private Wrapper(String[] methods) { + this.methods = methods; + } + + @Override + public HttpHandler wrap(HttpHandler handler) { + HttpString[] strings = new HttpString[methods.length]; + for(int i = 0; i < methods.length; ++i) { + strings[i] = new HttpString(methods[i]); + } + + return new AllowedMethodsHandler(handler, strings); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/AttachmentHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/AttachmentHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/AttachmentHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/AttachmentHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/BlockingHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/BlockingHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/BlockingHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/BlockingHandler.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,17 +9,23 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; /** * A {@link HttpHandler} that initiates a blocking request. If the thread is currently running @@ -59,4 +65,41 @@ this.handler = rootHandler; return this; } + + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "blocking"; + } + + @Override + public Map> parameters() { + return Collections.emptyMap(); + } + + @Override + public Set requiredParameters() { + return Collections.emptySet(); + } + + @Override + public String defaultParameter() { + return null; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper(); + } + + } + + private static class Wrapper implements HandlerWrapper { + @Override + public HttpHandler wrap(HttpHandler handler) { + return new BlockingHandler(handler); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/CanonicalPathHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/CanonicalPathHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/CanonicalPathHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/CanonicalPathHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,18 +9,24 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + import io.undertow.Handlers; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.CanonicalPathUtils; /** @@ -52,4 +58,40 @@ this.next = next; return this; } + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "canonical-path"; + } + + @Override + public Map> parameters() { + return Collections.emptyMap(); + } + + @Override + public Set requiredParameters() { + return Collections.emptySet(); + } + + @Override + public String defaultParameter() { + return null; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper(); + } + + } + + private static class Wrapper implements HandlerWrapper { + @Override + public HttpHandler wrap(HttpHandler handler) { + return new CanonicalPathHandler(handler); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/ChannelUpgradeHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/ChannelUpgradeHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/ChannelUpgradeHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/ChannelUpgradeHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; @@ -40,7 +40,7 @@ * @author Stuart Douglas */ public final class ChannelUpgradeHandler implements HttpHandler { - private final CopyOnWriteMap> handlers = new CopyOnWriteMap>(); + private final CopyOnWriteMap> handlers = new CopyOnWriteMap<>(); private volatile HttpHandler nonUpgradeHandler = ResponseCodeHandler.HANDLE_404; /** @@ -59,7 +59,7 @@ } List list = handlers.get(productString); if (list == null) { - handlers.put(productString, list = new CopyOnWriteArrayList()); + handlers.put(productString, list = new CopyOnWriteArrayList<>()); } list.add(new Holder(openListener, handshake)); } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/Cookie.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/Cookie.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/Cookie.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/Cookie.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/CookieImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/CookieImpl.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/CookieImpl.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/CookieImpl.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/DateHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/DateHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/DateHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/DateHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import java.util.Date; @@ -12,6 +30,10 @@ * * The current date string is cached, and is updated every second in a racey * manner (i.e. it is possible for two thread to update it at once). + *

+ * This handler is deprecated, the same functionality is achieved by using the + * server option {@link io.undertow.UndertowOptions#ALWAYS_SET_DATE ALWAYS_SET_DATE}. + * It is enabled by default. * * @author Stuart Douglas */ @@ -29,6 +51,7 @@ @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { + // better method is used in DateUtils#addDateHeaderIfRequired long time = System.nanoTime(); if(time < nextUpdateTime) { exchange.getResponseHeaders().put(Headers.DATE, cachedDateString); Index: 3rdParty_sources/undertow/io/undertow/server/handlers/DisableCacheHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/DisableCacheHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/DisableCacheHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/DisableCacheHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,7 +1,13 @@ package io.undertow.server.handlers; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.Headers; /** @@ -26,4 +32,40 @@ exchange.getResponseHeaders().add(Headers.EXPIRES, "0"); next.handleRequest(exchange); } + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "disable-cache"; + } + + @Override + public Map> parameters() { + return Collections.emptyMap(); + } + + @Override + public Set requiredParameters() { + return Collections.emptySet(); + } + + @Override + public String defaultParameter() { + return null; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper(); + } + + } + + private static class Wrapper implements HandlerWrapper { + @Override + public HttpHandler wrap(HttpHandler handler) { + return new DisableCacheHandler(handler); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/DisallowedMethodsHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/DisallowedMethodsHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/DisallowedMethodsHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/DisallowedMethodsHandler.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,11 +1,33 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; +import java.util.Map; import java.util.Set; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.HttpString; import io.undertow.util.StatusCodes; @@ -20,13 +42,13 @@ private final HttpHandler next; public DisallowedMethodsHandler(final HttpHandler next, final Set disallowedMethods) { - this.disallowedMethods = new HashSet(disallowedMethods); + this.disallowedMethods = new HashSet<>(disallowedMethods); this.next = next; } public DisallowedMethodsHandler(final HttpHandler next, final HttpString... disallowedMethods) { - this.disallowedMethods = new HashSet(Arrays.asList(disallowedMethods)); + this.disallowedMethods = new HashSet<>(Arrays.asList(disallowedMethods)); this.next = next; } @@ -40,4 +62,52 @@ } } + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "disallowed-methods"; + } + + @Override + public Map> parameters() { + return Collections.>singletonMap("methods", String[].class); + } + + @Override + public Set requiredParameters() { + return Collections.singleton("methods"); + } + + @Override + public String defaultParameter() { + return "methods"; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper((String[]) config.get("methods")); + } + + } + + private static class Wrapper implements HandlerWrapper { + + private final String[] methods; + + private Wrapper(String[] methods) { + this.methods = methods; + } + + @Override + public HttpHandler wrap(HttpHandler handler) { + HttpString[] strings = new HttpString[methods.length]; + for(int i = 0; i < methods.length; ++i) { + strings[i] = new HttpString(methods[i]); + } + + return new DisallowedMethodsHandler(handler, strings); + } + } } Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/handlers/ExceptionHandler.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/server/handlers/GracefulShutdownHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/GracefulShutdownHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/GracefulShutdownHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/GracefulShutdownHandler.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import io.undertow.UndertowMessages; @@ -25,7 +43,7 @@ private volatile boolean shutdown = false; private final GracefulShutdownListener listener = new GracefulShutdownListener(); - private final List shutdownListeners = new ArrayList(); + private final List shutdownListeners = new ArrayList<>(); private final Object lock = new Object(); Index: 3rdParty_sources/undertow/io/undertow/server/handlers/HttpContinueAcceptingHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/HttpContinueAcceptingHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/HttpContinueAcceptingHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/HttpContinueAcceptingHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/HttpContinueReadHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/HttpContinueReadHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/HttpContinueReadHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/HttpContinueReadHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import java.io.IOException; @@ -25,7 +43,10 @@ private static final ConduitWrapper WRAPPER = new ConduitWrapper() { @Override public StreamSourceConduit wrap(final ConduitFactory factory, final HttpServerExchange exchange) { - return new ContinueConduit(factory.create(), exchange); + if(exchange.isRequestChannelAvailable() && !exchange.isResponseStarted()) { + return new ContinueConduit(factory.create(), exchange); + } + return factory.create(); } }; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/HttpTraceHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/HttpTraceHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/HttpTraceHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/HttpTraceHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,7 +1,31 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.HeaderValues; import io.undertow.util.Headers; import io.undertow.util.Methods; @@ -45,4 +69,42 @@ handler.handleRequest(exchange); } } + + + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "trace"; + } + + @Override + public Map> parameters() { + return Collections.emptyMap(); + } + + @Override + public Set requiredParameters() { + return Collections.emptySet(); + } + + @Override + public String defaultParameter() { + return null; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper(); + } + + } + + private static class Wrapper implements HandlerWrapper { + @Override + public HttpHandler wrap(HttpHandler handler) { + return new HttpTraceHandler(handler); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/HttpUpgradeHandshake.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/HttpUpgradeHandshake.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/HttpUpgradeHandshake.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/HttpUpgradeHandshake.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/IPAddressAccessControlHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/IPAddressAccessControlHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/IPAddressAccessControlHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/IPAddressAccessControlHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,17 +1,42 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; import java.net.InetSocketAddress; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import java.util.regex.Pattern; import io.undertow.UndertowMessages; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.StatusCodes; import org.xnio.Bits; @@ -54,15 +79,22 @@ private volatile HttpHandler next; private volatile boolean defaultAllow = false; - private final List ipv6acl = new CopyOnWriteArrayList(); - private final List ipv4acl = new CopyOnWriteArrayList(); + private final int denyResponseCode; + private final List ipv6acl = new CopyOnWriteArrayList<>(); + private final List ipv4acl = new CopyOnWriteArrayList<>(); public IPAddressAccessControlHandler(final HttpHandler next) { + this(next, StatusCodes.FORBIDDEN); + } + + public IPAddressAccessControlHandler(final HttpHandler next, final int denyResponseCode) { this.next = next; + this.denyResponseCode = denyResponseCode; } public IPAddressAccessControlHandler() { this.next = ResponseCodeHandler.HANDLE_404; + this.denyResponseCode = StatusCodes.FORBIDDEN; } @Override @@ -71,7 +103,7 @@ if (isAllowed(peer.getAddress())) { next.handleRequest(exchange); } else { - exchange.setResponseCode(StatusCodes.FORBIDDEN); + exchange.setResponseCode(denyResponseCode); exchange.endExchange(); } } @@ -93,6 +125,10 @@ return defaultAllow; } + public int getDenyResponseCode() { + return denyResponseCode; + } + public boolean isDefaultAllow() { return defaultAllow; } @@ -377,4 +413,96 @@ } } + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "ip-access-control"; + } + + @Override + public Map> parameters() { + Map> params = new HashMap<>(); + params.put("acl", String[].class); + params.put("failure-status", int.class); + params.put("default-allow", boolean.class); + return params; + } + + @Override + public Set requiredParameters() { + return Collections.singleton("acl"); + } + + @Override + public String defaultParameter() { + return "acl"; + } + + @Override + public HandlerWrapper build(Map config) { + + String[] acl = (String[]) config.get("acl"); + Boolean defaultAllow = (Boolean) config.get("default-allow"); + Integer failureStatus = (Integer) config.get("failure-status"); + + List peerMatches = new ArrayList<>(); + for(String rule :acl) { + String[] parts = rule.split(" "); + if(parts.length != 2) { + throw UndertowMessages.MESSAGES.invalidAclRule(rule); + } + if(parts[1].trim().equals("allow")) { + peerMatches.add(new Holder(parts[0].trim(), false)); + } else if(parts[1].trim().equals("deny")) { + peerMatches.add(new Holder(parts[0].trim(), true)); + } else { + throw UndertowMessages.MESSAGES.invalidAclRule(rule); + } + } + return new Wrapper(peerMatches, defaultAllow == null ? false : defaultAllow, failureStatus == null ? StatusCodes.FORBIDDEN : failureStatus); + } + + } + + private static class Wrapper implements HandlerWrapper { + + private final List peerMatches; + private final boolean defaultAllow; + private final int failureStatus; + + + private Wrapper(List peerMatches, boolean defaultAllow, int failureStatus) { + this.peerMatches = peerMatches; + this.defaultAllow = defaultAllow; + this.failureStatus = failureStatus; + } + + + @Override + public HttpHandler wrap(HttpHandler handler) { + IPAddressAccessControlHandler res = new IPAddressAccessControlHandler(handler, failureStatus); + for(Holder match: peerMatches) { + if(match.deny) { + res.addDeny(match.rule); + } else { + res.addAllow(match.rule); + } + } + res.setDefaultAllow(defaultAllow); + return res; + } + } + + private static class Holder { + final String rule; + final boolean deny; + + private Holder(String rule, boolean deny) { + this.rule = rule; + this.deny = deny; + } + } + } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/JDBCLogHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/JDBCLogHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/JDBCLogHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/JDBCLogHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import io.undertow.UndertowLogger; @@ -72,7 +90,7 @@ refererField = "referer"; userAgentField = "userAgent"; this.logWriteExecutor = logWriteExecutor; - this.pendingMessages = new ConcurrentLinkedDeque(); + this.pendingMessages = new ConcurrentLinkedDeque<>(); } @Override @@ -138,7 +156,7 @@ return; } - List messages = new ArrayList(); + List messages = new ArrayList<>(); JDBCLogAttribute msg = null; //only grab at most 1000 messages at a time Index: 3rdParty_sources/undertow/io/undertow/server/handlers/MetricsHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/MetricsHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/MetricsHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/MetricsHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import io.undertow.server.ExchangeCompletionListener; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/NameVirtualHostHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/NameVirtualHostHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/NameVirtualHostHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/NameVirtualHostHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; @@ -35,7 +35,7 @@ public class NameVirtualHostHandler implements HttpHandler { private volatile HttpHandler defaultHandler = ResponseCodeHandler.HANDLE_404; - private final Map hosts = new CopyOnWriteMap(); + private final Map hosts = new CopyOnWriteMap<>(); @Override Index: 3rdParty_sources/undertow/io/undertow/server/handlers/OriginHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/OriginHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/OriginHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/OriginHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; @@ -32,14 +32,14 @@ import io.undertow.util.Headers; /** - * A handler for the HTTP Origin header. + * A handler for the HTTP Origin (RFC 6454) header. * * @author Stuart Douglas */ public class OriginHandler implements HttpHandler { private volatile HttpHandler originFailedHandler = ResponseCodeHandler.HANDLE_403; - private volatile Set allowedOrigins = new HashSet(); + private volatile Set allowedOrigins = new HashSet<>(); private volatile boolean requireAllOrigins = true; private volatile boolean requireOriginHeader = true; private volatile HttpHandler next = ResponseCodeHandler.HANDLE_404; @@ -86,21 +86,21 @@ } public synchronized OriginHandler addAllowedOrigin(final String origin) { - final Set allowedOrigins = new HashSet(this.allowedOrigins); + final Set allowedOrigins = new HashSet<>(this.allowedOrigins); allowedOrigins.add(origin); this.allowedOrigins = Collections.unmodifiableSet(allowedOrigins); return this; } public synchronized OriginHandler addAllowedOrigins(final Collection origins) { - final Set allowedOrigins = new HashSet(this.allowedOrigins); + final Set allowedOrigins = new HashSet<>(this.allowedOrigins); allowedOrigins.addAll(origins); this.allowedOrigins = Collections.unmodifiableSet(allowedOrigins); return this; } public synchronized OriginHandler addAllowedOrigins(final String... origins) { - final Set allowedOrigins = new HashSet(this.allowedOrigins); + final Set allowedOrigins = new HashSet<>(this.allowedOrigins); allowedOrigins.addAll(Arrays.asList(origins)); this.allowedOrigins = Collections.unmodifiableSet(allowedOrigins); return this; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/PathHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/PathHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/PathHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/PathHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; @@ -35,7 +35,7 @@ */ public class PathHandler implements HttpHandler { - private final PathMatcher pathMatcher = new PathMatcher(); + private final PathMatcher pathMatcher = new PathMatcher<>(); public PathHandler(final HttpHandler defaultHandler) { pathMatcher.addPrefixPath("/", defaultHandler); @@ -47,7 +47,7 @@ @Override public void handleRequest(HttpServerExchange exchange) throws Exception { final PathMatcher.PathMatch match = pathMatcher.match(exchange.getRelativePath()); - if(match.getValue() == null) { + if (match.getValue() == null) { ResponseCodeHandler.HANDLE_404.handleRequest(exchange); return; } Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/handlers/PathSeparatorHandler.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/server/handlers/PathTemplateHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/PathTemplateHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/PathTemplateHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/PathTemplateHandler.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,8 +1,27 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.util.AttachmentKey; +import io.undertow.util.PathTemplateMatch; import io.undertow.util.PathTemplateMatcher; import java.util.Map; @@ -17,9 +36,13 @@ private final boolean rewriteQueryParameters; + /** + * @see io.undertow.util.PathTemplateMatch#ATTACHMENT_KEY + */ + @Deprecated public static final AttachmentKey PATH_TEMPLATE_MATCH = AttachmentKey.create(PathTemplateMatch.class); - private final PathTemplateMatcher pathTemplateMatcher = new PathTemplateMatcher(); + private final PathTemplateMatcher pathTemplateMatcher = new PathTemplateMatcher<>(); public PathTemplateHandler(boolean rewriteQueryParameters) { this.rewriteQueryParameters = rewriteQueryParameters; @@ -33,11 +56,11 @@ public void handleRequest(HttpServerExchange exchange) throws Exception { PathTemplateMatcher.PathMatchResult match = pathTemplateMatcher.match(exchange.getRelativePath()); if (match == null) { - exchange.setResponseCode(404); - exchange.endExchange(); + ResponseCodeHandler.HANDLE_404.handleRequest(exchange); return; } exchange.putAttachment(PATH_TEMPLATE_MATCH, new PathTemplateMatch(match.getMatchedTemplate(), match.getParameters())); + exchange.putAttachment(io.undertow.util.PathTemplateMatch.ATTACHMENT_KEY, new io.undertow.util.PathTemplateMatch(match.getMatchedTemplate(), match.getParameters())); if (rewriteQueryParameters) { for (Map.Entry entry : match.getParameters().entrySet()) { exchange.addQueryParam(entry.getKey(), entry.getValue()); @@ -56,6 +79,10 @@ return this; } + /** + * @see io.undertow.util.PathTemplateMatch + */ + @Deprecated public static final class PathTemplateMatch { private final String matchedTemplate; private final Map parameters; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/PeerNameResolvingHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/PeerNameResolvingHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/PeerNameResolvingHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/PeerNameResolvingHandler.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,15 +1,38 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import io.undertow.UndertowLogger; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; +import java.util.Collections; +import java.util.Map; +import java.util.Set; /** * A handler that performs reverse DNS lookup to resolve a peer address @@ -78,7 +101,45 @@ public static enum ResolveType { FORWARD, REVERSE, - FORWARD_AND_REVERSE; + FORWARD_AND_REVERSE } + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "resolve-peer-name"; + } + + @Override + public Map> parameters() { + return Collections.emptyMap(); + } + + @Override + public Set requiredParameters() { + return Collections.emptySet(); + } + + @Override + public String defaultParameter() { + return null; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper(); + } + + } + + private static class Wrapper implements HandlerWrapper { + @Override + public HttpHandler wrap(HttpHandler handler) { + return new PeerNameResolvingHandler(handler); + } + } + + } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/PredicateContextHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/PredicateContextHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/PredicateContextHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/PredicateContextHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import io.undertow.predicate.Predicate; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/PredicateHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/PredicateHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/PredicateHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/PredicateHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import io.undertow.predicate.Predicate; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/ProxyPeerAddressHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/ProxyPeerAddressHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/ProxyPeerAddressHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/ProxyPeerAddressHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,11 +1,33 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.Headers; -import java.net.InetAddress; import java.net.InetSocketAddress; +import java.util.Collections; +import java.util.Map; +import java.util.Set; /** * Handler that sets the peer address to the value of the X-Forwarded-For header. @@ -32,16 +54,68 @@ if (index == -1) { value = forwardedFor; } else { - value = forwardedFor.substring(0, index - 1); + value = forwardedFor.substring(0, index); } - InetAddress address = InetAddress.getByName(value); //we have no way of knowing the port - exchange.setSourceAddress(new InetSocketAddress(address, 0)); + exchange.setSourceAddress(InetSocketAddress.createUnresolved(value, 0)); } String forwardedProto = exchange.getRequestHeaders().getFirst(Headers.X_FORWARDED_PROTO); if (forwardedProto != null) { exchange.setRequestScheme(forwardedProto); } + String forwardedHost = exchange.getRequestHeaders().getFirst(Headers.X_FORWARDED_HOST); + String forwardedPort = exchange.getRequestHeaders().getFirst(Headers.X_FORWARDED_PORT); + if (forwardedHost != null) { + int index = forwardedHost.indexOf(','); + final String value; + if (index == -1) { + value = forwardedHost; + } else { + value = forwardedHost.substring(0, index); + } + int port = 0; + if(forwardedPort != null) { + port = Integer.parseInt(forwardedPort); + } + exchange.setDestinationAddress(InetSocketAddress.createUnresolved(value, port)); + } next.handleRequest(exchange); } + + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "proxy-peer-address"; + } + + @Override + public Map> parameters() { + return Collections.emptyMap(); + } + + @Override + public Set requiredParameters() { + return Collections.emptySet(); + } + + @Override + public String defaultParameter() { + return null; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper(); + } + + } + + private static class Wrapper implements HandlerWrapper { + @Override + public HttpHandler wrap(HttpHandler handler) { + return new ProxyPeerAddressHandler(handler); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/RedirectHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/RedirectHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/RedirectHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/RedirectHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,10 +1,35 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + import io.undertow.attribute.ExchangeAttribute; import io.undertow.attribute.ExchangeAttributeParser; import io.undertow.attribute.ExchangeAttributes; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.Headers; /** @@ -29,11 +54,63 @@ attribute = parser.parse(location); } + public RedirectHandler(ExchangeAttribute attribute) { + this.attribute = attribute; + } + @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { exchange.setResponseCode(302); exchange.getResponseHeaders().put(Headers.LOCATION, attribute.readAttribute(exchange)); exchange.endExchange(); } + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "redirect"; + } + + @Override + public Map> parameters() { + Map> params = new HashMap<>(); + params.put("value", ExchangeAttribute.class); + + return params; + } + + @Override + public Set requiredParameters() { + return Collections.singleton("value"); + } + + @Override + public String defaultParameter() { + return "value"; + } + + @Override + public HandlerWrapper build(Map config) { + + return new Wrapper((ExchangeAttribute)config.get("value")); + } + + } + + private static class Wrapper implements HandlerWrapper { + + private final ExchangeAttribute value; + + private Wrapper(ExchangeAttribute value) { + this.value = value; + } + + @Override + public HttpHandler wrap(HttpHandler handler) { + return new RedirectHandler(value); + } + } + } Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/handlers/RequestDumpingHandler.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/handlers/RequestDumplingHandler.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/server/handlers/RequestLimit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/RequestLimit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/RequestLimit.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/RequestLimit.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import io.undertow.server.Connectors; @@ -77,7 +95,7 @@ } state = (maximumConcurrentRequests & 0xFFFFFFFFL) << 32; - this.queue = new LinkedBlockingQueue(queueSize <= 0 ? Integer.MAX_VALUE : queueSize); + this.queue = new LinkedBlockingQueue<>(queueSize <= 0 ? Integer.MAX_VALUE : queueSize); } public void handleRequest(final HttpServerExchange exchange, final HttpHandler next) throws Exception { Index: 3rdParty_sources/undertow/io/undertow/server/handlers/RequestLimitingHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/RequestLimitingHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/RequestLimitingHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/RequestLimitingHandler.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,17 +9,23 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; /** * A handler which limits the maximum number of concurrent requests. Requests beyond the limit will @@ -66,8 +72,8 @@ * Construct a new instance. This version takes a {@link RequestLimit} directly which may be shared with other * handlers. * - * @param requestLimit the request limit information. - * @param nextHandler the next handler + * @param requestLimit the request limit information. + * @param nextHandler the next handler */ public RequestLimitingHandler(RequestLimit requestLimit, HttpHandler nextHandler) { if (nextHandler == null) { @@ -84,4 +90,48 @@ public RequestLimit getRequestLimit() { return requestLimit; } + + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "request-limit"; + } + + @Override + public Map> parameters() { + return Collections.>singletonMap("requests", int.class); + } + + @Override + public Set requiredParameters() { + return Collections.singleton("requests"); + } + + @Override + public String defaultParameter() { + return "requests"; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper((Integer) config.get("requests")); + } + + } + + private static class Wrapper implements HandlerWrapper { + + private final int requests; + + private Wrapper(int requests) { + this.requests = requests; + } + + @Override + public HttpHandler wrap(HttpHandler handler) { + return new RequestLimitingHandler(requests, handler); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/ResponseCodeHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/ResponseCodeHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/ResponseCodeHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/ResponseCodeHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; @@ -51,6 +51,10 @@ */ public static final ResponseCodeHandler HANDLE_404 = new ResponseCodeHandler(404); /** + * A handler which sets a 405 code. + */ + public static final ResponseCodeHandler HANDLE_405 = new ResponseCodeHandler(405); + /** * A handler which sets a 406 code. */ public static final ResponseCodeHandler HANDLE_406 = new ResponseCodeHandler(406); Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/handlers/ResponseRateLimitingHandler.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/server/handlers/SSLHeaderHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/SSLHeaderHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/SSLHeaderHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/SSLHeaderHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,11 +1,31 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import io.undertow.UndertowLogger; import io.undertow.server.BasicSSLSessionInfo; import io.undertow.server.ExchangeCompletionListener; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.server.SSLSessionInfo; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.Certificates; import io.undertow.util.HeaderMap; @@ -15,6 +35,10 @@ import static io.undertow.util.Headers.SSL_CLIENT_CERT; import static io.undertow.util.Headers.SSL_SESSION_ID; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + /** * Handler that sets SSL information on the connection based on the following headers: *

@@ -83,4 +107,42 @@ } next.handleRequest(exchange); } + + + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "ssl-headers"; + } + + @Override + public Map> parameters() { + return Collections.emptyMap(); + } + + @Override + public Set requiredParameters() { + return Collections.emptySet(); + } + + @Override + public String defaultParameter() { + return null; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper(); + } + + } + + private static class Wrapper implements HandlerWrapper { + @Override + public HttpHandler wrap(HttpHandler handler) { + return new SSLHeaderHandler(handler); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/SetAttributeHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/SetAttributeHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/SetAttributeHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/SetAttributeHandler.java 25 Nov 2014 10:46:47 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import io.undertow.attribute.ExchangeAttribute; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/SetHeaderHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/SetHeaderHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/SetHeaderHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/SetHeaderHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers; @@ -23,18 +23,20 @@ import io.undertow.util.HttpString; /** + * Set a fixed response header. + * * @author Stuart Douglas */ public class SetHeaderHandler implements HttpHandler { private final HttpString header; private final String value; + private final HttpHandler next; - private volatile HttpHandler next = ResponseCodeHandler.HANDLE_404; - public SetHeaderHandler(final String header, final String value) { - this.header = new HttpString(header); + this.next = ResponseCodeHandler.HANDLE_404; this.value = value; + this.header = new HttpString(header); } public SetHeaderHandler(final HttpHandler next, final String header, final String value) { Index: 3rdParty_sources/undertow/io/undertow/server/handlers/URLDecodingHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/Attic/URLDecodingHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/URLDecodingHandler.java 8 Sep 2014 10:52:08 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/URLDecodingHandler.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,13 +1,35 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers; import java.util.ArrayDeque; +import java.util.Collections; import java.util.Deque; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import io.undertow.UndertowOptions; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.URLUtils; /** @@ -40,9 +62,9 @@ exchange.setRelativePath(URLUtils.decode(exchange.getRelativePath(), charset, decodeSlash, sb)); exchange.setResolvedPath(URLUtils.decode(exchange.getResolvedPath(), charset, decodeSlash, sb)); if (!exchange.getQueryString().isEmpty()) { - final TreeMap> newParams = new TreeMap>(); + final TreeMap> newParams = new TreeMap<>(); for (Map.Entry> param : exchange.getQueryParameters().entrySet()) { - final Deque newVales = new ArrayDeque(param.getValue().size()); + final Deque newVales = new ArrayDeque<>(param.getValue().size()); for (String val : param.getValue()) { newVales.add(URLUtils.decode(val, charset, true, sb)); } @@ -54,4 +76,49 @@ } next.handleRequest(exchange); } + + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "url-decoding"; + } + + @Override + public Map> parameters() { + return Collections.>singletonMap("charset", String.class); + } + + @Override + public Set requiredParameters() { + return Collections.singleton("charset"); + } + + @Override + public String defaultParameter() { + return "charset"; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper(config.get("charset").toString()); + } + + } + + private static class Wrapper implements HandlerWrapper { + + private final String charset; + + private Wrapper(String charset) { + this.charset = charset; + } + + @Override + public HttpHandler wrap(HttpHandler handler) { + return new URLDecodingHandler(handler, charset); + } + } + } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/AccessLogHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/Attic/AccessLogHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/AccessLogHandler.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/AccessLogHandler.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,12 +1,36 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.accesslog; +import java.util.Collections; +import java.util.Map; +import java.util.Set; + import io.undertow.attribute.ExchangeAttribute; import io.undertow.attribute.ExchangeAttributes; import io.undertow.attribute.SubstituteEmptyWrapper; import io.undertow.server.ExchangeCompletionListener; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; /** * Access log handler. This handler will generate access log messages based on the provided format string, @@ -28,8 +52,7 @@ *

  • %l - Remote logical username from identd (always returns '-') *
  • %m - Request method *
  • %p - Local port - *
  • %q - Query string (prepended with a '?' if it exists, otherwise - * an empty string + *
  • %q - Query string (excluding the '?' character) *
  • %r - First line of the request *
  • %s - HTTP status code of the response *
  • %t - Date and time, in Common Log Format format @@ -112,4 +135,48 @@ '}'; } + + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "access-log"; + } + + @Override + public Map> parameters() { + return Collections.>singletonMap("format", String.class); + } + + @Override + public Set requiredParameters() { + return Collections.singleton("format"); + } + + @Override + public String defaultParameter() { + return "format"; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper((String) config.get("format")); + } + + } + + private static class Wrapper implements HandlerWrapper { + + private final String format; + + private Wrapper(String format) { + this.format = format; + } + + @Override + public HttpHandler wrap(HttpHandler handler) { + return new AccessLogHandler(handler, new JBossLoggingAccessLogReceiver(), format, Wrapper.class.getClassLoader()); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/AccessLogReceiver.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/Attic/AccessLogReceiver.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/AccessLogReceiver.java 8 Sep 2014 10:52:22 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/AccessLogReceiver.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.accesslog; /** Index: 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/DefaultAccessLogReceiver.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/Attic/DefaultAccessLogReceiver.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/DefaultAccessLogReceiver.java 8 Sep 2014 10:52:22 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/DefaultAccessLogReceiver.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.accesslog; import java.io.BufferedWriter; @@ -55,6 +73,8 @@ private Writer writer = null; + private volatile boolean closed = false; + public DefaultAccessLogReceiver(final Executor logWriteExecutor, final File outputDirectory, final String logBaseName) { this(logWriteExecutor, outputDirectory, logBaseName, null); } @@ -64,16 +84,17 @@ this.outputDirectory = outputDirectory; this.logBaseName = logBaseName; this.logNameSuffix = (logNameSuffix != null) ? logNameSuffix : DEFAULT_LOG_SUFFIX; - this.pendingMessages = new ConcurrentLinkedDeque(); + this.pendingMessages = new ConcurrentLinkedDeque<>(); this.defaultLogFile = new File(outputDirectory, logBaseName + this.logNameSuffix); calculateChangeOverPoint(); } private void calculateChangeOverPoint() { Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.SECOND, 59); - calendar.set(Calendar.MINUTE, 59); - calendar.set(Calendar.HOUR, 23); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.HOUR, 0); + calendar.add(Calendar.DATE, 1); changeOverPoint = calendar.getTimeInMillis(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); currentDateString = df.format(new Date()); @@ -101,7 +122,7 @@ if (forceLogRotation) { doRotate(); } - List messages = new ArrayList(); + List messages = new ArrayList<>(); String msg = null; //only grab at most 1000 messages at a time for (int i = 0; i < 1000; ++i) { @@ -123,6 +144,14 @@ if (stateUpdater.compareAndSet(this, 0, 1)) { logWriteExecutor.execute(this); } + } else if(closed) { + try { + writer.flush(); + writer.close(); + writer = null; + } catch (IOException e) { + UndertowLogger.ROOT_LOGGER.errorWritingAccessLog(e); + } } } } @@ -148,7 +177,7 @@ } try { if (writer == null) { - writer = new BufferedWriter(new FileWriter(defaultLogFile)); + writer = new BufferedWriter(new FileWriter(defaultLogFile, true)); } for (String message : messages) { writer.write(message); @@ -197,8 +226,9 @@ @Override public void close() throws IOException { - writer.flush(); - writer.close(); - writer = null; + closed = true; + if (stateUpdater.compareAndSet(this, 0, 1)) { + logWriteExecutor.execute(this); + } } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/JBossLoggingAccessLogReceiver.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/Attic/JBossLoggingAccessLogReceiver.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/JBossLoggingAccessLogReceiver.java 8 Sep 2014 10:52:22 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/accesslog/JBossLoggingAccessLogReceiver.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.accesslog; import org.jboss.logging.Logger; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/builder/HandlerBuilder.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/builder/Attic/HandlerBuilder.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/builder/HandlerBuilder.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/builder/HandlerBuilder.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.builder; import io.undertow.server.HandlerWrapper; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/builder/HandlerParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/builder/Attic/HandlerParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/builder/HandlerParser.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/builder/HandlerParser.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.builder; @@ -64,7 +64,7 @@ private static Map loadBuilders(final ClassLoader classLoader) { ServiceLoader loader = ServiceLoader.load(HandlerBuilder.class, classLoader); - final Map ret = new HashMap(); + final Map ret = new HashMap<>(); for (HandlerBuilder builder : loader) { if (ret.containsKey(builder.name())) { if (ret.get(builder.name()).getClass() != builder.getClass()) { @@ -104,7 +104,7 @@ } Token next = tokens.peek(); if (next.token.equals("[")) { - final Map values = new HashMap(); + final Map values = new HashMap<>(); tokens.poll(); next = tokens.poll(); @@ -198,7 +198,7 @@ } Class componentType = type.getComponentType(); - final List values = new ArrayList(); + final List values = new ArrayList<>(); Token token = tokens.poll(); while (token != null) { Token commaOrEnd = tokens.poll(); @@ -229,7 +229,7 @@ } private static void checkParameters(final String string, int pos, final Map values, final HandlerBuilder builder) { - final Set required = new HashSet(builder.requiredParameters()); + final Set required = new HashSet<>(builder.requiredParameters()); for (String key : values.keySet()) { required.remove(key); } @@ -316,7 +316,7 @@ int pos = 0; StringBuilder current = new StringBuilder(); - Deque ret = new ArrayDeque(); + Deque ret = new ArrayDeque<>(); while (pos < string.length()) { char c = string.charAt(pos); if (currentStringDelim != 0) { Index: 3rdParty_sources/undertow/io/undertow/server/handlers/builder/PredicatedHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/builder/Attic/PredicatedHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/builder/PredicatedHandler.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/builder/PredicatedHandler.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.builder; import io.undertow.predicate.Predicate; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/builder/PredicatedHandlersParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/builder/Attic/PredicatedHandlersParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/builder/PredicatedHandlersParser.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/builder/PredicatedHandlersParser.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,15 +1,34 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.builder; -import io.undertow.UndertowMessages; import io.undertow.predicate.Predicate; import io.undertow.predicate.PredicateParser; import io.undertow.predicate.Predicates; import io.undertow.server.HandlerWrapper; +import io.undertow.util.ChaninedHandlerWrapper; import io.undertow.util.FileUtils; import java.io.File; import java.io.InputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -33,7 +52,7 @@ public static List parse(final String contents, final ClassLoader classLoader) { String[] lines = contents.split("\\n"); - final List wrappers = new ArrayList(); + final List wrappers = new ArrayList<>(); for (String line : lines) { if (line.trim().length() > 0) { @@ -47,7 +66,12 @@ predicate = Predicates.truePredicate(); handler = HandlerParser.parse(parts[0], classLoader); } else { - throw UndertowMessages.MESSAGES.invalidSyntax(line); + predicate = PredicateParser.parse(parts[0], classLoader); + HandlerWrapper[] handlers = new HandlerWrapper[parts.length -1]; + for(int i = 0; i < handlers.length; ++i) { + handlers[i] = HandlerParser.parse(parts[i + 1], classLoader); + } + handler = new ChaninedHandlerWrapper(Arrays.asList(handlers)); } wrappers.add(new PredicatedHandler(predicate, handler)); } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/builder/ResponseCodeHandlerBuilder.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/builder/Attic/ResponseCodeHandlerBuilder.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/builder/ResponseCodeHandlerBuilder.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/builder/ResponseCodeHandlerBuilder.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.builder; import io.undertow.server.HandlerWrapper; @@ -20,14 +38,14 @@ @Override public Map> parameters() { - Map> parameters = new HashMap>(); + Map> parameters = new HashMap<>(); parameters.put("value", Integer.class); return parameters; } @Override public Set requiredParameters() { - final Set req = new HashSet(); + final Set req = new HashSet<>(); req.add("value"); return req; } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/builder/RewriteHandlerBuilder.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/builder/Attic/RewriteHandlerBuilder.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/builder/RewriteHandlerBuilder.java 8 Sep 2014 10:52:13 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/builder/RewriteHandlerBuilder.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.builder; import io.undertow.attribute.ExchangeAttribute; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/builder/SetHandlerBuilder.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/builder/Attic/SetHandlerBuilder.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/builder/SetHandlerBuilder.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/builder/SetHandlerBuilder.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.builder; import io.undertow.attribute.ExchangeAttribute; @@ -21,7 +39,7 @@ @Override public Map> parameters() { - Map> parameters = new HashMap>(); + Map> parameters = new HashMap<>(); parameters.put("value", ExchangeAttribute.class); parameters.put("attribute", ExchangeAttribute.class); @@ -30,7 +48,7 @@ @Override public Set requiredParameters() { - final Set req = new HashSet(); + final Set req = new HashSet<>(); req.add("value"); req.add("attribute"); return req; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/cache/CacheHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/cache/Attic/CacheHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/cache/CacheHandler.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/cache/CacheHandler.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.cache; import io.undertow.Handlers; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/cache/CachedHttpRequest.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/cache/Attic/CachedHttpRequest.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/cache/CachedHttpRequest.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/cache/CachedHttpRequest.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.cache; import java.util.Date; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/cache/DirectBufferCache.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/cache/Attic/DirectBufferCache.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/cache/DirectBufferCache.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/cache/DirectBufferCache.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.cache; @@ -64,7 +64,7 @@ public DirectBufferCache(int sliceSize, int slicesPerPage, int maxMemory, final BufferAllocator bufferAllocator, int maxAge) { this.sliceSize = sliceSize; this.pool = new LimitedBufferSlicePool(bufferAllocator, sliceSize, sliceSize * slicesPerPage, maxMemory / (sliceSize * slicesPerPage)); - this.cache = new ConcurrentHashMap(16); + this.cache = new ConcurrentHashMap<>(16); this.accessQueue = ConcurrentDirectDeque.newInstance(); this.maxAge = maxAge; } @@ -140,7 +140,7 @@ * @return all the keys in this cache */ public Set getAllKeys() { - return new HashSet(cache.keySet()); + return new HashSet<>(cache.keySet()); } private void bumpAccess(CacheEntry cacheEntry) { Index: 3rdParty_sources/undertow/io/undertow/server/handlers/cache/LRUCache.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/cache/Attic/LRUCache.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/cache/LRUCache.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/cache/LRUCache.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.cache; @@ -53,7 +53,7 @@ public LRUCache(int maxEntries, final int maxAge) { this.maxAge = maxAge; - this.cache = new ConcurrentHashMap>(16); + this.cache = new ConcurrentHashMap<>(16); this.accessQueue = ConcurrentDirectDeque.newInstance(); this.maxEntries = maxEntries; } @@ -67,7 +67,7 @@ } else { expires = System.currentTimeMillis() + maxAge; } - value = new CacheEntry(key, newValue, expires); + value = new CacheEntry<>(key, newValue, expires); CacheEntry result = cache.putIfAbsent(key, value); if (result != null) { value = result; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/cache/LimitedBufferSlicePool.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/cache/Attic/LimitedBufferSlicePool.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/cache/LimitedBufferSlicePool.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/cache/LimitedBufferSlicePool.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.cache; @@ -39,7 +39,7 @@ public final class LimitedBufferSlicePool { private static final AtomicIntegerFieldUpdater regionUpdater = AtomicIntegerFieldUpdater.newUpdater(LimitedBufferSlicePool.class, "regionsUsed"); - private final Queue sliceQueue = new ConcurrentLinkedQueue(); + private final Queue sliceQueue = new ConcurrentLinkedQueue<>(); private final BufferAllocator allocator; private final int bufferSize; private final int buffersPerRegion; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/cache/ResponseCache.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/cache/Attic/ResponseCache.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/cache/ResponseCache.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/cache/ResponseCache.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.cache; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/cache/ResponseCachingSender.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/cache/Attic/ResponseCachingSender.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/cache/ResponseCachingSender.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/cache/ResponseCachingSender.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.cache; import java.io.UnsupportedEncodingException; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/cache/ResponseCachingStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/cache/Attic/ResponseCachingStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/cache/ResponseCachingStreamSinkConduit.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/cache/ResponseCachingStreamSinkConduit.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.cache; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/AllowedContentEncodings.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/encoding/Attic/AllowedContentEncodings.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/AllowedContentEncodings.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/AllowedContentEncodings.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.encoding; import java.util.List; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodedResource.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/encoding/Attic/ContentEncodedResource.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodedResource.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodedResource.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.encoding; import io.undertow.server.handlers.resource.Resource; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodedResourceManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/encoding/Attic/ContentEncodedResourceManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodedResourceManager.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodedResourceManager.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.encoding; import io.undertow.UndertowLogger; @@ -40,7 +58,7 @@ private final int maxResourceSize; private final Predicate encodingAllowed; - private final ConcurrentMap fileLocks = new ConcurrentHashMap(); + private final ConcurrentMap fileLocks = new ConcurrentHashMap<>(); public ContentEncodedResourceManager(File encodedResourcesRoot, CachingResourceManager encodedResourceManager, ContentEncodingRepository contentEncodingRepository, int minResourceSize, int maxResourceSize, Predicate encodingAllowed) { this.encodedResourcesRoot = encodedResourcesRoot; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodingProvider.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/encoding/Attic/ContentEncodingProvider.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodingProvider.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodingProvider.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.encoding; import io.undertow.server.ConduitWrapper; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodingRepository.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/encoding/Attic/ContentEncodingRepository.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodingRepository.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/ContentEncodingRepository.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.encoding; import io.undertow.predicate.Predicate; @@ -20,8 +38,9 @@ public class ContentEncodingRepository { public static final String IDENTITY = "identity"; + public static final EncodingMapping IDENTITY_ENCODING = new EncodingMapping(IDENTITY, ContentEncodingProvider.IDENTITY, 0, Predicates.truePredicate()); - private final Map encodingMap = new CopyOnWriteMap(); + private final Map encodingMap = new CopyOnWriteMap<>(); /** * Gets all allow @@ -33,20 +52,23 @@ if (res == null || res.isEmpty()) { return null; } - final List resultingMappings = new ArrayList(); + final List resultingMappings = new ArrayList<>(); final List> found = QValueParser.parse(res); for (List result : found) { - List available = new ArrayList(); + List available = new ArrayList<>(); boolean includesIdentity = false; boolean isQValue0 = false; for (final QValueParser.QValueResult value : result) { EncodingMapping encoding; if (value.getValue().equals("*")) { includesIdentity = true; - encoding = new EncodingMapping(IDENTITY, ContentEncodingProvider.IDENTITY, 0, Predicates.truePredicate()); + encoding = IDENTITY_ENCODING; } else { encoding = encodingMap.get(value.getValue()); + if(encoding == null && IDENTITY.equals(value.getValue())) { + encoding = IDENTITY_ENCODING; + } } if (value.isQValueZero()) { isQValue0 = true; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/DeflateEncodingProvider.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/encoding/Attic/DeflateEncodingProvider.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/DeflateEncodingProvider.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/DeflateEncodingProvider.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.encoding; import io.undertow.conduits.DeflatingStreamSinkConduit; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/EncodingHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/encoding/Attic/EncodingHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/EncodingHandler.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/EncodingHandler.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.encoding; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/EncodingMapping.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/encoding/Attic/EncodingMapping.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/EncodingMapping.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/EncodingMapping.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.encoding; import io.undertow.predicate.Predicate; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/GzipEncodingProvider.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/encoding/Attic/GzipEncodingProvider.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/GzipEncodingProvider.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/encoding/GzipEncodingProvider.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.encoding; import io.undertow.conduits.GzipStreamSinkConduit; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/error/FileErrorPageHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/error/Attic/FileErrorPageHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/error/FileErrorPageHandler.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/error/FileErrorPageHandler.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.error; @@ -24,22 +24,26 @@ import java.nio.channels.FileChannel; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; +import org.jboss.logging.Logger; +import org.xnio.FileAccess; +import org.xnio.IoUtils; +import org.xnio.channels.Channels; +import org.xnio.channels.StreamSinkChannel; import io.undertow.Handlers; import io.undertow.UndertowLogger; import io.undertow.server.DefaultResponseListener; import io.undertow.server.ExchangeCompletionListener; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.server.handlers.ResponseCodeHandler; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.util.Headers; -import org.jboss.logging.Logger; -import org.xnio.FileAccess; -import org.xnio.IoUtils; -import org.xnio.channels.Channels; -import org.xnio.channels.StreamSinkChannel; /** * Handler that serves up a file from disk to serve as an error page. @@ -63,7 +67,7 @@ public FileErrorPageHandler(final File file, final Integer... responseCodes) { this.file = file; - this.responseCodes = new HashSet(Arrays.asList(responseCodes)); + this.responseCodes = new HashSet<>(Arrays.asList(responseCodes)); } @Override @@ -149,13 +153,13 @@ if (responseCodes == null) { this.responseCodes = Collections.emptySet(); } else { - this.responseCodes = new HashSet(responseCodes); + this.responseCodes = new HashSet<>(responseCodes); } return this; } public FileErrorPageHandler setResponseCodes(final Integer... responseCodes) { - this.responseCodes = new HashSet(Arrays.asList(responseCodes)); + this.responseCodes = new HashSet<>(Arrays.asList(responseCodes)); return this; } @@ -167,4 +171,53 @@ this.file = file; return this; } + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "error-file"; + } + + @Override + public Map> parameters() { + Map> params = new HashMap<>(); + params.put("file", String.class); + params.put("response-codes", Integer[].class); + return params; + } + + @Override + public Set requiredParameters() { + return new HashSet<>(Arrays.asList(new String[]{"file", "response-codes"})); + } + + @Override + public String defaultParameter() { + return null; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper((String)config.get("file"), (Integer[]) config.get("response-codes")); + } + + } + + private static class Wrapper implements HandlerWrapper { + + private final String file; + private final Integer[] responseCodes; + + private Wrapper(String file, Integer[] responseCodes) { + this.file = file; + this.responseCodes = responseCodes; + } + + + @Override + public HttpHandler wrap(HttpHandler handler) { + return new FileErrorPageHandler(new File(file), responseCodes); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/error/SimpleErrorPageHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/error/Attic/SimpleErrorPageHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/error/SimpleErrorPageHandler.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/error/SimpleErrorPageHandler.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.error; @@ -91,12 +91,12 @@ } public SimpleErrorPageHandler setResponseCodes(final Set responseCodes) { - this.responseCodes = new HashSet(responseCodes); + this.responseCodes = new HashSet<>(responseCodes); return this; } public SimpleErrorPageHandler setResponseCodes(final Integer... responseCodes) { - this.responseCodes = new HashSet(Arrays.asList(responseCodes)); + this.responseCodes = new HashSet<>(Arrays.asList(responseCodes)); return this; } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/form/EagerFormParsingHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/form/Attic/EagerFormParsingHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/form/EagerFormParsingHandler.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/form/EagerFormParsingHandler.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.form; @@ -55,7 +55,12 @@ next.handleRequest(exchange); return; } - parser.parse(next); + if(exchange.isBlocking()) { + exchange.putAttachment(FormDataParser.FORM_DATA, parser.parseBlocking()); + next.handleRequest(exchange); + } else { + parser.parse(next); + } } public HttpHandler getNext() { Index: 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormData.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/form/Attic/FormData.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormData.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormData.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.form; @@ -35,7 +35,7 @@ */ public final class FormData implements Iterable { - private final Map> values = new LinkedHashMap>(); + private final Map> values = new LinkedHashMap<>(); private final int maxValues; private int valueCount = 0; @@ -70,7 +70,7 @@ public void add(String name, String value, final HeaderMap headers) { Deque values = this.values.get(name); if (values == null) { - this.values.put(name, values = new ArrayDeque(1)); + this.values.put(name, values = new ArrayDeque<>(1)); } values.add(new FormValueImpl(value, headers)); if (++valueCount > maxValues) { @@ -81,7 +81,7 @@ public void add(String name, File value, String fileName, final HeaderMap headers) { Deque values = this.values.get(name); if (values == null) { - this.values.put(name, values = new ArrayDeque(1)); + this.values.put(name, values = new ArrayDeque<>(1)); } values.add(new FormValueImpl(value, fileName, headers)); if (values.size() > maxValues) { @@ -93,7 +93,7 @@ } public void put(String name, String value, final HeaderMap headers) { - Deque values = new ArrayDeque(1); + Deque values = new ArrayDeque<>(1); Deque old = this.values.put(name, values); if (old != null) { valueCount -= old.size(); Index: 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormDataParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/form/Attic/FormDataParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormDataParser.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormDataParser.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.form; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormEncodedDataDefinition.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/form/Attic/FormEncodedDataDefinition.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormEncodedDataDefinition.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormEncodedDataDefinition.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.form; @@ -25,10 +25,10 @@ import io.undertow.UndertowLogger; import io.undertow.UndertowMessages; import io.undertow.UndertowOptions; -import io.undertow.server.Connectors; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.util.Headers; +import io.undertow.util.SameThreadExecutor; import org.xnio.ChannelListener; import org.xnio.IoUtils; import org.xnio.Pooled; @@ -45,14 +45,15 @@ public static final String APPLICATION_X_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded"; private String defaultEncoding = "ISO-8859-1"; + private boolean forceCreation = false; //if the parser should be created even if the correct headers are missing public FormEncodedDataDefinition() { } @Override public FormDataParser create(final HttpServerExchange exchange) { String mimeType = exchange.getRequestHeaders().getFirst(Headers.CONTENT_TYPE); - if (mimeType != null && mimeType.startsWith(APPLICATION_X_WWW_FORM_URLENCODED)) { + if (forceCreation || (mimeType != null && mimeType.startsWith(APPLICATION_X_WWW_FORM_URLENCODED))) { String charset = defaultEncoding; String contentType = exchange.getRequestHeaders().getFirst(Headers.CONTENT_TYPE); @@ -71,6 +72,15 @@ return defaultEncoding; } + public boolean isForceCreation() { + return forceCreation; + } + + public FormEncodedDataDefinition setForceCreation(boolean forceCreation) { + this.forceCreation = forceCreation; + return this; + } + public FormEncodedDataDefinition setDefaultEncoding(final String defaultEncoding) { this.defaultEncoding = defaultEncoding; return this; @@ -103,7 +113,7 @@ try { doParse(channel); if (state == 4) { - Connectors.executeRootHandler(handler, exchange); + exchange.dispatch(SameThreadExecutor.INSTANCE, handler); } } catch (IOException e) { IoUtils.safeClose(channel); @@ -119,6 +129,7 @@ try { final ByteBuffer buffer = pooled.getResource(); do { + buffer.clear(); c = channel.read(buffer); if (c > 0) { buffer.flip(); @@ -130,6 +141,10 @@ name = builder.toString(); builder.setLength(0); state = 2; + } else if (n == '&') { + data.add(builder.toString(), ""); + builder.setLength(0); + state = 0; } else if (n == '%' || n == '+') { state = 1; builder.append((char) n); @@ -143,6 +158,10 @@ name = URLDecoder.decode(builder.toString(), charset); builder.setLength(0); state = 2; + } else if (n == '&') { + data.add(URLDecoder.decode(builder.toString(), charset), ""); + builder.setLength(0); + state = 0; } else { builder.append((char) n); } @@ -180,6 +199,12 @@ data.add(name, builder.toString()); } else if (state == 3) { data.add(name, URLDecoder.decode(builder.toString(), charset)); + } else if(builder.length() > 0) { + if(state == 1) { + data.add(URLDecoder.decode(builder.toString(), charset), ""); + } else { + data.add(builder.toString(), ""); + } } state = 4; exchange.putAttachment(FORM_DATA, data); @@ -206,7 +231,7 @@ channel.getReadSetter().set(this); channel.resumeReads(); } else { - Connectors.executeRootHandler(handler, exchange); + exchange.dispatch(SameThreadExecutor.INSTANCE, handler); } } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormParserFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/form/Attic/FormParserFactory.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormParserFactory.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/form/FormParserFactory.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.form; import java.util.ArrayList; @@ -65,7 +83,7 @@ public static class Builder { - private List parsers = new ArrayList(); + private List parsers = new ArrayList<>(); public Builder addParser(final ParserDefinition definition) { parsers.add(definition); Index: 3rdParty_sources/undertow/io/undertow/server/handlers/form/MultiPartParserDefinition.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/form/Attic/MultiPartParserDefinition.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/form/MultiPartParserDefinition.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/form/MultiPartParserDefinition.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,43 +9,44 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.form; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Executor; - import io.undertow.UndertowLogger; import io.undertow.UndertowMessages; import io.undertow.UndertowOptions; -import io.undertow.server.Connectors; import io.undertow.server.ExchangeCompletionListener; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.util.HeaderMap; import io.undertow.util.Headers; import io.undertow.util.MalformedMessageException; import io.undertow.util.MultipartParser; +import io.undertow.util.SameThreadExecutor; +import org.xnio.ChannelListener; import org.xnio.FileAccess; import org.xnio.IoUtils; import org.xnio.Pooled; import org.xnio.channels.StreamSourceChannel; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Executor; + /** - * * @author Stuart Douglas */ public class MultiPartParserDefinition implements FormParserFactory.ParserDefinition { @@ -73,11 +74,11 @@ String mimeType = exchange.getRequestHeaders().getFirst(Headers.CONTENT_TYPE); if (mimeType != null && mimeType.startsWith(MULTIPART_FORM_DATA)) { String boundary = Headers.extractTokenFromHeader(mimeType, "boundary"); - if(boundary == null) { + if (boundary == null) { UndertowLogger.REQUEST_LOGGER.debugf("Could not find boundary in multipart request with ContentType: %s, multipart data will not be available", mimeType); return null; } - final MultiPartUploadHandler parser = new MultiPartUploadHandler(exchange, boundary, maxIndividualFileSize, defaultEncoding); + final MultiPartUploadHandler parser = new MultiPartUploadHandler(exchange, boundary, maxIndividualFileSize, defaultEncoding); exchange.addExchangeCompleteListener(new ExchangeCompletionListener() { @Override public void exchangeEvent(final HttpServerExchange exchange, final NextListener nextListener) { @@ -126,12 +127,12 @@ this.maxIndividualFileSize = maxIndividualFileSize; } - private final class MultiPartUploadHandler implements FormDataParser, Runnable, MultipartParser.PartHandler { + private final class MultiPartUploadHandler implements FormDataParser, MultipartParser.PartHandler { private final HttpServerExchange exchange; private final FormData data; private final String boundary; - private final List createdFiles = new ArrayList(); + private final List createdFiles = new ArrayList<>(); private final long maxIndividualFileSize; private String defaultEncoding; @@ -143,6 +144,7 @@ private HeaderMap headers; private HttpHandler handler; private long currentFileSize; + private final MultipartParser.ParseState parser; private MultiPartUploadHandler(final HttpServerExchange exchange, final String boundary, final long maxIndividualFileSize, final String defaultEncoding) { @@ -151,6 +153,7 @@ this.maxIndividualFileSize = maxIndividualFileSize; this.defaultEncoding = defaultEncoding; this.data = new FormData(exchange.getConnection().getUndertowOptions().get(UndertowOptions.MAX_PARAMETERS, 1000)); + this.parser = MultipartParser.beginParse(exchange.getConnection().getBufferPool(), this, boundary.getBytes(), exchange.getRequestCharset()); } @@ -163,10 +166,15 @@ this.handler = handler; //we need to delegate to a thread pool //as we parse with blocking operations + + StreamSourceChannel requestChannel = exchange.getRequestChannel(); + if (requestChannel == null) { + throw new IOException(UndertowMessages.MESSAGES.requestChannelAlreadyProvided()); + } if (executor == null) { - exchange.dispatch(this); + exchange.dispatch(new NonBlockingParseTask(exchange.getConnection().getWorker(), requestChannel)); } else { - exchange.dispatch(executor, this); + exchange.dispatch(executor, new NonBlockingParseTask(executor, requestChannel)); } } @@ -178,46 +186,32 @@ } final MultipartParser.ParseState parser = MultipartParser.beginParse(exchange.getConnection().getBufferPool(), this, boundary.getBytes(), exchange.getRequestCharset()); - StreamSourceChannel requestChannel = exchange.getRequestChannel(); - if (requestChannel == null) { + InputStream inputStream = exchange.getInputStream(); + if (inputStream == null) { throw new IOException(UndertowMessages.MESSAGES.requestChannelAlreadyProvided()); } - final Pooled resource = exchange.getConnection().getBufferPool().allocate(); - final ByteBuffer buf = resource.getResource(); + byte[] buf = new byte[1024]; try { - while (!parser.isComplete()) { - buf.clear(); - requestChannel.awaitReadable(); - int c = requestChannel.read(buf); - buf.flip(); + while (true) { + int c = inputStream.read(buf); if (c == -1) { - throw UndertowMessages.MESSAGES.connectionTerminatedReadingMultiPartData(); + if (parser.isComplete()) { + break; + } else { + throw UndertowMessages.MESSAGES.connectionTerminatedReadingMultiPartData(); + } } else if (c != 0) { - parser.parse(buf); + parser.parse(ByteBuffer.wrap(buf, 0, c)); } } exchange.putAttachment(FORM_DATA, data); } catch (MalformedMessageException e) { throw new IOException(e); - } finally { - resource.free(); } return exchange.getAttachment(FORM_DATA); } @Override - public void run() { - try { - parseBlocking(); - Connectors.executeRootHandler(handler, exchange); - } catch (Throwable e) { - UndertowLogger.REQUEST_LOGGER.debug("Exception parsing data", e); - exchange.setResponseCode(500); - exchange.endExchange(); - } - } - - @Override public void beginPart(final HeaderMap headers) { this.currentFileSize = 0; this.headers = headers; @@ -242,7 +236,7 @@ @Override public void data(final ByteBuffer buffer) throws IOException { this.currentFileSize += buffer.remaining(); - if(this.maxIndividualFileSize > 0 && this.currentFileSize > this.maxIndividualFileSize) { + if (this.maxIndividualFileSize > 0 && this.currentFileSize > this.maxIndividualFileSize) { throw UndertowMessages.MESSAGES.maxFileSizeExceeded(this.maxIndividualFileSize); } if (file == null) { @@ -294,7 +288,7 @@ @Override public void close() throws IOException { //we have to dispatch this, as it may result in file IO - final List files = new ArrayList(getCreatedFiles()); + final List files = new ArrayList<>(getCreatedFiles()); exchange.getConnection().getWorker().execute(new Runnable() { @Override public void run() { @@ -314,6 +308,72 @@ public void setCharacterEncoding(final String encoding) { this.defaultEncoding = encoding; } - } + private final class NonBlockingParseTask implements Runnable { + + private final Executor executor; + private final StreamSourceChannel requestChannel; + + private NonBlockingParseTask(Executor executor, StreamSourceChannel requestChannel) { + this.executor = executor; + this.requestChannel = requestChannel; + } + + @Override + public void run() { + try { + final FormData existing = exchange.getAttachment(FORM_DATA); + if (existing != null) { + exchange.dispatch(SameThreadExecutor.INSTANCE, handler); + return; + } + Pooled pooled = exchange.getConnection().getBufferPool().allocate(); + try { + while (true) { + int c = requestChannel.read(pooled.getResource()); + if(c == 0) { + requestChannel.getReadSetter().set(new ChannelListener() { + @Override + public void handleEvent(StreamSourceChannel channel) { + channel.suspendReads(); + executor.execute(NonBlockingParseTask.this); + } + }); + requestChannel.resumeReads(); + return; + } else if (c == -1) { + if (parser.isComplete()) { + exchange.putAttachment(FORM_DATA, data); + exchange.dispatch(SameThreadExecutor.INSTANCE, handler); + } else { + UndertowLogger.REQUEST_IO_LOGGER.ioException(UndertowMessages.MESSAGES.connectionTerminatedReadingMultiPartData()); + exchange.setResponseCode(500); + exchange.endExchange(); + } + return; + } else { + pooled.getResource().flip(); + parser.parse(pooled.getResource()); + pooled.getResource().compact(); + } + } + } catch (MalformedMessageException e) { + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); + exchange.setResponseCode(500); + exchange.endExchange(); + } finally { + pooled.free(); + } + + } catch (Throwable e) { + UndertowLogger.REQUEST_IO_LOGGER.debug("Exception parsing data", e); + exchange.setResponseCode(500); + exchange.endExchange(); + } + } + } + } + + + } Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ConnectionPoolErrorHandler.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ConnectionPoolManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/proxy/Attic/ConnectionPoolManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ConnectionPoolManager.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ConnectionPoolManager.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,38 +1,34 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.proxy; -import io.undertow.server.HttpServerExchange; - /** * Manager that controls the behaviour of a {@link ProxyConnectionPool} * * @author Stuart Douglas */ -public interface ConnectionPoolManager { +public interface ConnectionPoolManager extends ProxyConnectionPoolConfig, ConnectionPoolErrorHandler { /** - * Returns true if the connection pool can create a new connection * - * @param connections The number of connections associated with the current IO thread. - * @param proxyConnectionPool The connection pool - * @return true if a connection can be created - */ - boolean canCreateConnection(int connections, ProxyConnectionPool proxyConnectionPool); - - /** - * This is invoked when the target thread pool transitions to problem status. It will be called once for each queued request - * that has not yet been allocated a connection. The manager can redistribute these requests to other hosts, or can end the - * exchange with an error status. - * - * @param proxyTarget The proxy target - * @param exchange The exchange - * @param callback The callback - * @param timeoutMills The remaining timeout in milliseconds, or -1 if no timeout has been specified - */ - void queuedConnectionFailed(ProxyClient.ProxyTarget proxyTarget, HttpServerExchange exchange, ProxyCallback callback, long timeoutMills); - - /** - * * @return The amount of time that we should wait before re-testing a problem server */ int getProblemServerRetry(); + } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ExclusivityChecker.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/proxy/Attic/ExclusivityChecker.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ExclusivityChecker.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ExclusivityChecker.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.proxy; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/HostTable.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/proxy/Attic/HostTable.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/HostTable.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/HostTable.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.proxy; import io.undertow.UndertowMessages; @@ -19,8 +37,8 @@ */ public class HostTable { - private final Map> hosts = new CopyOnWriteMap>(); - private final Map>> targets = new CopyOnWriteMap>>(); + private final Map> hosts = new CopyOnWriteMap<>(); + private final Map>> targets = new CopyOnWriteMap<>(); public synchronized HostTable addHost(H host) { if(hosts.containsKey(host)) { @@ -46,12 +64,12 @@ hostData.add(new Target(virtualHost, contextPath)); PathMatcher> paths = targets.get(virtualHost); if(paths == null) { - paths = new PathMatcher>(); + paths = new PathMatcher<>(); targets.put(virtualHost, paths); } Set hostSet = paths.getPrefixPath(contextPath); if(hostSet == null) { - hostSet = new CopyOnWriteArraySet(); + hostSet = new CopyOnWriteArraySet<>(); paths.addPrefixPath(contextPath, hostSet); } hostSet.add(host); Index: 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/LoadBalancingProxyClient.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/proxy/Attic/LoadBalancingProxyClient.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/LoadBalancingProxyClient.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/LoadBalancingProxyClient.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.proxy; import io.undertow.UndertowLogger; @@ -8,17 +26,18 @@ import io.undertow.server.handlers.Cookie; import io.undertow.util.AttachmentKey; import io.undertow.util.CopyOnWriteMap; +import org.xnio.OptionMap; +import org.xnio.ssl.XnioSsl; +import java.net.InetSocketAddress; import java.net.URI; import java.util.Map; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import static io.undertow.server.handlers.proxy.ProxyConnectionPool.AvailabilityType.AVAILABLE; -import static io.undertow.server.handlers.proxy.ProxyConnectionPool.AvailabilityType.FULL; -import static io.undertow.server.handlers.proxy.ProxyConnectionPool.AvailabilityType.PROBLEM; +import static io.undertow.server.handlers.proxy.ProxyConnectionPool.AvailabilityType.*; import static org.xnio.IoUtils.safeClose; /** @@ -43,12 +62,13 @@ */ private volatile int problemServerRetry = 10; - private final Set sessionCookieNames = new CopyOnWriteArraySet(); + private final Set sessionCookieNames = new CopyOnWriteArraySet<>(); /** * The number of connections to create per thread */ private volatile int connectionsPerThread = 10; + private volatile int maxQueueSize = 0; /** * The hosts list. @@ -58,30 +78,13 @@ private final AtomicInteger currentHost = new AtomicInteger(0); private final UndertowClient client; - private final Map routes = new CopyOnWriteMap(); + private final Map routes = new CopyOnWriteMap<>(); private final ExclusivityChecker exclusivityChecker; private static final ProxyTarget PROXY_TARGET = new ProxyTarget() { }; - private final ConnectionPoolManager manager = new ConnectionPoolManager() { - @Override - public boolean canCreateConnection(int connections, ProxyConnectionPool proxyConnectionPool) { - return connections < connectionsPerThread; - } - - @Override - public void queuedConnectionFailed(ProxyTarget proxyTarget, HttpServerExchange exchange, ProxyCallback callback, long timeoutMills) { - getConnection(proxyTarget, exchange, callback, timeoutMills, TimeUnit.MILLISECONDS); - } - - @Override - public int getProblemServerRetry() { - return problemServerRetry; - } - }; - public LoadBalancingProxyClient() { this(UndertowClient.getInstance()); } @@ -128,13 +131,31 @@ return this; } + public int getMaxQueueSize() { + return maxQueueSize; + } + + public LoadBalancingProxyClient setMaxQueueSize(int maxQueueSize) { + this.maxQueueSize = maxQueueSize; + return this; + } + public synchronized LoadBalancingProxyClient addHost(final URI host) { - return addHost(host, null); + return addHost(host, null, null); } + public synchronized LoadBalancingProxyClient addHost(final URI host, XnioSsl ssl) { + return addHost(host, null, ssl); + } + public synchronized LoadBalancingProxyClient addHost(final URI host, String jvmRoute) { - ProxyConnectionPool pool = new ProxyConnectionPool(manager, host, client); - Host h = new Host(pool, jvmRoute, host); + return addHost(host, jvmRoute, null); + } + + + public synchronized LoadBalancingProxyClient addHost(final URI host, String jvmRoute, XnioSsl ssl) { + + Host h = new Host(jvmRoute, null, host, ssl, OptionMap.EMPTY); Host[] existing = hosts; Host[] newHosts = new Host[existing.length + 1]; System.arraycopy(existing, 0, newHosts, 0, existing.length); @@ -146,6 +167,25 @@ return this; } + + public synchronized LoadBalancingProxyClient addHost(final URI host, String jvmRoute, XnioSsl ssl, OptionMap options) { + return addHost(null, host, jvmRoute, ssl, options); + } + + + public synchronized LoadBalancingProxyClient addHost(final InetSocketAddress bindAddress, final URI host, String jvmRoute, XnioSsl ssl, OptionMap options) { + Host h = new Host(jvmRoute, bindAddress, host, ssl, options); + Host[] existing = hosts; + Host[] newHosts = new Host[existing.length + 1]; + System.arraycopy(existing, 0, newHosts, 0, existing.length); + newHosts[existing.length] = h; + this.hosts = newHosts; + if (jvmRoute != null) { + this.routes.put(jvmRoute, h); + } + return this; + } + public synchronized LoadBalancingProxyClient removeHost(final URI uri) { int found = -1; Host[] existing = hosts; @@ -187,20 +227,14 @@ final Host host = selectHost(exchange); if (host == null) { - callback.failed(exchange); + callback.couldNotResolveBackend(exchange); } else { if (holder != null || (exclusivityChecker != null && exclusivityChecker.isExclusivityRequired(exchange))) { // If we have a holder, even if the connection was closed we now exclusivity was already requested so our client // may be assuming it still exists. host.connectionPool.connect(target, exchange, new ProxyCallback() { @Override - public void failed(HttpServerExchange exchange) { - UndertowLogger.PROXY_REQUEST_LOGGER.proxyFailedToConnectToBackend(exchange.getRequestURI(), host.uri); - callback.failed(exchange); - } - - @Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; @@ -222,6 +256,22 @@ } callback.completed(exchange, result); } + + @Override + public void queuedRequestFailed(HttpServerExchange exchange) { + callback.queuedRequestFailed(exchange); + } + + @Override + public void failed(HttpServerExchange exchange) { + UndertowLogger.PROXY_REQUEST_LOGGER.proxyFailedToConnectToBackend(exchange.getRequestURI(), host.uri); + callback.failed(exchange); + } + + @Override + public void couldNotResolveBackend(HttpServerExchange exchange) { + callback.couldNotResolveBackend(exchange); + } }, timeout, timeUnit, true); } else { host.connectionPool.connect(target, exchange, callback, timeout, timeUnit, false); @@ -250,7 +300,7 @@ return selected; } else if (available == FULL && full == null) { full = selected; - } else if (available == PROBLEM && problem == null) { + } else if ((available == PROBLEM || available == FULL_QUEUE) && problem == null) { problem = selected; } host = (host + 1) % hosts.length; @@ -286,16 +336,48 @@ return null; } - protected static final class Host { + protected final class Host extends ConnectionPoolErrorHandler.SimpleConnectionPoolErrorHandler implements ConnectionPoolManager { final ProxyConnectionPool connectionPool; final String jvmRoute; final URI uri; + final XnioSsl ssl; - private Host(ProxyConnectionPool connectionPool, String jvmRoute, URI uri) { - this.connectionPool = connectionPool; + private Host(String jvmRoute, InetSocketAddress bindAddress, URI uri, XnioSsl ssl, OptionMap options) { + this.connectionPool = new ProxyConnectionPool(this, bindAddress, uri, ssl, client, options); this.jvmRoute = jvmRoute; this.uri = uri; + this.ssl = ssl; } + + @Override + public int getProblemServerRetry() { + return problemServerRetry; + } + + @Override + public int getMaxConnections() { + return connectionsPerThread; + } + + @Override + public int getMaxCachedConnections() { + return connectionsPerThread; + } + + @Override + public int getSMaxConnections() { + return connectionsPerThread; + } + + @Override + public long getTtl() { + return -1; + } + + @Override + public int getMaxQueueSize() { + return maxQueueSize; + } } private static class ExclusiveConnectionHolder { Index: 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyCallback.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/proxy/Attic/ProxyCallback.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyCallback.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyCallback.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.proxy; import io.undertow.server.HttpServerExchange; @@ -11,6 +29,27 @@ void completed(final HttpServerExchange exchange, T result); - void failed(HttpServerExchange exchange); + /** + * Callback if establishing the connection to a backend server fails. + * + * @param exchange the http server exchange + */ + void failed(final HttpServerExchange exchange); + /** + * Callback if no backend server could be found. + * + * @param exchange the http server exchange + */ + void couldNotResolveBackend(final HttpServerExchange exchange); + + /** + * This is invoked when the target connection pool transitions to problem status. It will be called once for each queued request + * that has not yet been allocated a connection. The manager can redistribute these requests to other hosts, or can end the + * exchange with an error status. + * + * @param exchange The exchange + */ + void queuedRequestFailed(HttpServerExchange exchange); + } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyClient.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/proxy/Attic/ProxyClient.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyClient.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyClient.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.proxy; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyConnection.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/proxy/Attic/ProxyConnection.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyConnection.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyConnection.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.proxy; import io.undertow.client.ClientConnection; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyConnectionPool.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/proxy/Attic/ProxyConnectionPool.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyConnectionPool.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyConnectionPool.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,5 +1,32 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.proxy; +import java.io.Closeable; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.URI; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.TimeUnit; + import io.undertow.UndertowLogger; import io.undertow.UndertowMessages; import io.undertow.client.ClientCallback; @@ -13,15 +40,8 @@ import org.xnio.OptionMap; import org.xnio.XnioExecutor; import org.xnio.XnioIoThread; +import org.xnio.ssl.XnioSsl; -import java.io.Closeable; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayDeque; -import java.util.Deque; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.TimeUnit; - /** * A pool of connections to a target host. * @@ -31,56 +51,90 @@ * * @author Stuart Douglas */ -class ProxyConnectionPool implements Closeable { +public class ProxyConnectionPool implements Closeable { private final URI uri; + private final InetSocketAddress bindAddress; + + private final XnioSsl ssl; + private final UndertowClient client; private final ConnectionPoolManager connectionPoolManager; - /** - * flag that is set when a problem is detected with this host. It will be taken out of consideration - * until the flag is cleared. - *

    - * The exception to this is if all flags are marked as problems, in which case it will be tried anyway - */ - private volatile boolean problem; + private final OptionMap options; /** * Set to true when the connection pool is closed. */ private volatile boolean closed; - private final ConcurrentMap hostThreadData = new CopyOnWriteMap(); + private final int maxConnections; + private final int maxCachedConnections; + private final int sMaxConnections; + private final int maxRequestQueueSize; + private final long ttl; - public ProxyConnectionPool(ConnectionPoolManager connectionPoolManager, URI uri, UndertowClient client) { + private final ConcurrentMap hostThreadData = new CopyOnWriteMap<>(); + + public ProxyConnectionPool(ConnectionPoolManager connectionPoolManager, URI uri, UndertowClient client, OptionMap options) { + this(connectionPoolManager, uri, null, client, options); + } + + public ProxyConnectionPool(ConnectionPoolManager connectionPoolManager,InetSocketAddress bindAddress, URI uri, UndertowClient client, OptionMap options) { + this(connectionPoolManager, bindAddress, uri, null, client, options); + } + + public ProxyConnectionPool(ConnectionPoolManager connectionPoolManager, URI uri, XnioSsl ssl, UndertowClient client, OptionMap options) { + this(connectionPoolManager, null, uri, ssl, client, options); + } + + public ProxyConnectionPool(ConnectionPoolManager connectionPoolManager, InetSocketAddress bindAddress,URI uri, XnioSsl ssl, UndertowClient client, OptionMap options) { this.connectionPoolManager = connectionPoolManager; + this.maxConnections = Math.max(connectionPoolManager.getMaxConnections(), 1); + this.maxCachedConnections = Math.max(connectionPoolManager.getMaxCachedConnections(), 0); + this.sMaxConnections = Math.max(connectionPoolManager.getSMaxConnections(), 0); + this.maxRequestQueueSize = Math.max(connectionPoolManager.getMaxQueueSize(), 0); + this.ttl = connectionPoolManager.getTtl(); + this.bindAddress = bindAddress; this.uri = uri; + this.ssl = ssl; this.client = client; + this.options = options; } public URI getUri() { return uri; } + public InetSocketAddress getBindAddress() { + return bindAddress; + } + public void close() { this.closed = true; + for (HostThreadData data : hostThreadData.values()) { + final ConnectionHolder holder = data.availableConnections.poll(); + if (holder != null) { + IoUtils.safeClose(holder.clientConnection); + } + } } /** * Called when the IO thread has completed a successful request * - * @param connection The client connection + * @param connectionHolder The client connection holder */ - private void returnConnection(final ClientConnection connection) { + private void returnConnection(final ConnectionHolder connectionHolder) { HostThreadData hostData = getData(); if (closed) { //the host has been closed - IoUtils.safeClose(connection); - ClientConnection con = hostData.availableConnections.poll(); + IoUtils.safeClose(connectionHolder.clientConnection); + ConnectionHolder con = hostData.availableConnections.poll(); while (con != null) { - IoUtils.safeClose(con); + IoUtils.safeClose(con.clientConnection); con = hostData.availableConnections.poll(); } redistributeQueued(hostData); @@ -90,6 +144,7 @@ //only do something if the connection is open. If it is closed then //the close setter will handle creating a new connection and decrementing //the connection count + final ClientConnection connection = connectionHolder.clientConnection; if (connection.isOpen() && !connection.isUpgraded()) { CallbackHolder callback = hostData.awaitingConnections.poll(); while (callback != null && callback.isCancelled()) { @@ -100,24 +155,38 @@ callback.getTimeoutKey().remove(); } // Anything waiting for a connection is not expecting exclusivity. - connectionReady(connection, callback.getCallback(), callback.getExchange(), false); + connectionReady(connectionHolder, callback.getCallback(), callback.getExchange(), false); } else { - hostData.availableConnections.add(connection); + final int cachedConnectionCount = hostData.availableConnections.size(); + if (cachedConnectionCount >= maxCachedConnections) { + // Close the longest idle connection instead of the current one + final ConnectionHolder holder = hostData.availableConnections.poll(); + if (holder != null) { + IoUtils.safeClose(holder.clientConnection); + } + } + hostData.availableConnections.add(connectionHolder); + // If the soft max and ttl are configured + if (sMaxConnections >= 0 && ttl > 0) { + final long currentTime = System.currentTimeMillis(); + connectionHolder.timeout = currentTime + ttl; + timeoutConnections(currentTime, hostData); + } } } else if (connection.isOpen() && connection.isUpgraded()) { //we treat upgraded connections as closed //as we do not want the connection pool filled with upgraded connections //if the connection is actually closed the close setter will handle it connection.getCloseSetter().set(null); - handleClosedConnection(hostData, connection); + handleClosedConnection(hostData, connectionHolder); } } - private void handleClosedConnection(HostThreadData hostData, final ClientConnection connection) { + private void handleClosedConnection(HostThreadData hostData, final ConnectionHolder connection) { int connections = --hostData.connections; hostData.availableConnections.remove(connection); - if (connectionPoolManager.canCreateConnection(connections, this)) { + if (connections < maxConnections) { CallbackHolder task = hostData.awaitingConnections.poll(); while (task != null && task.isCancelled()) { task = hostData.awaitingConnections.poll(); @@ -129,35 +198,37 @@ } private void openConnection(final HttpServerExchange exchange, final ProxyCallback callback, final HostThreadData data, final boolean exclusive) { - if (exclusive == false) { + if (!exclusive) { data.connections++; } client.connect(new ClientCallback() { @Override public void completed(final ClientConnection result) { - problem = false; - if (exclusive == false) { + final ConnectionHolder connectionHolder = new ConnectionHolder(result); + if (!exclusive) { result.getCloseSetter().set(new ChannelListener() { @Override public void handleEvent(ClientConnection channel) { - handleClosedConnection(data, channel); + handleClosedConnection(data, connectionHolder); } }); } - connectionReady(result, callback, exchange, exclusive); + connectionReady(connectionHolder, callback, exchange, exclusive); } @Override public void failed(IOException e) { - if (exclusive == false) { + if (!exclusive) { data.connections--; } - problem = true; - redistributeQueued(getData()); - scheduleFailedHostRetry(exchange); + UndertowLogger.REQUEST_LOGGER.debug("Failed to connect", e); + if (!connectionPoolManager.handleError()) { + redistributeQueued(getData()); + scheduleFailedHostRetry(exchange); + } callback.failed(exchange); } - }, getUri(), exchange.getIoThread(), exchange.getConnection().getBufferPool(), OptionMap.EMPTY); + }, bindAddress, getUri(), exchange.getIoThread(), ssl, exchange.getConnection().getBufferPool(), options); } private void redistributeQueued(HostThreadData hostData) { @@ -171,42 +242,44 @@ if (callback.getExpireTime() > 0 && callback.getExpireTime() < time) { callback.getCallback().failed(callback.getExchange()); } else { - connectionPoolManager.queuedConnectionFailed(callback.getProxyTarget(), callback.getExchange(), callback.getCallback(), callback.getExpireTime() > 0 ? time - callback.getExpireTime() : -1); - callback.getCallback().failed(callback.getExchange()); + callback.getCallback().queuedRequestFailed(callback.getExchange()); } } callback = hostData.awaitingConnections.poll(); } } - private void connectionReady(final ClientConnection result, final ProxyCallback callback, final HttpServerExchange exchange, final boolean exclusive) { + private void connectionReady(final ConnectionHolder result, final ProxyCallback callback, final HttpServerExchange exchange, final boolean exclusive) { exchange.addExchangeCompleteListener(new ExchangeCompletionListener() { @Override public void exchangeEvent(HttpServerExchange exchange, NextListener nextListener) { - if (exclusive == false) { + if (!exclusive) { returnConnection(result); } nextListener.proceed(); } }); - callback.completed(exchange, new ProxyConnection(result, uri.getPath() == null ? "/" : uri.getPath())); + callback.completed(exchange, new ProxyConnection(result.clientConnection, uri.getPath() == null ? "/" : uri.getPath())); } public AvailabilityType available() { if (closed) { return AvailabilityType.CLOSED; } - if (problem) { + if (!connectionPoolManager.isAvailable()) { return AvailabilityType.PROBLEM; } HostThreadData data = getData(); - if (connectionPoolManager.canCreateConnection(data.connections, this)) { + if (data.connections < maxConnections) { return AvailabilityType.AVAILABLE; } if (!data.availableConnections.isEmpty()) { return AvailabilityType.AVAILABLE; } + if (data.awaitingConnections.size() >= maxRequestQueueSize) { + return AvailabilityType.FULL_QUEUE; + } return AvailabilityType.FULL; } @@ -216,30 +289,93 @@ * @param exchange The server exchange */ private void scheduleFailedHostRetry(final HttpServerExchange exchange) { - exchange.getIoThread().executeAfter(new Runnable() { - @Override - public void run() { - if (closed) { - return; + final int retry = connectionPoolManager.getProblemServerRetry(); + // only schedule a retry task if the node is not available + if (retry > 0 && !connectionPoolManager.isAvailable()) { + exchange.getIoThread().executeAfter(new Runnable() { + @Override + public void run() { + if (closed) { + return; + } + + UndertowLogger.PROXY_REQUEST_LOGGER.debugf("Attempting to reconnect to failed host %s", getUri()); + client.connect(new ClientCallback() { + @Override + public void completed(ClientConnection result) { + UndertowLogger.PROXY_REQUEST_LOGGER.debugf("Connected to previously failed host %s, returning to service", getUri()); + if (connectionPoolManager.clearError()) { + // In case the node is available now, return the connection + final ConnectionHolder connectionHolder = new ConnectionHolder(result); + final HostThreadData data = getData(); + result.getCloseSetter().set(new ChannelListener() { + @Override + public void handleEvent(ClientConnection channel) { + handleClosedConnection(data, connectionHolder); + } + }); + data.connections++; + returnConnection(connectionHolder); + } else { + // Otherwise reschedule the retry task + scheduleFailedHostRetry(exchange); + } + } + + @Override + public void failed(IOException e) { + UndertowLogger.PROXY_REQUEST_LOGGER.debugf("Failed to reconnect to failed host %s", getUri()); + connectionPoolManager.handleError(); + scheduleFailedHostRetry(exchange); + } + }, bindAddress, getUri(), exchange.getIoThread(), ssl, exchange.getConnection().getBufferPool(), options); } + }, retry, TimeUnit.SECONDS); + } + } - UndertowLogger.PROXY_REQUEST_LOGGER.debugf("Attempting to reconnect to failed host %s", getUri()); - client.connect(new ClientCallback() { - @Override - public void completed(ClientConnection result) { - UndertowLogger.PROXY_REQUEST_LOGGER.debugf("Connected to previously failed host %s, returning to service", getUri()); - problem = false; - returnConnection(result); + /** + * Timeout idle connections which are above the soft max cached connections limit. + * + * @param currentTime the current time + * @param data the local host thread data + */ + private void timeoutConnections(final long currentTime, final HostThreadData data) { + int idleConnections = data.availableConnections.size(); + for (;;) { + ConnectionHolder holder; + if (idleConnections > 0 && idleConnections >= sMaxConnections && (holder = data.availableConnections.peek()) != null) { + if (!holder.clientConnection.isOpen()) { + // Already closed connections decrease the available connections + idleConnections--; + } else if (currentTime >= holder.timeout) { + // If the timeout is reached already, just close + holder = data.availableConnections.poll(); + IoUtils.safeClose(holder.clientConnection); + idleConnections--; + } else { + // If the next run is after the connection timeout don't reschedule the task + if (data.timeoutKey == null || data.nextTimeout > holder.timeout) { + if (data.timeoutKey != null) { + data.timeoutKey.remove(); + data.timeoutKey = null; + } + // Schedule a timeout task + final long remaining = holder.timeout - currentTime + 1; + data.nextTimeout = holder.timeout; + data.timeoutKey = holder.clientConnection.getIoThread().executeAfter(data.timeoutTask, remaining, TimeUnit.MILLISECONDS); } - - @Override - public void failed(IOException e) { - UndertowLogger.PROXY_REQUEST_LOGGER.debugf("Failed to reconnect to failed host %s", getUri()); - scheduleFailedHostRetry(exchange); - } - }, getUri(), exchange.getIoThread(), exchange.getConnection().getBufferPool(), OptionMap.EMPTY); + return; + } + } else { + // If we are below the soft limit, just cancel the task + if (data.timeoutKey != null) { + data.timeoutKey.remove(); + data.timeoutKey = null; + } + return; } - }, connectionPoolManager.getProblemServerRetry(), TimeUnit.SECONDS); + } } /** @@ -270,18 +406,23 @@ */ public void connect(ProxyClient.ProxyTarget proxyTarget, HttpServerExchange exchange, ProxyCallback callback, final long timeout, final TimeUnit timeUnit, boolean exclusive) { HostThreadData data = getData(); - ClientConnection conn = data.availableConnections.poll(); - while (conn != null && !conn.isOpen()) { - conn = data.availableConnections.poll(); + ConnectionHolder connectionHolder = data.availableConnections.poll(); + while (connectionHolder != null && !connectionHolder.clientConnection.isOpen()) { + connectionHolder = data.availableConnections.poll(); } - if (conn != null) { + if (connectionHolder != null) { if (exclusive) { data.connections--; } - connectionReady(conn, callback, exchange, exclusive); - } else if (exclusive || connectionPoolManager.canCreateConnection(data.connections, this)) { + connectionReady(connectionHolder, callback, exchange, exclusive); + } else if (exclusive || data.connections < maxConnections) { openConnection(exchange, callback, data, exclusive); } else { + // Reject the request directly if we reached the max request queue size + if (data.awaitingConnections.size() >= maxRequestQueueSize) { + callback.queuedRequestFailed(exchange); + return; + } CallbackHolder holder; if (timeout > 0) { long time = System.currentTimeMillis(); @@ -294,15 +435,36 @@ } } - private static final class HostThreadData { + private final class HostThreadData { int connections = 0; - final Deque availableConnections = new ArrayDeque(); - final Deque awaitingConnections = new ArrayDeque(); + XnioIoThread.Key timeoutKey; + long nextTimeout; + final Deque availableConnections = new ArrayDeque<>(); + final Deque awaitingConnections = new ArrayDeque<>(); + final Runnable timeoutTask = new Runnable() { + @Override + public void run() { + final long currentTime = System.currentTimeMillis(); + timeoutConnections(currentTime, HostThreadData.this); + } + }; + } + private static final class ConnectionHolder { + private long timeout; + private final ClientConnection clientConnection; + + private ConnectionHolder(ClientConnection clientConnection) { + this.clientConnection = clientConnection; + } + + } + + private static final class CallbackHolder implements Runnable { final ProxyClient.ProxyTarget proxyTarget; final ProxyCallback callback; @@ -353,7 +515,7 @@ } } - enum AvailabilityType { + public enum AvailabilityType { /** * The host is read to accept requests */ @@ -368,6 +530,10 @@ */ FULL, /** + * All connections are in use and the queue is full. Requests will be rejected. + */ + FULL_QUEUE, + /** * The host is probably down, only try as a last resort */ PROBLEM, @@ -376,4 +542,5 @@ */ CLOSED; } + } Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyConnectionPoolConfig.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/proxy/Attic/ProxyHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyHandler.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/ProxyHandler.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,15 +9,34 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.proxy; +import javax.net.ssl.SSLPeerUnverifiedException; +import javax.security.cert.CertificateEncodingException; +import javax.security.cert.X509Certificate; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URLEncoder; +import java.nio.channels.Channel; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Deque; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + import io.undertow.UndertowLogger; import io.undertow.attribute.ExchangeAttribute; import io.undertow.attribute.ExchangeAttributes; @@ -31,11 +50,13 @@ import io.undertow.io.IoCallback; import io.undertow.io.Sender; import io.undertow.server.ExchangeCompletionListener; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.server.HttpUpgradeListener; import io.undertow.server.RenegotiationRequiredException; import io.undertow.server.SSLSessionInfo; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.server.protocol.http.HttpAttachments; import io.undertow.server.protocol.http.HttpContinue; import io.undertow.util.Attachable; @@ -56,19 +77,6 @@ import org.xnio.XnioExecutor; import org.xnio.channels.StreamSinkChannel; -import javax.net.ssl.SSLPeerUnverifiedException; -import javax.security.cert.CertificateEncodingException; -import javax.security.cert.X509Certificate; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import java.net.URLEncoder; -import java.nio.channels.Channel; -import java.util.Deque; -import java.util.Map; -import java.util.concurrent.TimeUnit; - /** * An HTTP handler which proxies content to a remote server. *

    @@ -91,26 +99,39 @@ private static final AttachmentKey EXCHANGE = AttachmentKey.create(HttpServerExchange.class); private static final AttachmentKey TIMEOUT_KEY = AttachmentKey.create(XnioExecutor.Key.class); - private final ProxyClientHandler proxyClientHandler = new ProxyClientHandler(); - /** * Map of additional headers to add to the request. */ - private final Map requestHeaders = new CopyOnWriteMap(); + private final Map requestHeaders = new CopyOnWriteMap<>(); private final HttpHandler next; + private final boolean rewriteHostHeader; + private final boolean reuseXForwarded; + public ProxyHandler(ProxyClient proxyClient, int maxRequestTime, HttpHandler next) { + this(proxyClient, maxRequestTime, next, false, false); + } + + /** + * + * @param proxyClient the client to use to make the proxy call + * @param maxRequestTime the maximum amount of time to allow the request to be processed + * @param next the next handler in line + * @param rewriteHostHeader should the HOST header be rewritten to use the target host of the call. + * @param reuseXForwarded should any existing X-Forwarded-For header be used or should it be overwritten. + */ + public ProxyHandler(ProxyClient proxyClient, int maxRequestTime, HttpHandler next, boolean rewriteHostHeader, boolean reuseXForwarded) { this.proxyClient = proxyClient; this.maxRequestTime = maxRequestTime; this.next = next; + this.rewriteHostHeader = rewriteHostHeader; + this.reuseXForwarded = reuseXForwarded; } public ProxyHandler(ProxyClient proxyClient, HttpHandler next) { - this.proxyClient = proxyClient; - this.next = next; - this.maxRequestTime = -1; + this(proxyClient, -1, next); } public void handleRequest(final HttpServerExchange exchange) throws Exception { @@ -120,22 +141,14 @@ next.handleRequest(exchange); return; } - if (maxRequestTime > 0) { + final int maxRetryAttempts = 0; // TODO make this configurable, or just take from the error policy? + final long timeout = maxRequestTime > 0 ? System.currentTimeMillis() + maxRequestTime : 0; + final ProxyClientHandler clientHandler = new ProxyClientHandler(exchange, target, timeout, maxRetryAttempts); + if (timeout > 0) { final XnioExecutor.Key key = exchange.getIoThread().executeAfter(new Runnable() { @Override public void run() { - - UndertowLogger.REQUEST_LOGGER.timingOutRequest(exchange.getRequestURI()); - - ProxyConnection connectionAttachment = exchange.getAttachment(CONNECTION); - if (connectionAttachment != null) { - //we rely on the close listener to end the exchange - ClientConnection clientConnection = connectionAttachment.getConnection(); - IoUtils.safeClose(clientConnection); - } else { - exchange.setResponseCode(503); - exchange.endExchange(); - } + clientHandler.cancel(exchange); } }, maxRequestTime, TimeUnit.MILLISECONDS); exchange.putAttachment(TIMEOUT_KEY, key); @@ -147,13 +160,7 @@ } }); } - exchange.dispatch(SameThreadExecutor.INSTANCE, new Runnable() { - @Override - public void run() { - log.debugf("Proxying request %s, opening connection", exchange.getRequestURL()); - proxyClient.getConnection(target, exchange, proxyClientHandler, -1, TimeUnit.MILLISECONDS); - } - }); + exchange.dispatch(exchange.isInIoThread() ? SameThreadExecutor.INSTANCE : exchange.getIoThread(), clientHandler); } /** @@ -173,8 +180,8 @@ * Adds a request header to the outgoing request. If the header resolves to null or an empty string * it will not be added, however any existing header with the same name will be removed. * - * @param header The header name - * @param value The header value attribute. + * @param header The header name + * @param value The header value attribute. * @return this */ public ProxyHandler addRequestHeader(final HttpString header, final String value) { @@ -215,7 +222,10 @@ HeaderValues values; while (f != -1L) { values = from.fiCurrent(f); - to.putAll(values.getHeaderName(), values); + if(!to.contains(values.getHeaderName())) { + //don't over write existing headers, normally the map will be empty, if it is not we assume it is not for a reason + to.putAll(values.getHeaderName(), values); + } f = from.fiNextNonEmpty(f); } } @@ -224,35 +234,101 @@ return proxyClient; } - private final class ProxyClientHandler implements ProxyCallback { + private final class ProxyClientHandler implements ProxyCallback, Runnable { + private int tries; + + private final long timeout; + private final int maxRetryAttempts; + private final HttpServerExchange exchange; + private ProxyClient.ProxyTarget target; + + ProxyClientHandler(HttpServerExchange exchange, ProxyClient.ProxyTarget target, long timeout, int maxRetryAttempts) { + this.exchange = exchange; + this.timeout = timeout; + this.maxRetryAttempts = maxRetryAttempts; + this.target = target; + } + @Override - public void completed(HttpServerExchange exchange, ProxyConnection result) { - exchange.putAttachment(CONNECTION, result); - exchange.dispatch(SameThreadExecutor.INSTANCE, new ProxyAction(result, exchange, requestHeaders)); + public void run() { + proxyClient.getConnection(target, exchange, this, -1, TimeUnit.MILLISECONDS); } @Override - public void failed(HttpServerExchange exchange) { - UndertowLogger.PROXY_REQUEST_LOGGER.proxyRequestFailedToResolveBackend(exchange.getRequestURI()); - if (!exchange.isResponseStarted()) { + public void completed(final HttpServerExchange exchange, final ProxyConnection connection) { + exchange.putAttachment(CONNECTION, connection); + exchange.dispatch(SameThreadExecutor.INSTANCE, new ProxyAction(connection, exchange, requestHeaders, rewriteHostHeader, reuseXForwarded)); + } + + @Override + public void failed(final HttpServerExchange exchange) { + final long time = System.currentTimeMillis(); + if (tries++ < maxRetryAttempts) { + if (timeout > 0 && time > timeout) { + cancel(exchange); + } else { + target = proxyClient.findTarget(exchange); + if (target != null) { + final long remaining = timeout > 0 ? timeout - time : -1; + proxyClient.getConnection(target, exchange, this, remaining, TimeUnit.MILLISECONDS); + } else { + couldNotResolveBackend(exchange); // The context was registered when we started, so return 503 + } + } + } else { + couldNotResolveBackend(exchange); + } + } + + @Override + public void queuedRequestFailed(HttpServerExchange exchange) { + failed(exchange); + } + + @Override + public void couldNotResolveBackend(HttpServerExchange exchange) { + if (exchange.isResponseStarted()) { + IoUtils.safeClose(exchange.getConnection()); + } else { exchange.setResponseCode(503); exchange.endExchange(); + } + } + + void cancel(final HttpServerExchange exchange) { + final ProxyConnection connectionAttachment = exchange.getAttachment(CONNECTION); + if (connectionAttachment != null) { + ClientConnection clientConnection = connectionAttachment.getConnection(); + UndertowLogger.REQUEST_LOGGER.timingOutRequest(clientConnection.getPeerAddress() + "" + exchange.getRequestURI()); + IoUtils.safeClose(clientConnection); } else { + UndertowLogger.REQUEST_LOGGER.timingOutRequest(exchange.getRequestURI()); + } + if (exchange.isResponseStarted()) { IoUtils.safeClose(exchange.getConnection()); + } else { + exchange.setResponseCode(503); + exchange.endExchange(); } } + } private static class ProxyAction implements Runnable { private final ProxyConnection clientConnection; private final HttpServerExchange exchange; private final Map requestHeaders; + private final boolean rewriteHostHeader; + private final boolean reuseXForwarded; - public ProxyAction(final ProxyConnection clientConnection, final HttpServerExchange exchange, Map requestHeaders) { + public ProxyAction(final ProxyConnection clientConnection, final HttpServerExchange exchange, Map requestHeaders, + boolean rewriteHostHeader, boolean reuseXForwarded) { this.clientConnection = clientConnection; this.exchange = exchange; this.requestHeaders = requestHeaders; + this.rewriteHostHeader = rewriteHostHeader; + this.reuseXForwarded = reuseXForwarded; } @Override @@ -306,7 +382,7 @@ final HeaderMap outboundRequestHeaders = request.getRequestHeaders(); copyHeaders(outboundRequestHeaders, inboundRequestHeaders); - if(!exchange.isPersistent()) { + if (!exchange.isPersistent()) { //just because the client side is non-persistent //we don't want to close the connection to the backend outboundRequestHeaders.put(Headers.CONNECTION, "keep-alive"); @@ -320,18 +396,43 @@ outboundRequestHeaders.put(entry.getKey(), headerValue.replace('\n', ' ')); } } - SocketAddress address = exchange.getConnection().getPeerAddress(); - if (address instanceof InetSocketAddress) { - outboundRequestHeaders.put(Headers.X_FORWARDED_FOR, ((InetSocketAddress) address).getHostString()); - } else { - outboundRequestHeaders.put(Headers.X_FORWARDED_FOR, "localhost"); - } - outboundRequestHeaders.put(Headers.X_FORWARDED_PROTO, exchange.getRequestScheme()); - if (exchange.getRequestScheme().equals("https")) { - request.putAttachment(ProxiedRequestAttachments.IS_SSL, true); + final SocketAddress address = exchange.getConnection().getPeerAddress(); + final String remoteHost = (address != null && address instanceof InetSocketAddress) ? ((InetSocketAddress) address).getHostString() : "localhost"; + request.putAttachment(ProxiedRequestAttachments.REMOTE_HOST, remoteHost); + + if (reuseXForwarded && request.getRequestHeaders().contains(Headers.X_FORWARDED_FOR)) { + // We have an existing header so we shall simply append the host to the existing list + final String current = request.getRequestHeaders().getFirst(Headers.X_FORWARDED_FOR); + if (current == null || current.isEmpty()) { + // It was empty so just add it + request.getRequestHeaders().put(Headers.X_FORWARDED_FOR, remoteHost); + } + else { + // Add the new entry and reset the existing header + request.getRequestHeaders().put(Headers.X_FORWARDED_FOR, current + "," + remoteHost); + } } + else { + // No existing header or not allowed to reuse the header so set it here + request.getRequestHeaders().put(Headers.X_FORWARDED_FOR, remoteHost); + } + // Set the protocol header and attachment + final String proto = exchange.getRequestScheme().equals("https") ? "https" : "http"; + request.getRequestHeaders().put(Headers.X_FORWARDED_PROTO, proto); + request.putAttachment(ProxiedRequestAttachments.IS_SSL, proto.equals("https")); + + // Set the server name + final String hostName = exchange.getHostName(); + request.getRequestHeaders().put(Headers.X_FORWARDED_HOST, hostName); + request.putAttachment(ProxiedRequestAttachments.SERVER_NAME, hostName); + + // Set the port + int port = exchange.getConnection().getLocalAddress(InetSocketAddress.class).getPort(); + request.getRequestHeaders().put(Headers.X_FORWARDED_PORT, port); + request.putAttachment(ProxiedRequestAttachments.SERVER_PORT, port); + SSLSessionInfo sslSessionInfo = exchange.getConnection().getSslSessionInfo(); if (sslSessionInfo != null) { X509Certificate[] peerCertificates; @@ -351,14 +452,20 @@ request.putAttachment(ProxiedRequestAttachments.SSL_SESSION_ID, sslSessionInfo.getSessionId()); } + if(rewriteHostHeader) { + InetSocketAddress targetAddress = clientConnection.getConnection().getPeerAddress(InetSocketAddress.class); + request.getRequestHeaders().put(Headers.HOST, targetAddress.getHostString() + ":" + targetAddress.getPort()); + request.getRequestHeaders().put(Headers.X_FORWARDED_HOST, exchange.getRequestHeaders().getFirst(Headers.HOST)); + } clientConnection.getConnection().sendRequest(request, new ClientCallback() { @Override - public void completed(ClientExchange result) { + public void completed(final ClientExchange result) { result.putAttachment(EXCHANGE, exchange); - if (HttpContinue.requiresContinueResponse(exchange)) { + boolean requiresContinueResponse = HttpContinue.requiresContinueResponse(exchange); + if (requiresContinueResponse) { result.setContinueHandler(new ContinueNotification() { @Override public void handleContinue(final ClientExchange clientExchange) { @@ -375,11 +482,30 @@ }); } }); + } result.setResponseListener(new ResponseCallback(exchange)); - IoExceptionHandler handler = new IoExceptionHandler(exchange, clientConnection.getConnection()); + final IoExceptionHandler handler = new IoExceptionHandler(exchange, clientConnection.getConnection()); + if(requiresContinueResponse) { + try { + if(!result.getRequestChannel().flush()) { + result.getRequestChannel().getWriteSetter().set(ChannelListeners.flushingChannelListener(new ChannelListener() { + @Override + public void handleEvent(StreamSinkChannel channel) { + ChannelListeners.initiateTransfer(Long.MAX_VALUE, exchange.getRequestChannel(), result.getRequestChannel(), ChannelListeners.closingChannelListener(), new HTTPTrailerChannelListener(exchange, result), handler, handler, exchange.getConnection().getBufferPool()); + + } + }, handler)); + result.getRequestChannel().resumeWrites(); + return; + } + } catch (IOException e) { + handler.handleException(result.getRequestChannel(), e); + } + } ChannelListeners.initiateTransfer(Long.MAX_VALUE, exchange.getRequestChannel(), result.getRequestChannel(), ChannelListeners.closingChannelListener(), new HTTPTrailerChannelListener(exchange, result), handler, handler, exchange.getConnection().getBufferPool()); + } @Override @@ -500,6 +626,7 @@ @Override public void handleException(Channel channel, IOException exception) { + IoUtils.safeClose(channel); if (exchange.isResponseStarted()) { IoUtils.safeClose(clientConnection); UndertowLogger.REQUEST_IO_LOGGER.debug("Exception reading from target server", exception); @@ -574,4 +701,62 @@ sb.append(encoded); return sb.toString(); } + + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "reverse-proxy"; + } + + @Override + public Map> parameters() { + return Collections.>singletonMap("hosts", String[].class); + } + + @Override + public Set requiredParameters() { + return Collections.singleton("hosts"); + } + + @Override + public String defaultParameter() { + return "hosts"; + } + + @Override + public HandlerWrapper build(Map config) { + String[] hosts = (String[]) config.get("hosts"); + List uris = new ArrayList<>(); + for(String host : hosts) { + try { + uris.add(new URI(host)); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + return new Wrapper(uris); + } + + } + + private static class Wrapper implements HandlerWrapper { + + private final List uris; + + private Wrapper(List uris) { + this.uris = uris; + } + + @Override + public HttpHandler wrap(HttpHandler handler) { + + LoadBalancingProxyClient loadBalancingProxyClient = new LoadBalancingProxyClient(); + for(URI url : uris) { + loadBalancingProxyClient.addHost(url); + } + return new ProxyHandler(loadBalancingProxyClient, handler); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/SimpleProxyClientProvider.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/proxy/Attic/SimpleProxyClientProvider.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/SimpleProxyClientProvider.java 8 Sep 2014 10:52:15 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/proxy/SimpleProxyClientProvider.java 25 Nov 2014 10:46:52 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.proxy; import io.undertow.client.ClientCallback; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/CachedResource.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/CachedResource.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/CachedResource.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/CachedResource.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.resource; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/CachingResourceManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/CachingResourceManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/CachingResourceManager.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/CachingResourceManager.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.resource; @@ -57,7 +57,7 @@ this.maxFileSize = maxFileSize; this.underlyingResourceManager = underlyingResourceManager; this.dataCache = dataCache; - this.cache = new LRUCache(metadataCacheSize, maxAge); + this.cache = new LRUCache<>(metadataCacheSize, maxAge); this.maxAge = maxAge; if(underlyingResourceManager.isResourceChangeListenerSupported()) { try { Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ClassPathResourceManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/ClassPathResourceManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ClassPathResourceManager.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ClassPathResourceManager.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.resource; import io.undertow.UndertowMessages; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/DirectoryUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/DirectoryUtils.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/DirectoryUtils.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/DirectoryUtils.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.resource; import java.io.IOException; @@ -63,20 +81,26 @@ int state = 0; String parent = null; - for (int i = path.length() - 1; i >= 0; i--) { - if (state == 1) { - if (path.charAt(i) == '/') { - state = 2; + if(path.length() > 1) { + for (int i = path.length() - 1; i >= 0; i--) { + if (state == 1) { + if (path.charAt(i) == '/') { + state = 2; + } + } else if (path.charAt(i) != '/') { + if (state == 2) { + parent = path.substring(0, i + 1); + break; + } + state = 1; } - } else if (path.charAt(i) != '/') { - if (state == 2) { - parent = path.substring(0, i + 1); - break; - } - state = 1; } + if(parent == null) { + parent = "/"; + } } + SimpleDateFormat format = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss"); int i = 0; if (parent != null) { Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/FileResource.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/FileResource.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/FileResource.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/FileResource.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.resource; @@ -93,7 +93,7 @@ @Override public List list() { - final List resources = new ArrayList(); + final List resources = new ArrayList<>(); for (String child : file.list()) { resources.add(new FileResource(new File(this.file, child), manager, path)); } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/FileResourceManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/FileResourceManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/FileResourceManager.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/FileResourceManager.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,20 +9,24 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.handlers.resource; import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.TreeSet; import io.undertow.UndertowLogger; import io.undertow.UndertowMessages; @@ -37,7 +41,7 @@ */ public class FileResourceManager implements ResourceManager { - private final List listeners = new ArrayList(); + private final List listeners = new ArrayList<>(); private FileSystemWatcher fileSystemWatcher; @@ -48,7 +52,35 @@ */ private final long transferMinSize; + /** + * Check to validate caseSensitive issues for specific case-insensitive FS. + * @see io.undertow.server.handlers.resource.FileResourceManager#isFileSameCase(java.io.File) + */ + private final boolean caseSensitive; + + /** + * Check to allow follow symbolic links + */ + private final boolean followLinks; + + /** + * Used if followLinks == true. Set of paths valid to follow symbolic links + */ + private final TreeSet safePaths = new TreeSet(); + public FileResourceManager(final File base, long transferMinSize) { + this(base, transferMinSize, true, false, null); + } + + public FileResourceManager(final File base, long transferMinSize, boolean caseSensitive) { + this(base, transferMinSize, caseSensitive, false, null); + } + + public FileResourceManager(final File base, long transferMinSize, boolean followLinks, final String... safePaths) { + this(base, transferMinSize, true, followLinks, safePaths); + } + + public FileResourceManager(final File base, long transferMinSize, boolean caseSensitive, boolean followLinks, final String... safePaths) { if (base == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("base"); } @@ -58,7 +90,19 @@ } this.base = basePath; this.transferMinSize = transferMinSize; - + this.caseSensitive = caseSensitive; + this.followLinks = followLinks; + if (this.followLinks) { + if (safePaths == null) { + throw UndertowMessages.MESSAGES.argumentCannotBeNull("safePaths"); + } + for (final String safePath : safePaths) { + if (safePath == null) { + throw UndertowMessages.MESSAGES.argumentCannotBeNull("safePaths"); + } + } + this.safePaths.addAll(Arrays.asList(safePaths)); + } } public File getBase() { @@ -88,11 +132,13 @@ try { File file = new File(base, path); if (file.exists()) { - //security check for case insensitive file systems - //we make sure the case of the filename matches the case of the request - //TODO: we should be able to avoid this if we can tell a FS is case sensitive - if (file.getCanonicalFile().getName().equals(file.getName())) { - return new FileResource(file, this, path); + boolean isSymlinkPath = isSymlinkPath(base, file); + if (isSymlinkPath) { + if (this.followLinks && isSymlinkSafe(file)) { + return getFileResource(file, path); + } + } else { + return getFileResource(file, path); } } return null; @@ -116,7 +162,7 @@ @Override public void handleChanges(Collection changes) { synchronized (FileResourceManager.this) { - final List events = new ArrayList(); + final List events = new ArrayList<>(); for (FileChangeEvent change : changes) { if (change.getFile().getAbsolutePath().startsWith(base)) { String path = change.getFile().getAbsolutePath().substring(base.length()); @@ -148,4 +194,91 @@ fileSystemWatcher.close(); } } + + /** + * Returns true is some element of path inside base path is a symlink. + */ + private boolean isSymlinkPath(final String base, final File file) throws IOException { + Path path = file.toPath(); + int nameCount = path.getNameCount(); + File root = new File(base); + Path rootPath = root.toPath(); + int rootCount = rootPath.getNameCount(); + if (nameCount > rootCount) { + File f = root; + for (int i= rootCount; i 0) { + if (safePath.charAt(0) == '/') { + /* + * Absolute path + */ + return safePath.length() > 0 && + canonicalPath.length() >= safePath.length() && + canonicalPath.startsWith(safePath); + } else { + /* + * In relative path we build the path appending to base + */ + String absSafePath = base + '/' + safePath; + File absSafePathFile = new File(absSafePath); + String canonicalSafePath = absSafePathFile.getCanonicalPath(); + return canonicalSafePath.length() > 0 && + canonicalPath.length() >= canonicalSafePath.length() && + canonicalPath.startsWith(canonicalSafePath); + + } + } + } + return false; + } + + /** + * Apply security check for case insensitive file systems. + */ + private FileResource getFileResource(final File file, final String path) throws IOException { + if (this.caseSensitive) { + if (isFileSameCase(file)) { + return new FileResource(file, this, path); + } else { + return null; + } + } else { + return new FileResource(file, this, path); + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/Resource.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/Resource.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/Resource.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/Resource.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.resource; import java.io.File; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceChangeEvent.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/ResourceChangeEvent.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceChangeEvent.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceChangeEvent.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.resource; /** Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceChangeListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/ResourceChangeListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceChangeListener.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceChangeListener.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.resource; import java.util.Collection; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/ResourceHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceHandler.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceHandler.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,20 +1,46 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.resource; +import java.io.File; import java.io.IOException; import java.util.Arrays; +import java.util.Collections; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import io.undertow.UndertowLogger; import io.undertow.io.IoCallback; import io.undertow.predicate.Predicate; import io.undertow.predicate.Predicates; +import io.undertow.server.HandlerWrapper; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; +import io.undertow.server.handlers.builder.HandlerBuilder; import io.undertow.server.handlers.cache.ResponseCache; import io.undertow.server.handlers.encoding.ContentEncodedResource; import io.undertow.server.handlers.encoding.ContentEncodedResourceManager; +import io.undertow.util.CanonicalPathUtils; import io.undertow.util.DateUtils; import io.undertow.util.ETag; import io.undertow.util.ETagUtils; @@ -29,12 +55,18 @@ */ public class ResourceHandler implements HttpHandler { - private final List welcomeFiles = new CopyOnWriteArrayList(new String[]{"index.html", "index.htm", "default.html", "default.htm"}); + private final List welcomeFiles = new CopyOnWriteArrayList<>(new String[]{"index.html", "index.htm", "default.html", "default.htm"}); /** * If directory listing is enabled. */ private volatile boolean directoryListingEnabled = false; + /** + * If the canonical version of paths should be passed into the resource manager. + */ + private volatile boolean canonicalizePaths = true; + + /** * The mime mappings that are used to determine the content type. */ private volatile MimeMappings mimeMappings = MimeMappings.DEFAULT; @@ -128,7 +160,11 @@ public void run() { Resource resource = null; try { - resource = resourceManager.getResource(exchange.getRelativePath()); + if(File.separatorChar == '/' || !exchange.getRelativePath().contains(File.separator)) { + //we don't process resources that contain the sperator character if this is not / + //this prevents attacks where people use windows path seperators in file URLS's + resource = resourceManager.getResource(canonicalize(exchange.getRelativePath())); + } } catch (IOException e) { UndertowLogger.REQUEST_IO_LOGGER.ioException(e); exchange.setResponseCode(500); @@ -186,10 +222,13 @@ //todo: handle range requests //we are going to proceed. Set the appropriate headers final String contentType = resource.getContentType(mimeMappings); - if (contentType != null) { - exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, contentType); - } else { - exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/octet-stream"); + + if(!exchange.getResponseHeaders().contains(Headers.CONTENT_TYPE)) { + if (contentType != null) { + exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, contentType); + } else { + exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/octet-stream"); + } } if (lastModified != null) { exchange.getResponseHeaders().put(Headers.LAST_MODIFIED, resource.getLastModifiedString()); @@ -241,14 +280,21 @@ realBase = base + "/"; } for (String possibility : possible) { - Resource index = resourceManager.getResource(realBase + possibility); + Resource index = resourceManager.getResource(canonicalize(realBase + possibility)); if (index != null) { return index; } } return null; } + private String canonicalize(String s) { + if(canonicalizePaths) { + return CanonicalPathUtils.canonicalize(s); + } + return s; + } + public boolean isDirectoryListingEnabled() { return directoryListingEnabled; } @@ -322,4 +368,71 @@ this.contentEncodedResourceManager = contentEncodedResourceManager; return this; } + + public boolean isCanonicalizePaths() { + return canonicalizePaths; + } + + /** + * If this handler should use canonicalized paths. + * + * WARNING: If this is not true and {@link io.undertow.server.handlers.CanonicalPathHandler} is not installed in + * the handler chain then is may be possible to perform a directory traversal attack. If you set this to false make + * sure you have some kind of check in place to control the path. + * @param canonicalizePaths If paths should be canonicalized + */ + public void setCanonicalizePaths(boolean canonicalizePaths) { + this.canonicalizePaths = canonicalizePaths; + } + + public static class Builder implements HandlerBuilder { + + @Override + public String name() { + return "resource"; + } + + @Override + public Map> parameters() { + Map> params = new HashMap<>(); + params.put("location", String.class); + params.put("allow-listing", boolean.class); + return params; + } + + @Override + public Set requiredParameters() { + return Collections.singleton("location"); + } + + @Override + public String defaultParameter() { + return "location"; + } + + @Override + public HandlerWrapper build(Map config) { + return new Wrapper((String)config.get("location"), (Boolean) config.get("allow-listing")); + } + + } + + private static class Wrapper implements HandlerWrapper { + + private final String location; + private final boolean allowDirectoryListing; + + private Wrapper(String location, boolean allowDirectoryListing) { + this.location = location; + this.allowDirectoryListing = allowDirectoryListing; + } + + @Override + public HttpHandler wrap(HttpHandler handler) { + ResourceManager rm = new FileResourceManager(new File(location), 1024); + ResourceHandler resourceHandler = new ResourceHandler(rm); + resourceHandler.setDirectoryListingEnabled(allowDirectoryListing); + return resourceHandler; + } + } } Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/ResourceManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceManager.java 8 Sep 2014 10:52:18 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/ResourceManager.java 25 Nov 2014 10:46:54 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.resource; import io.undertow.UndertowMessages; Index: 3rdParty_sources/undertow/io/undertow/server/handlers/resource/URLResource.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/handlers/resource/Attic/URLResource.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/handlers/resource/URLResource.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/handlers/resource/URLResource.java 25 Nov 2014 10:46:55 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.handlers.resource; import java.io.File; @@ -82,7 +100,7 @@ @Override public List list() { - List result = new LinkedList(); + List result = new LinkedList<>(); File file = getFile(); try { if (file != null) { Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/protocol/ParseTimeoutUpdater.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AbstractAjpParseState.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/ajp/Attic/AbstractAjpParseState.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AbstractAjpParseState.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AbstractAjpParseState.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.ajp; /** Index: 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AbstractAjpParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/ajp/Attic/AbstractAjpParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AbstractAjpParser.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AbstractAjpParser.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.ajp; import io.undertow.util.HttpString; Index: 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpOpenListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/ajp/Attic/AjpOpenListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpOpenListener.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpOpenListener.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,13 +1,38 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.ajp; import io.undertow.UndertowLogger; import io.undertow.UndertowMessages; +import io.undertow.UndertowOptions; +import io.undertow.conduits.ReadTimeoutStreamSourceConduit; +import io.undertow.conduits.WriteTimeoutStreamSinkConduit; import io.undertow.server.HttpHandler; import io.undertow.server.OpenListener; +import org.xnio.IoUtils; import org.xnio.OptionMap; +import org.xnio.Options; import org.xnio.Pool; +import org.xnio.Pooled; import org.xnio.StreamConnection; +import java.io.IOException; import java.nio.ByteBuffer; import static io.undertow.UndertowOptions.DECODE_URL; @@ -30,22 +55,60 @@ private final AjpRequestParser parser; + @Deprecated public AjpOpenListener(final Pool pool, final int bufferSize) { - this(pool, OptionMap.EMPTY, bufferSize); + this(pool, OptionMap.EMPTY); } + @Deprecated public AjpOpenListener(final Pool pool, final OptionMap undertowOptions, final int bufferSize) { + this(pool, undertowOptions); + } + public AjpOpenListener(final Pool pool) { + this(pool, OptionMap.EMPTY); + } + + public AjpOpenListener(final Pool pool, final OptionMap undertowOptions) { this.undertowOptions = undertowOptions; this.bufferPool = pool; - this.bufferSize = bufferSize; + Pooled buf = pool.allocate(); + this.bufferSize = buf.getResource().remaining(); + buf.free(); parser = new AjpRequestParser(undertowOptions.get(URL_CHARSET, UTF_8), undertowOptions.get(DECODE_URL, true)); } + @Override public void handleEvent(final StreamConnection channel) { if (UndertowLogger.REQUEST_LOGGER.isTraceEnabled()) { UndertowLogger.REQUEST_LOGGER.tracef("Opened connection with %s", channel.getPeerAddress()); } + //set read and write timeouts + try { + Integer readTimeout = channel.getOption(Options.READ_TIMEOUT); + Integer idleTimeout = undertowOptions.get(UndertowOptions.IDLE_TIMEOUT); + if ((readTimeout == null || readTimeout <= 0) && idleTimeout != null) { + readTimeout = idleTimeout; + } else if (readTimeout != null && idleTimeout != null && idleTimeout > 0) { + readTimeout = Math.min(readTimeout, idleTimeout); + } + if (readTimeout != null && readTimeout > 0) { + channel.getSourceChannel().setConduit(new ReadTimeoutStreamSourceConduit(channel.getSourceChannel().getConduit(), channel, this)); + } + Integer writeTimeout = channel.getOption(Options.WRITE_TIMEOUT); + if ((writeTimeout == null || writeTimeout <= 0) && idleTimeout != null) { + writeTimeout = idleTimeout; + } else if (writeTimeout != null && idleTimeout != null && idleTimeout > 0) { + writeTimeout = Math.min(writeTimeout, idleTimeout); + } + if (writeTimeout != null && writeTimeout > 0) { + channel.getSinkChannel().setConduit(new WriteTimeoutStreamSinkConduit(channel.getSinkChannel().getConduit(), channel, this)); + } + } catch (IOException e) { + IoUtils.safeClose(channel); + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); + } + AjpServerConnection connection = new AjpServerConnection(channel, bufferPool, rootHandler, undertowOptions, bufferSize); AjpReadListener readListener = new AjpReadListener(connection, scheme, parser); connection.setAjpReadListener(readListener); @@ -54,18 +117,22 @@ readListener.handleEvent(channel.getSourceChannel()); } + @Override public HttpHandler getRootHandler() { return rootHandler; } + @Override public void setRootHandler(final HttpHandler rootHandler) { this.rootHandler = rootHandler; } + @Override public OptionMap getUndertowOptions() { return undertowOptions; } + @Override public void setUndertowOptions(final OptionMap undertowOptions) { if (undertowOptions == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("undertowOptions"); Index: 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpReadListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/ajp/Attic/AjpReadListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpReadListener.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpReadListener.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.ajp; import io.undertow.UndertowLogger; @@ -8,12 +26,12 @@ import io.undertow.server.AbstractServerConnection; import io.undertow.server.Connectors; import io.undertow.server.HttpServerExchange; +import io.undertow.server.protocol.ParseTimeoutUpdater; import io.undertow.util.HeaderMap; import io.undertow.util.Headers; import io.undertow.util.HttpString; import io.undertow.util.Methods; import org.xnio.ChannelListener; -import org.xnio.IoUtils; import org.xnio.Pooled; import org.xnio.StreamConnection; import org.xnio.channels.StreamSinkChannel; @@ -48,27 +66,39 @@ private final AjpRequestParser parser; private WriteReadyHandler.ChannelListenerHandler writeReadyHandler; + private ParseTimeoutUpdater parseTimeoutUpdater; AjpReadListener(final AjpServerConnection connection, final String scheme, AjpRequestParser parser) { this.connection = connection; this.scheme = scheme; this.parser = parser; this.maxRequestSize = connection.getUndertowOptions().get(UndertowOptions.MAX_HEADER_SIZE, UndertowOptions.DEFAULT_MAX_HEADER_SIZE); - this.maxEntitySize = connection.getUndertowOptions().get(UndertowOptions.MAX_ENTITY_SIZE, 0); - this.writeReadyHandler = new WriteReadyHandler.ChannelListenerHandler(connection.getChannel().getSinkChannel()); + this.maxEntitySize = connection.getUndertowOptions().get(UndertowOptions.MAX_ENTITY_SIZE, UndertowOptions.DEFAULT_MAX_ENTITY_SIZE); + this.writeReadyHandler = new WriteReadyHandler.ChannelListenerHandler<>(connection.getChannel().getSinkChannel()); this.recordRequestStartTime = connection.getUndertowOptions().get(UndertowOptions.RECORD_REQUEST_START_TIME, false); + int requestParseTimeout = connection.getUndertowOptions().get(UndertowOptions.REQUEST_PARSE_TIMEOUT, -1); + int requestIdleTimeout = connection.getUndertowOptions().get(UndertowOptions.NO_REQUEST_TIMEOUT, -1); + if(requestIdleTimeout < 0 && requestParseTimeout < 0) { + this.parseTimeoutUpdater = null; + } else { + this.parseTimeoutUpdater = new ParseTimeoutUpdater(connection, requestParseTimeout, requestIdleTimeout); + connection.addCloseListener(parseTimeoutUpdater); + } } public void startRequest() { connection.resetChannel(); state = new AjpRequestParseState(); httpServerExchange = new HttpServerExchange(connection, maxEntitySize); read = 0; + if(parseTimeoutUpdater != null) { + parseTimeoutUpdater.connectionIdle(); + } } public void handleEvent(final StreamSourceChannel channel) { if(connection.getOriginalSinkConduit().isWriteShutdown() || connection.getOriginalSourceConduit().isReadShutdown()) { - IoUtils.safeClose(connection); + safeClose(connection); channel.suspendReads(); return; } @@ -77,7 +107,7 @@ final Pooled pooled = existing == null ? connection.getBufferPool().allocate() : existing; final ByteBuffer buffer = pooled.getResource(); boolean free = true; - + boolean bytesRead = false; try { int res; do { @@ -94,6 +124,10 @@ res = buffer.remaining(); } if (res == 0) { + + if(bytesRead && parseTimeoutUpdater != null) { + parseTimeoutUpdater.failedParse(); + } if (!channel.isReadResumed()) { channel.getReadSetter().set(this); channel.resumeReads(); @@ -105,15 +139,16 @@ channel.shutdownReads(); final StreamSinkChannel responseChannel = connection.getChannel().getSinkChannel(); responseChannel.shutdownWrites(); - IoUtils.safeClose(connection); + safeClose(connection); } catch (IOException e) { UndertowLogger.REQUEST_IO_LOGGER.ioException(e); // fuck it, it's all ruined - IoUtils.safeClose(connection); + safeClose(connection); return; } return; } + bytesRead = true; //TODO: we need to handle parse errors if (existing != null) { existing = null; @@ -123,19 +158,22 @@ } int begin = buffer.remaining(); parser.parse(buffer, state, httpServerExchange); - read += (begin - buffer.remaining()); + + read += begin - buffer.remaining(); if (buffer.hasRemaining()) { free = false; connection.setExtraBytes(pooled); } if (read > maxRequestSize) { UndertowLogger.REQUEST_LOGGER.requestHeaderWasTooLarge(connection.getPeerAddress(), maxRequestSize); - IoUtils.safeClose(connection); + safeClose(connection); return; } } while (!state.isComplete()); - + if(parseTimeoutUpdater != null) { + parseTimeoutUpdater.requestStarted(); + } if (state.prefix != AjpRequestParser.FORWARD_REQUEST) { if (state.prefix == AjpRequestParser.CPING) { UndertowLogger.REQUEST_LOGGER.debug("Received CPING, sending CPONG"); @@ -147,7 +185,7 @@ channel.resumeReads(); } else { UndertowLogger.REQUEST_LOGGER.ignoringAjpRequestWithPrefixCode(state.prefix); - IoUtils.safeClose(connection); + safeClose(connection); } return; } @@ -189,12 +227,12 @@ } catch (Throwable t) { //TODO: we should attempt to return a 500 status code in this situation UndertowLogger.REQUEST_LOGGER.exceptionProcessingRequest(t); - IoUtils.safeClose(channel); - IoUtils.safeClose(connection); + safeClose(channel); + safeClose(connection); } } catch (Exception e) { UndertowLogger.REQUEST_LOGGER.exceptionProcessingRequest(e); - IoUtils.safeClose(connection.getChannel()); + safeClose(connection.getChannel()); } finally { if (free) pooled.free(); } @@ -222,7 +260,7 @@ } } catch (IOException e) { UndertowLogger.REQUEST_IO_LOGGER.ioException(e); - IoUtils.safeClose(connection); + safeClose(connection); } } while (buffer.hasRemaining()); channel.suspendWrites(); @@ -236,7 +274,7 @@ AjpReadListener.this.handleEvent(underlyingChannel.getSourceChannel()); } catch (IOException e) { UndertowLogger.REQUEST_IO_LOGGER.ioException(e); - IoUtils.safeClose(connection); + safeClose(connection); } } @@ -247,7 +285,7 @@ channel.getReadSetter().set(this); channel.wakeupReads(); } else if(!exchange.isPersistent()) { - IoUtils.safeClose(exchange.getConnection()); + safeClose(exchange.getConnection()); } } Index: 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpRequestParseState.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/ajp/Attic/AjpRequestParseState.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpRequestParseState.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpRequestParseState.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,15 +1,33 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.ajp; -import io.undertow.server.BasicSSLSessionInfo; -import io.undertow.util.HttpString; - import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.security.cert.CertificateException; import java.util.HashMap; import java.util.Map; +import io.undertow.server.BasicSSLSessionInfo; +import io.undertow.util.HttpString; + /** * @author Stuart Douglas */ @@ -47,7 +65,7 @@ String currentAttribute; //TODO: can there be more than one attribute? - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); String remoteAddress; int serverPort = 80; @@ -74,15 +92,16 @@ } InetSocketAddress createPeerAddress() { - if(remoteAddress == null) { + if (remoteAddress == null) { return null; } String portString = attributes.get(AJP_REMOTE_PORT); int port = 0; - if(portString != null) { + if (portString != null) { try { port = Integer.parseInt(portString); - } catch (IllegalArgumentException e) {} + } catch (IllegalArgumentException e) { + } } try { InetAddress address = InetAddress.getByName(remoteAddress); @@ -93,14 +112,9 @@ } InetSocketAddress createDestinationAddress() { - if(serverAddress == null) { + if (serverAddress == null) { return null; } - try { - InetAddress address = InetAddress.getByName(serverAddress); - return new InetSocketAddress(address, serverPort); - } catch (UnknownHostException e) { - return null; - } + return InetSocketAddress.createUnresolved(serverAddress, serverPort); } } Index: 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpRequestParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/ajp/Attic/AjpRequestParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpRequestParser.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpRequestParser.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,16 +1,23 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.ajp; -import io.undertow.security.impl.ExternalAuthenticationMechanism; -import io.undertow.server.HttpServerExchange; -import io.undertow.util.Headers; -import io.undertow.util.HttpString; -import io.undertow.util.URLUtils; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.nio.ByteBuffer; - import static io.undertow.util.Methods.ACL; import static io.undertow.util.Methods.BASELINE_CONTROL; import static io.undertow.util.Methods.CHECKIN; @@ -39,6 +46,17 @@ import static io.undertow.util.Methods.UPDATE; import static io.undertow.util.Methods.VERSION_CONTROL; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.ByteBuffer; + +import io.undertow.security.impl.ExternalAuthenticationMechanism; +import io.undertow.server.HttpServerExchange; +import io.undertow.util.Headers; +import io.undertow.util.HttpString; +import io.undertow.util.URLUtils; + /** * @author Stuart Douglas */ @@ -198,7 +216,7 @@ int method = buf.get(); if (method > 0 && method < 28) { exchange.setRequestMethod(HTTP_METHODS[method]); - } else { + } else if((method & 0xFF) != 0xFF) { throw new IllegalArgumentException("Unknown method type " + method); } } @@ -217,7 +235,7 @@ StringHolder result = parseString(buf, state, false); if (result.readComplete) { int colon = result.value.indexOf(';'); - if(colon == -1) { + if (colon == -1) { String res = decode(result.value, result.containsUrlCharacters); exchange.setRequestURI(result.value); exchange.setRequestPath(res); @@ -277,7 +295,7 @@ return; } else { final byte isSsl = buf.get(); - if(isSsl != 0) { + if (isSsl != 0) { exchange.setRequestScheme("https"); } else { exchange.setRequestScheme("http"); @@ -367,10 +385,12 @@ if (state.currentAttribute.equals(QUERY_STRING)) { exchange.setQueryString(result == null ? "" : result); URLUtils.parseQueryString(result, exchange, encoding, doDecode); - } else if(state.currentAttribute.equals(REMOTE_USER)) { + } else if (state.currentAttribute.equals(REMOTE_USER)) { exchange.putAttachment(ExternalAuthenticationMechanism.EXTERNAL_PRINCIPAL, result); - } else if(state.currentAttribute.equals(AUTH_TYPE)) { + } else if (state.currentAttribute.equals(AUTH_TYPE)) { exchange.putAttachment(ExternalAuthenticationMechanism.EXTERNAL_AUTHENTICATION_TYPE, result); + } else if (state.currentAttribute.equals(STORED_METHOD)) { + exchange.setRequestMethod(new HttpString(result)); } else { //other attributes state.attributes.put(state.currentAttribute, result); @@ -383,7 +403,7 @@ } private String decode(String url, final boolean containsUrlCharacters) throws UnsupportedEncodingException { - if(doDecode && containsUrlCharacters) { + if (doDecode && containsUrlCharacters) { return URLDecoder.decode(url, encoding); } return url; Index: 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpServerConnection.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/ajp/Attic/AjpServerConnection.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpServerConnection.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpServerConnection.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.protocol.ajp; @@ -52,7 +52,7 @@ public AjpServerConnection(StreamConnection channel, Pool bufferPool, HttpHandler rootHandler, OptionMap undertowOptions, int bufferSize) { super(channel, bufferPool, rootHandler, undertowOptions, bufferSize); - this.writeReadyHandler = new WriteReadyHandler.ChannelListenerHandler(channel.getSinkChannel()); + this.writeReadyHandler = new WriteReadyHandler.ChannelListenerHandler<>(channel.getSinkChannel()); } @Override @@ -81,6 +81,11 @@ } @Override + public void terminateRequestChannel(HttpServerExchange exchange) { + //todo: terminate + } + + @Override public void restoreChannel(ConduitState state) { super.restoreChannel(state); channel.getSinkChannel().getConduit().setWriteReadyHandler(writeReadyHandler); Index: 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpServerRequestConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/ajp/Attic/AjpServerRequestConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpServerRequestConduit.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpServerRequestConduit.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.ajp; import java.io.IOException; @@ -116,6 +134,15 @@ } @Override + public void terminateReads() throws IOException { + if(exchange.isPersistent()) { + state |= STATE_FINISHED; + return; + } + super.terminateReads(); + } + + @Override public long read(ByteBuffer[] dsts, int offset, int length) throws IOException { long total = 0; for (int i = offset; i < length; ++i) { @@ -140,6 +167,13 @@ return -1; } else if (anyAreSet(state, STATE_SEND_REQUIRED)) { state = this.state = (state & STATE_MASK) | STATE_READING; + if(ajpResponseConduit.isWriteShutdown()) { + this.state = STATE_FINISHED; + if (finishListener != null) { + finishListener.handleEvent(this); + } + return -1; + } if (!ajpResponseConduit.doGetRequestBodyChunk(READ_BODY_CHUNK.duplicate(), this)) { return 0; } @@ -200,9 +234,9 @@ chunkRemaining = this.state & STATE_MASK; } - int limit = dst.limit(); + int limit = dst.remaining(); try { - if (limit > chunkRemaining) { + if (dst.remaining() > chunkRemaining) { dst.limit((int) (dst.position() + chunkRemaining)); } int read = next.read(dst); Index: 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpServerResponseConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/ajp/Attic/AjpServerResponseConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpServerResponseConduit.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/ajp/AjpServerResponseConduit.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.protocol.ajp; @@ -64,7 +64,7 @@ private static final Map HEADER_MAP; static { - final Map headers = new HashMap(); + final Map headers = new HashMap<>(); headers.put(Headers.CONTENT_TYPE, 0xA001); headers.put(Headers.CONTENT_LANGUAGE, 0xA002); headers.put(Headers.CONTENT_LENGTH, 0xA003); @@ -83,6 +83,7 @@ private static final int FLAG_WRITE_RESUMED = 1 << 2; private static final int FLAG_WRITE_READ_BODY_CHUNK_FROM_LISTENER = 1 << 3; private static final int FLAG_WRITE_SHUTDOWN = 1 << 4; + private static final int FLAG_READS_DONE = 1 << 5; private static final ByteBuffer CLOSE_FRAME_PERSISTENT; private static final ByteBuffer CLOSE_FRAME_NON_PERSISTENT; Index: 3rdParty_sources/undertow/io/undertow/server/protocol/framed/AbstractFramedChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/framed/Attic/AbstractFramedChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/framed/AbstractFramedChannel.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/framed/AbstractFramedChannel.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,19 +9,34 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.protocol.framed; -import io.undertow.UndertowMessages; -import io.undertow.conduits.IdleTimeoutConduit; -import io.undertow.util.ReferenceCountedPooled; -import io.undertow.websockets.core.WebSocketLogger; +import static org.xnio.IoUtils.safeClose; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.nio.ByteBuffer; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Deque; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import org.xnio.Buffers; +import org.xnio.ChannelExceptionHandler; import org.xnio.ChannelListener; import org.xnio.ChannelListener.Setter; import org.xnio.ChannelListeners; @@ -32,25 +47,18 @@ import org.xnio.StreamConnection; import org.xnio.XnioIoThread; import org.xnio.XnioWorker; +import org.xnio.channels.CloseableChannel; import org.xnio.channels.ConnectedChannel; import org.xnio.channels.StreamSinkChannel; import org.xnio.channels.StreamSourceChannel; -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import java.nio.ByteBuffer; -import java.util.ArrayDeque; -import java.util.Deque; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import io.undertow.UndertowLogger; +import io.undertow.UndertowMessages; +import io.undertow.conduits.IdleTimeoutConduit; +import io.undertow.util.ReferenceCountedPooled; +import io.undertow.websockets.core.WebSocketLogger; +import org.xnio.channels.SuspendableWriteChannel; -import static org.xnio.IoUtils.safeClose; - /** * A {@link org.xnio.channels.ConnectedChannel} which can be used to send and receive Frames. *

    @@ -75,20 +83,20 @@ /** * List of frames that are ready to send */ - private final List pendingFrames = new LinkedList(); + private final List pendingFrames = new LinkedList<>(); /** * Frames that are not yet read to send. */ - private final Deque heldFrames = new ArrayDeque(); + private final Deque heldFrames = new ArrayDeque<>(); /** * new frames to be sent. These will be added to either the pending or held frames list * depending on the {@link #framePriority} implementation in use. */ - private final Deque newFrames = new ArrayDeque(); + private final Deque newFrames = new LinkedBlockingDeque<>(); - private volatile R receiver = null; - private final List receivers = new CopyOnWriteArrayList(); + private volatile long frameDataRemaining; + private volatile R receiver; private boolean receivesSuspended = true; @@ -102,7 +110,11 @@ private static final AtomicIntegerFieldUpdater writesBrokenUpdater = AtomicIntegerFieldUpdater.newUpdater(AbstractFramedChannel.class, "writesBroken"); private ReferenceCountedPooled readData = null; + private final List> closeTasks = new CopyOnWriteArrayList<>(); + private boolean flushingSenders = false; + private final Set> receivers = new HashSet<>(); + /** * Create a new {@link io.undertow.server.protocol.framed.AbstractFramedChannel} * 8 @@ -112,25 +124,44 @@ * @param bufferPool The {@link org.xnio.Pool} which will be used to acquire {@link java.nio.ByteBuffer}'s from. * @param framePriority */ - protected AbstractFramedChannel(final StreamConnection connectedStreamChannel, Pool bufferPool, FramePriority framePriority) { + protected AbstractFramedChannel(final StreamConnection connectedStreamChannel, Pool bufferPool, FramePriority framePriority, final Pooled readData) { this.framePriority = framePriority; - IdleTimeoutConduit idle = new IdleTimeoutConduit(connectedStreamChannel.getSinkChannel().getConduit(), connectedStreamChannel.getSourceChannel().getConduit()); + if (readData != null) { + if(readData.getResource().hasRemaining()) { + this.readData = new ReferenceCountedPooled<>(readData, 1); + } else { + readData.free(); + } + } + if(bufferPool == null) { + throw UndertowMessages.MESSAGES.argumentCannotBeNull("bufferPool"); + } + if(connectedStreamChannel == null) { + throw UndertowMessages.MESSAGES.argumentCannotBeNull("connectedStreamChannel"); + } + IdleTimeoutConduit idle = createIdleTimeoutChannel(connectedStreamChannel); connectedStreamChannel.getSourceChannel().setConduit(idle); connectedStreamChannel.getSinkChannel().setConduit(idle); this.idleTimeoutConduit = idle; this.channel = connectedStreamChannel; this.bufferPool = bufferPool; - closeSetter = new ChannelListener.SimpleSetter(); - receiveSetter = new ChannelListener.SimpleSetter(); + closeSetter = new ChannelListener.SimpleSetter<>(); + receiveSetter = new ChannelListener.SimpleSetter<>(); channel.getSourceChannel().getReadSetter().set(null); channel.getSourceChannel().suspendReads(); channel.getSourceChannel().getReadSetter().set(new FrameReadListener()); connectedStreamChannel.getSinkChannel().getWriteSetter().set(new FrameWriteListener()); - connectedStreamChannel.getSinkChannel().getCloseSetter().set(new FrameCloseListener()); + FrameCloseListener closeListener = new FrameCloseListener(); + connectedStreamChannel.getSinkChannel().getCloseSetter().set(closeListener); + connectedStreamChannel.getSourceChannel().getCloseSetter().set(closeListener); } + protected IdleTimeoutConduit createIdleTimeoutChannel(StreamConnection connectedStreamChannel) { + return new IdleTimeoutConduit(connectedStreamChannel.getSinkChannel().getConduit(), connectedStreamChannel.getSourceChannel().getConduit()); + } + /** * Get the buffer pool for this connection. * @@ -217,10 +248,7 @@ * of calling this method then it can prevent frame channels for being fully consumed. */ public synchronized R receive() throws IOException { - if (receiver != null) { - return null; - } - if (isLastFrameReceived()) { + if (isLastFrameReceived() && receiver == null) { //we have received the last frame, we just shut down and return //it would probably make more sense to have the last channel responsible for this //however it is much simpler just to have it here @@ -232,16 +260,17 @@ boolean hasData; if (pooled == null) { Pooled buf = bufferPool.allocate(); - this.readData = pooled = new ReferenceCountedPooled(buf, 1); + this.readData = pooled = new ReferenceCountedPooled<>(buf, 1); hasData = false; } else { hasData = pooled.getResource().hasRemaining(); } boolean forceFree = false; + int read = 0; try { if (!hasData) { pooled.getResource().clear(); - int read = channel.getSourceChannel().read(pooled.getResource()); + read = channel.getSourceChannel().read(pooled.getResource()); if (read == 0) { //no data, we just free the buffer forceFree = true; @@ -257,14 +286,47 @@ safeClose(channel.getSourceChannel()); throw e; } - throw UndertowMessages.MESSAGES.channelIsClosed(); + forceFree = true; + lastDataRead(); + return null; } pooled.getResource().flip(); } + if (frameDataRemaining > 0) { + if (frameDataRemaining >= pooled.getResource().remaining()) { + frameDataRemaining -= pooled.getResource().remaining(); + if(receiver != null) { + receiver.dataReady(null, pooled); + } else { + //we are dropping a frame + pooled.free(); + } + readData = null; + if(frameDataRemaining == 0) { + receiver = null; + } + return null; + } else { + ByteBuffer buf = pooled.getResource().duplicate(); + buf.limit((int) (buf.position() + frameDataRemaining)); + pooled.getResource().position((int) (pooled.getResource().position() + frameDataRemaining)); + frameDataRemaining = 0; + Pooled frameData = pooled.createView(buf); + //note that we don't return here, there may be another frame + if(receiver != null) { + receiver.dataReady(null, frameData); + } else{ + //we are dropping the frame + frameData.free(); + } + receiver = null; + } + } FrameHeaderData data = parseFrame(pooled.getResource()); if (data != null) { Pooled frameData; - if (data.getFrameLength() > pooled.getResource().remaining()) { + if (data.getFrameLength() >= pooled.getResource().remaining()) { + frameDataRemaining = data.getFrameLength() - pooled.getResource().remaining(); frameData = pooled.createView(pooled.getResource().duplicate()); pooled.getResource().position(pooled.getResource().limit()); } else { @@ -275,31 +337,40 @@ } AbstractFramedStreamSourceChannel existing = data.getExistingChannel(); if (existing != null) { - existing.dataReady(data, frameData); if (data.getFrameLength() > frameData.getResource().remaining()) { receiver = (R) existing; } + existing.dataReady(data, frameData); return null; } else { + boolean moreData = data.getFrameLength() > frameData.getResource().remaining(); R newChannel = createChannel(data, frameData); - if (data.getFrameLength() > frameData.getResource().remaining()) { - receiver = newChannel; + if (newChannel != null) { + if(!newChannel.isComplete()) { + receivers.add(newChannel); + } + if (moreData) { + receiver = newChannel; + } + } else { + frameData.free(); } - receivers.add(newChannel); + return newChannel; } } return null; } catch (IOException e) { //something has code wrong with parsing, close the read side //we don't close the write side, as the underlying implementation will most likely want to send an error + UndertowLogger.REQUEST_LOGGER.ioException(e); markReadsBroken(e); forceFree = true; throw e; } finally { //if the receive caused the channel to break the close listener may be have been called //which will make readData null - if(readData != null) { + if (readData != null) { if (!pooled.getResource().hasRemaining() || forceFree) { pooled.free(); this.readData = null; @@ -309,13 +380,20 @@ } /** + * Method than is invoked when read() returns -1. + */ + protected void lastDataRead() { + + } + + /** * Method that creates the actual stream source channel implementation that is in use. * * @param frameHeaderData The header data, as returned by {@link #parseFrame(java.nio.ByteBuffer)} * @param frameData Any additional data for the frame that has already been read. This may not be the complete frame contents * @return A new stream source channel */ - protected abstract R createChannel(FrameHeaderData frameHeaderData, Pooled frameData); + protected abstract R createChannel(FrameHeaderData frameHeaderData, Pooled frameData) throws IOException; /** * Attempts to parse an incoming frame header from the data in the buffer. @@ -326,6 +404,13 @@ */ protected abstract FrameHeaderData parseFrame(ByteBuffer data) throws IOException; + protected synchronized void recalculateHeldFrames() throws IOException { + if (!heldFrames.isEmpty()) { + framePriority.frameAdded(null, pendingFrames, heldFrames); + flushSenders(); + } + } + /** * Flushes all ready stream sink conduits to the channel. *

    @@ -335,87 +420,114 @@ * * @throws IOException */ - protected synchronized void flushSenders() throws IOException { - int toSend = 0; - while (!newFrames.isEmpty()) { - S frame = newFrames.poll(); - if (framePriority.insertFrame(frame, pendingFrames)) { - if (!heldFrames.isEmpty()) { - framePriority.frameAdded(frame, pendingFrames, heldFrames); + protected synchronized void flushSenders() { + if(flushingSenders) { + throw UndertowMessages.MESSAGES.recursiveCallToFlushingSenders(); + } + flushingSenders = true; + try { + int toSend = 0; + while (!newFrames.isEmpty()) { + S frame = newFrames.poll(); + if (framePriority.insertFrame(frame, pendingFrames)) { + if (!heldFrames.isEmpty()) { + framePriority.frameAdded(frame, pendingFrames, heldFrames); + } + } else { + heldFrames.add(frame); } - } else { - heldFrames.add(frame); } - } - boolean finalFrame = false; - ListIterator it = pendingFrames.listIterator(); - while (it.hasNext()) { - S sender = it.next(); - if (sender.isReadyForFlush()) { - ++toSend; - } else { - break; + boolean finalFrame = false; + ListIterator it = pendingFrames.listIterator(); + while (it.hasNext()) { + S sender = it.next(); + if (sender.isReadyForFlush()) { + ++toSend; + } else { + break; + } + if (sender.isLastFrame()) { + finalFrame = true; + } } - if (sender.isLastFrame()) { - finalFrame = true; + if (toSend == 0) { + //if there is nothing to send we just attempt a flush on the underlying channel + try { + if(channel.getSinkChannel().flush()) { + channel.getSinkChannel().suspendWrites(); + } + } catch (IOException e) { + safeClose(channel); + markWritesBroken(e); + } + return; } - } - if (toSend == 0) { - return; - } - ByteBuffer[] data = new ByteBuffer[toSend * 3]; - int j = 0; - it = pendingFrames.listIterator(); - while (j < toSend) { - S next = it.next(); - //todo: rather than adding empty buffers just store the offsets - data[j * 3] = next.getFrameHeader(); - ByteBuffer frameHeaderByteBuffer = next.getFrameHeader(); - data[j * 3] = frameHeaderByteBuffer != null - ? frameHeaderByteBuffer - : Buffers.EMPTY_BYTE_BUFFER; - data[(j * 3) + 1] = next.getBuffer(); - data[(j * 3) + 2] = next.getFrameFooter(); - ++j; - } - long toWrite = Buffers.remaining(data); - - long res; - do { + ByteBuffer[] data = new ByteBuffer[toSend * 3]; + int j = 0; + it = pendingFrames.listIterator(); try { - res = channel.getSinkChannel().write(data); - toWrite -= res; + while (j < toSend) { + S next = it.next(); + //todo: rather than adding empty buffers just store the offsets + SendFrameHeader frameHeader = next.getFrameHeader(); + Pooled frameHeaderByteBuffer = frameHeader.getByteBuffer(); + data[j * 3] = frameHeaderByteBuffer != null + ? frameHeaderByteBuffer.getResource() + : Buffers.EMPTY_BYTE_BUFFER; + data[(j * 3) + 1] = next.getBuffer(); + data[(j * 3) + 2] = next.getFrameFooter(); + ++j; + } + long toWrite = Buffers.remaining(data); + long res; + do { + res = channel.getSinkChannel().write(data); + toWrite -= res; + } while (res > 0 && toWrite > 0); + int max = toSend; + + while (max > 0) { + S sinkChannel = pendingFrames.get(0); + Pooled frameHeaderByteBuffer = sinkChannel.getFrameHeader().getByteBuffer(); + if (frameHeaderByteBuffer != null && frameHeaderByteBuffer.getResource().hasRemaining() + || sinkChannel.getBuffer().hasRemaining() + || sinkChannel.getFrameFooter().hasRemaining()) { + break; + } + sinkChannel.flushComplete(); + pendingFrames.remove(sinkChannel); + max--; + } + if (!pendingFrames.isEmpty() || !channel.getSinkChannel().flush()) { + channel.getSinkChannel().resumeWrites(); + } else { + channel.getSinkChannel().suspendWrites(); + } + if (pendingFrames.isEmpty() && finalFrame) { + //all data has been sent. Close gracefully + channel.getSinkChannel().shutdownWrites(); + if (!channel.getSinkChannel().flush()) { + channel.getSinkChannel().setWriteListener(ChannelListeners.flushingChannelListener(null, null)); + channel.getSinkChannel().resumeWrites(); + } + } + } catch (IOException e) { - IoUtils.safeClose(channel); + safeClose(channel); markWritesBroken(e); - throw e; } - } while (res > 0 && toWrite > 0); - int max = toSend; - - while (max > 0) { - S sinkChannel = pendingFrames.get(0); - if (sinkChannel.getFrameHeader() != null && sinkChannel.getFrameHeader().hasRemaining() - || sinkChannel.getBuffer().hasRemaining() - || sinkChannel.getFrameFooter().hasRemaining()) { - break; + } finally { + flushingSenders = false; + if(!newFrames.isEmpty()) { + getIoThread().execute(new Runnable() { + @Override + public void run() { + flushSenders(); + } + }); } - sinkChannel.flushComplete(); - pendingFrames.remove(sinkChannel); - max--; } - if (!pendingFrames.isEmpty()) { - pendingFrames.get(0).activated(); - } - if (pendingFrames.isEmpty() && finalFrame) { - //all data has been sent. Close gracefully - channel.getSinkChannel().shutdownWrites(); - if (!channel.getSinkChannel().flush()) { - channel.getSinkChannel().setWriteListener(ChannelListeners.flushingChannelListener(null, null)); - channel.getSinkChannel().resumeWrites(); - } - } } void awaitWritable() throws IOException { @@ -436,12 +548,22 @@ */ protected synchronized void queueFrame(final S channel) throws IOException { assert !newFrames.contains(channel); - if (isWritesBroken() || !this.channel.getSinkChannel().isOpen()) { + if (isWritesBroken() || !this.channel.getSinkChannel().isOpen() || channel.isBroken() || !channel.isOpen()) { + IoUtils.safeClose(channel); throw UndertowMessages.MESSAGES.channelIsClosed(); } newFrames.add(channel); - if (newFrames.peek() == channel) { - flushSenders(); + if (!flushingSenders) { + if(channel.getIoThread() == Thread.currentThread()) { + flushSenders(); + } else { + channel.getIoThread().execute(new Runnable() { + @Override + public void run() { + flushSenders(); + } + }); + } } } @@ -490,12 +612,10 @@ */ public synchronized void resumeReceives() { receivesSuspended = false; - if (receiver == null) { - if (readData != null) { - channel.getSourceChannel().wakeupReads(); - } else { - channel.getSourceChannel().resumeReads(); - } + if (readData != null) { + channel.getSourceChannel().wakeupReads(); + } else { + channel.getSourceChannel().resumeReads(); } } @@ -505,12 +625,14 @@ /** * Forcibly closes the {@link io.undertow.server.protocol.framed.AbstractFramedChannel}. - * a clean shutdown */ @Override public void close() throws IOException { - IoUtils.safeClose(channel); - wakeupWrites(); + safeClose(channel); + if(readData != null) { + readData.free(); + readData = null; + } } @Override @@ -531,14 +653,19 @@ handleBrokenSourceChannel(cause); safeClose(channel.getSourceChannel()); - R receiver = this.receiver; - if (receiver != null && receiver.isReadResumed()) { - ChannelListeners.invokeChannelListener(receiver.getIoThread(), receiver, ((ChannelListener.SimpleSetter) receiver.getReadSetter()).get()); - } + + closeSubChannels(); } } + /** + * Method that is called when the channel is being forcibly closed, and all sub stream sink/source + * channels should also be forcibly closed. + */ + protected abstract void closeSubChannels(); + + /** * Called when a sub channel fails to fulfil its contract, and leaves the channel in an inconsistent state. *

    @@ -598,20 +725,18 @@ void notifyFrameReadComplete(AbstractFramedStreamSourceChannel channel) { synchronized (AbstractFramedChannel.this) { if (isLastFrameReceived()) { - IoUtils.safeClose(AbstractFramedChannel.this.channel.getSourceChannel()); + safeClose(AbstractFramedChannel.this.channel.getSourceChannel()); } + } + } + + void notifyClosed(AbstractFramedStreamSourceChannel channel) { + synchronized (AbstractFramedChannel.this) { receivers.remove(channel); - if (channel == receiver) { - receiver = null; - if (receivesSuspended) { - AbstractFramedChannel.this.channel.getSourceChannel().suspendReads(); - } else { - AbstractFramedChannel.this.channel.getSourceChannel().resumeReads(); - } - } } } + /** * {@link org.xnio.ChannelListener} which delegates the read notification to the appropriate listener */ @@ -620,21 +745,14 @@ @Override public void handleEvent(final StreamSourceChannel channel) { final R receiver = AbstractFramedChannel.this.receiver; - if (receiver != null) { - invokeReadListener(channel, receiver); - } else if (isLastFrameReceived() || receivesSuspended) { + if ((isLastFrameReceived() || receivesSuspended) && receiver == null) { channel.suspendReads(); return; } else { final ChannelListener listener = receiveSetter.get(); if (listener != null) { WebSocketLogger.REQUEST_LOGGER.debugf("Invoking receive listener", receiver); ChannelListeners.invokeChannelListener(AbstractFramedChannel.this, listener); - if (AbstractFramedChannel.this.receiver != null) { - //successful receive - //now invoke the read listener if necessary for performance reasons - invokeReadListener(channel, AbstractFramedChannel.this.receiver); - } } else { channel.suspendReads(); } @@ -643,49 +761,61 @@ ChannelListeners.invokeChannelListener(channel.getIoThread(), channel, this); } } - - private void invokeReadListener(StreamSourceChannel channel, R receiver) { - final ChannelListener listener = ((SimpleSetter) receiver.getReadSetter()).get(); - if (listener != null) { - WebSocketLogger.REQUEST_LOGGER.debugf("Invoking read listener %s on %s", listener, receiver); - ChannelListeners.invokeChannelListener(receiver, listener); - } else { - WebSocketLogger.REQUEST_LOGGER.debugf("Suspending reads on channel %s due to no listener", receiver); - channel.suspendReads(); - } - } } private class FrameWriteListener implements ChannelListener { @Override public void handleEvent(final StreamSinkChannel channel) { - synchronized (AbstractFramedChannel.this) { - //first we invoke the write listeners - for (S sender : pendingFrames) { - if (sender.isWriteResumed()) { - ChannelListeners.invokeChannelListener(sender, sender.getWriteListener()); - } - } - if (pendingFrames.isEmpty()) { - channel.suspendWrites(); - } - } + flushSenders(); } } /** * close listener, just goes through and activates any sub channels to make sure their listeners are invoked */ - private class FrameCloseListener implements ChannelListener { + private class FrameCloseListener implements ChannelListener { + private boolean sinkClosed; + private boolean sourceClosed; + @Override - public void handleEvent(final StreamSinkChannel c) { - if(Thread.currentThread() != c.getIoThread()) { + public void handleEvent(final CloseableChannel c) { + if(c instanceof StreamSinkChannel) { + sinkClosed = true; + } else if(c instanceof StreamSourceChannel) { + sourceClosed = true; + } + if(!sourceClosed || !sinkClosed) { + return; //both sides need to be closed + } else if(readData != null) { + //we make sure there is no data left to receive, if there is then we invoke the receive listener + final ChannelListener listener = receiveSetter.get(); + if(listener != null) { + channel.getIoThread().execute(new Runnable() { + @Override + public void run() { + while (readData != null) { + int rem = readData.getResource().remaining(); + ChannelListeners.invokeChannelListener(AbstractFramedChannel.this, (ChannelListener) receiveSetter.get()); + if(readData != null && rem == readData.getResource().remaining()) { + readData.free(); + readData = null; + break;//make sure we are making progress + } + } + handleEvent(c); + } + }); + } + return; + } + + if (Thread.currentThread() != c.getIoThread()) { ChannelListeners.invokeChannelListener(c.getIoThread(), c, this); return; } + R receiver = AbstractFramedChannel.this.receiver; try { - R receiver = AbstractFramedChannel.this.receiver; if (receiver != null && receiver.isOpen() && receiver.isReadResumed()) { ChannelListeners.invokeChannelListener(receiver, ((SimpleSetter) receiver.getReadSetter()).get()); } @@ -702,19 +832,25 @@ //if this was a clean shutdown there should not be any senders channel.markBroken(); } + for(AbstractFramedStreamSourceChannel r : new ArrayList<>(receivers)) { + IoUtils.safeClose(r); + } } } finally { - synchronized (AbstractFramedChannel.this) { - for (R r : receivers) { - IoUtils.safeClose(r); + try { + for (ChannelListener task : closeTasks) { + ChannelListeners.invokeChannelListener((C) AbstractFramedChannel.this, task); } - if (readData != null) { - readData.free(); - readData = null; + } finally { + synchronized (AbstractFramedChannel.this) { + closeSubChannels(); + if (readData != null) { + readData.free(); + readData = null; + } } + ChannelListeners.invokeChannelListener((C) AbstractFramedChannel.this, closeSetter.get()); } - ChannelListeners.invokeChannelListener((C) AbstractFramedChannel.this, closeSetter.get()); - } } } @@ -731,8 +867,27 @@ return framePriority; } + public void addCloseTask(final ChannelListener task) { + closeTasks.add(task); + } + @Override public String toString() { return getClass().getSimpleName() + "[ " + (receiver == null ? "No Receiver" : receiver.toString()) + " " + pendingFrames.toString() + " -- " + heldFrames.toString() + " -- " + newFrames.toString() + "]"; } + + protected StreamConnection getUnderlyingConnection() { + return channel; + } + + + + protected ChannelExceptionHandler writeExceptionHandler() { + return new ChannelExceptionHandler() { + @Override + public void handleException(SuspendableWriteChannel channel, IOException exception) { + markWritesBroken(exception); + } + }; + } } Index: 3rdParty_sources/undertow/io/undertow/server/protocol/framed/AbstractFramedStreamSinkChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/framed/Attic/AbstractFramedStreamSinkChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/framed/AbstractFramedStreamSinkChannel.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/framed/AbstractFramedStreamSinkChannel.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,5 +1,24 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.framed; +import io.undertow.UndertowLogger; import io.undertow.UndertowMessages; import io.undertow.util.ImmediatePooled; import org.xnio.Buffers; @@ -23,7 +42,6 @@ import static org.xnio.Bits.allAreClear; import static org.xnio.Bits.allAreSet; -import static org.xnio.Bits.anyAreClear; import static org.xnio.Bits.anyAreSet; /** @@ -32,41 +50,62 @@ * Thread safety notes: *

    * The general contract is that this channel is only to be used by a single thread at a time. The only exception to this is - * during flush. A flush will only happen when {@link #STATE_READY_FOR_FLUSH} is set, and while this bit is set the buffer + * during flush. A flush will only happen when {@link #readyForFlush} is set, and while this bit is set the buffer * must not be modified. * * @author Stuart Douglas */ public abstract class AbstractFramedStreamSinkChannel, R extends AbstractFramedStreamSourceChannel, S extends AbstractFramedStreamSinkChannel> implements StreamSinkChannel { - private static final Pooled EMPTY_BYTE_BUFFER = new ImmediatePooled(ByteBuffer.allocateDirect(0)); + private static final Pooled EMPTY_BYTE_BUFFER = new ImmediatePooled<>(ByteBuffer.allocateDirect(0)); - private final Pooled buffer; + private Pooled buffer; private final C channel; - private final ChannelListener.SimpleSetter writeSetter = new ChannelListener.SimpleSetter(); - private final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter(); + private final ChannelListener.SimpleSetter writeSetter = new ChannelListener.SimpleSetter<>(); + private final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter<>(); private final Object lock = new Object(); + /** + * the state variable, this must only be access by the thread that 'owns' the channel + */ private volatile int state = 0; - private Pooled header; - private Pooled trailer; + /** + * If this channel is ready for flush, updated by multiple threads. In general it will be set by the thread + * that 'owns' the channel, and cleared by the IO thread + */ + private volatile boolean readyForFlush; - private static final int STATE_BROKEN = 1; - private static final int STATE_READY_FOR_FLUSH = 1 << 1; - private static final int STATE_CLOSED = 1 << 2; - private static final int STATE_ACTIVE = 1 << 3; - private static final int STATE_WRITES_RESUMED = 1 << 4; - private static final int STATE_WRITES_SHUTDOWN = 1 << 5; - private static final int STATE_IN_LISTENER_LOOP = 1 << 6; + /** + * If all the data has been written out and the channel has been fully flushed + */ + private volatile boolean fullyFlushed; /** - * writes are shutdown, data has been written, but flush has not been called + * If the last frame has been queued. + * + * Note that this may not actually be the final frame in some circumstances, e.g. if the final frame + * is two large to fit in the flow control window. In this case the flag may be cleared after flush is complete. */ - private static final int STATE_FULLY_FLUSHED = 1 << 7; - private static final int STATE_FINAL_FRAME_QUEUED = 1 << 8; + private volatile boolean finalFrameQueued; + /** + * If this channel is broken, updated by multiple threads + */ + private volatile boolean broken; + private volatile int waiterCount = 0; + + private SendFrameHeader header; + private Pooled trailer; + + private static final int STATE_CLOSED = 1; + private static final int STATE_WRITES_RESUMED = 1 << 1; + private static final int STATE_WRITES_SHUTDOWN = 1 << 2; + private static final int STATE_IN_LISTENER_LOOP = 1 << 3; + private static final int STATE_FIRST_DATA_WRITTEN = 1 << 4; + + protected AbstractFramedStreamSinkChannel(C channel) { this.channel = channel; this.buffer = channel.getBufferPool().allocate(); @@ -83,27 +122,31 @@ @Override public void suspendWrites() { state &= ~STATE_WRITES_RESUMED; - if (anyAreSet(state, STATE_ACTIVE)) { - channel.suspendWrites(); - } } /** * Returns the header for the current frame. * + * This consists of the frame data, and also an integer specifying how much data is remaining in the buffer. + * If this is non-zero then this method must adjust the buffers limit accordingly. + * + * It is expected that this will be used when limits on the size of a data frame prevent the whole buffer from + * being sent at once. + * + * * @return The header for the current frame, or null */ - final ByteBuffer getFrameHeader() { + final SendFrameHeader getFrameHeader() throws IOException { if (header == null) { header = createFrameHeader(); if (header == null) { - header = EMPTY_BYTE_BUFFER; + header = new SendFrameHeader(0, null); } } - return header.getResource(); + return header; } - protected Pooled createFrameHeader() { + protected SendFrameHeader createFrameHeader() throws IOException{ return null; } @@ -127,110 +170,135 @@ } @Override - public void resumeWrites() { - resumeWrites(false); - } - - @Override public boolean isWriteResumed() { return anyAreSet(state, STATE_WRITES_RESUMED); } @Override public void wakeupWrites() { - resumeWrites(true); + resumeWritesInternal(true); } - void resumeWrites(final boolean wakeup) { + @Override + public void resumeWrites() { + resumeWritesInternal(false); + } + + protected void resumeWritesInternal(boolean wakeup) { + boolean alreadyResumed = anyAreSet(state, STATE_WRITES_RESUMED); + if(!wakeup && alreadyResumed) { + return; + } state |= STATE_WRITES_RESUMED; - if (anyAreSet(state, STATE_ACTIVE)) { - if (wakeup) { - channel.wakeupWrites(); - } else { - channel.resumeWrites(); - } - } else { + if(readyForFlush && !wakeup) { + //we already have data queued to be flushed + return; + } - if (!anyAreSet(state, STATE_IN_LISTENER_LOOP)) { - getIoThread().execute(new Runnable() { + if (!anyAreSet(state, STATE_IN_LISTENER_LOOP)) { + state |= STATE_IN_LISTENER_LOOP; + getIoThread().execute(new Runnable() { - @Override - public void run() { - state |= STATE_IN_LISTENER_LOOP; - try { - do { - ChannelListener listener = getWriteListener(); - if (listener == null || !isWriteResumed()) { - return; - } - ChannelListeners.invokeChannelListener((S) AbstractFramedStreamSinkChannel.this, listener); - //if writes are shutdown or we become active then we stop looping - //we stop when writes are shutdown because we can't flush until we are active - //although we may be flushed as part of a batch - } - while (allAreClear(state, STATE_ACTIVE | STATE_CLOSED | STATE_BROKEN | STATE_READY_FOR_FLUSH) && (anyAreSet(state, STATE_FULLY_FLUSHED) || buffer.getResource().hasRemaining())); - } finally { - state &= ~STATE_IN_LISTENER_LOOP; + int loopCount = 0; + + @Override + public void run() { + try { + ChannelListener listener = getWriteListener(); + if (listener == null || !isWriteResumed()) { + return; } + if(loopCount++ == 100) { + //should never happen + UndertowLogger.ROOT_LOGGER.listenerNotProgressing(); + IoUtils.safeClose(AbstractFramedStreamSinkChannel.this); + return; + } + ChannelListeners.invokeChannelListener((S) AbstractFramedStreamSinkChannel.this, listener); + //if writes are shutdown or we become active then we stop looping + //we stop when writes are shutdown because we can't flush until we are active + //although we may be flushed as part of a batch + + if (allAreSet(state, STATE_WRITES_RESUMED) && allAreClear(state, STATE_CLOSED) && !broken && !readyForFlush && !fullyFlushed) { + getIoThread().execute(this); + } + } finally { + state &= ~STATE_IN_LISTENER_LOOP; } - }); - } + } + }); } + } @Override public void shutdownWrites() throws IOException { + if(anyAreSet(state, STATE_WRITES_SHUTDOWN) || broken ) { + return; + } state |= STATE_WRITES_SHUTDOWN; queueFinalFrame(); } private void queueFinalFrame() throws IOException { - if (allAreClear(state, STATE_READY_FOR_FLUSH | STATE_FINAL_FRAME_QUEUED)) { + if (!readyForFlush && !fullyFlushed && allAreClear(state, STATE_CLOSED) && !broken && !finalFrameQueued) { + readyForFlush = true; buffer.getResource().flip(); - state |= STATE_READY_FOR_FLUSH | STATE_FINAL_FRAME_QUEUED; + state |= STATE_FIRST_DATA_WRITTEN; + finalFrameQueued = true; channel.queueFrame((S) this); } } protected boolean isFinalFrameQueued() { - return anyAreSet(state, STATE_FINAL_FRAME_QUEUED); + return finalFrameQueued; } @Override public void awaitWritable() throws IOException { + if(Thread.currentThread() == getIoThread()) { + throw UndertowMessages.MESSAGES.awaitCalledFromIoThread(); + } synchronized (lock) { - if (anyAreSet(state, STATE_BROKEN | STATE_CLOSED)) { + if (anyAreSet(state, STATE_CLOSED) || broken) { return; } - if (anyAreSet(state, STATE_ACTIVE)) { - channel.awaitWritable(); - } else if (anyAreSet(state, STATE_READY_FOR_FLUSH)) { + if (readyForFlush) { try { - lock.wait(); + waiterCount++; + //we need to re-check after incrementing the waiters count + + if(readyForFlush && !anyAreSet(state, STATE_CLOSED) && !broken) { + lock.wait(); + } } catch (InterruptedException e) { throw new InterruptedIOException(); + } finally { + waiterCount--; } } } } @Override public void awaitWritable(long l, TimeUnit timeUnit) throws IOException { + if(Thread.currentThread() == getIoThread()) { + throw UndertowMessages.MESSAGES.awaitCalledFromIoThread(); + } synchronized (lock) { - if (anyAreSet(state, STATE_BROKEN | STATE_CLOSED)) { + if (anyAreSet(state, STATE_CLOSED) || broken) { return; } - if (anyAreSet(state, STATE_ACTIVE)) { - channel.awaitWritable(l, timeUnit); - } else if (anyAreSet(state, STATE_READY_FOR_FLUSH)) { + if (readyForFlush) { try { - if (anyAreSet(state, STATE_BROKEN | STATE_CLOSED)) { - return; + waiterCount++; + if(readyForFlush && !anyAreSet(state, STATE_CLOSED) && !broken) { + lock.wait(timeUnit.toMillis(l)); } - - lock.wait(timeUnit.toMillis(l)); } catch (InterruptedException e) { throw new InterruptedIOException(); + } finally { + waiterCount--; } } } @@ -242,12 +310,12 @@ } @Override - public ChannelListener.Setter getWriteSetter() { + public ChannelListener.Setter getWriteSetter() { return writeSetter; } @Override - public ChannelListener.Setter getCloseSetter() { + public ChannelListener.Setter getCloseSetter() { return closeSetter; } @@ -263,41 +331,41 @@ @Override public boolean flush() throws IOException { - if (anyAreSet(state, STATE_CLOSED | STATE_BROKEN)) { + if(anyAreSet(state, STATE_CLOSED)) { + return true; + } + if (broken) { throw UndertowMessages.MESSAGES.channelIsClosed(); } - if (anyAreSet(state, STATE_FULLY_FLUSHED)) { + + if (readyForFlush) { + return false; + } + if (fullyFlushed) { state |= STATE_CLOSED; return true; } - if (anyAreSet(state, STATE_WRITES_SHUTDOWN) && anyAreClear(state, STATE_FINAL_FRAME_QUEUED)) { + if (anyAreSet(state, STATE_WRITES_SHUTDOWN) && !finalFrameQueued) { queueFinalFrame(); + return false; } - //we only flush if we are active - if (allAreSet(state, STATE_ACTIVE)) { - channel.flushSenders(); - if (allAreSet(state, STATE_FINAL_FRAME_QUEUED | STATE_FULLY_FLUSHED)) { - state |= STATE_CLOSED; - return true; - } - } - if (allAreSet(state, STATE_WRITES_SHUTDOWN)) { + if(anyAreSet(state, STATE_WRITES_SHUTDOWN)) { return false; } - return true; //todo: should this return true of false? + if(buffer != null && buffer.getResource().position() > 0) { + handleBufferFull(); + return !readyForFlush; + } + return true; } @Override public long write(ByteBuffer[] srcs, int offset, int length) throws IOException { int state = this.state; - if (anyAreSet(state, STATE_READY_FOR_FLUSH)) { - flush(); - state = this.state; - } - if (anyAreSet(state, STATE_READY_FOR_FLUSH)) { + if (readyForFlush) { return 0; //we can't do anything, we are waiting for a flush } - if (anyAreSet(state, STATE_BROKEN | STATE_CLOSED | STATE_WRITES_SHUTDOWN)) { + if (anyAreSet(state, STATE_CLOSED | STATE_WRITES_SHUTDOWN) || broken) { throw UndertowMessages.MESSAGES.channelIsClosed(); } long copied = Buffers.copy(this.buffer.getResource(), srcs, offset, length); @@ -315,14 +383,10 @@ @Override public int write(ByteBuffer src) throws IOException { int state = this.state; - if (anyAreSet(state, STATE_READY_FOR_FLUSH)) { - flush(); - state = this.state; - } - if (anyAreSet(state, STATE_READY_FOR_FLUSH)) { + if (readyForFlush) { return 0; //we can't do anything, we are waiting for a flush } - if (anyAreSet(state, STATE_BROKEN | STATE_CLOSED | STATE_WRITES_SHUTDOWN)) { + if (anyAreSet(state, STATE_CLOSED | STATE_WRITES_SHUTDOWN) || broken) { throw UndertowMessages.MESSAGES.channelIsClosed(); } int copied = Buffers.copy(this.buffer.getResource(), src); @@ -348,14 +412,12 @@ } private void handleBufferFull() throws IOException { - if (allAreClear(state, STATE_READY_FOR_FLUSH)) { + if (!readyForFlush) { + readyForFlush = true; getBuffer().flip(); - state |= STATE_READY_FOR_FLUSH; + state |= STATE_FIRST_DATA_WRITTEN; channel.queueFrame((S) this); } - if (anyAreSet(state, STATE_ACTIVE)) { - channel.flushSenders(); - } } /** @@ -368,7 +430,7 @@ * as it may be written out by another thread. */ public boolean isReadyForFlush() { - return anyAreSet(state, STATE_READY_FOR_FLUSH); + return readyForFlush; } /** @@ -385,11 +447,46 @@ @Override public void close() throws IOException { - state |= STATE_CLOSED; - buffer.free(); - //TODO: need to think about this more - //if the frame has had nothing written out it should not break the parent channel - channel.close(); + if(fullyFlushed || anyAreSet(state, STATE_CLOSED)) { + return; + } + try { + state |= STATE_CLOSED; + buffer.free(); + buffer = null; + if (header != null && header.getByteBuffer() != null) { + header.getByteBuffer().free(); + } + if (trailer != null) { + trailer.free(); + } + if (anyAreSet(state, STATE_FIRST_DATA_WRITTEN)) { + channelForciblyClosed(); + } + //we need to wake up/invoke the write listener + if (isWriteResumed()) { + ChannelListeners.invokeChannelListener(getIoThread(), this, (ChannelListener) getWriteListener()); + } + wakeupWrites(); + } finally { + wakeupWaiters(); + } + } + + /** + * Called when a channel has been forcibly closed, and data (frames) have already been written. + * + * The action this should take is protocol dependent, e.g. for SPDY a RST_STREAM should be sent, + * for websockets the channel should be closed. + * + * By default this will just close the underlying channel + * + * @throws IOException + */ + protected void channelForciblyClosed() throws IOException { + if(isFirstDataWritten()) { + getChannel().markWritesBroken(null); + } wakeupWaiters(); } @@ -413,92 +510,110 @@ } /** - * Method that is invoked when a frame has been fully flushed + * Method that is invoked when a frame has been fully flushed. This method is only invoked by the IO thread */ final void flushComplete() throws IOException { try { - state &= ~(STATE_READY_FOR_FLUSH | STATE_ACTIVE); - boolean channelClosed = anyAreSet(state, STATE_FINAL_FRAME_QUEUED); + int remaining = header.getRemainingInBuffer(); + boolean finalFrame = finalFrameQueued; + boolean channelClosed = finalFrame && remaining == 0 && !header.isAnotherFrameRequired(); + if(remaining > 0) { + buffer.getResource().limit(buffer.getResource().limit() + remaining); + if(finalFrame) { + //we clear the final frame flag, as it could not actually be written out + //note that we don't attempt to requeue, as whatever stopped it from being written will likely still + //be an issue + this.finalFrameQueued = false; + } + } else if(header.isAnotherFrameRequired()) { + this.finalFrameQueued = false; + } if (channelClosed) { - state |= STATE_FULLY_FLUSHED; + fullyFlushed = true; buffer.free(); + buffer = null; } else { - buffer.getResource().clear(); + buffer.getResource().compact(); } - if(header != null) { - header.free(); + if (header.getByteBuffer() != null) { + header.getByteBuffer().free(); } trailer.free(); header = null; trailer = null; - final ChannelListener closeListener = this.closeSetter.get(); - if (channelClosed && closeListener != null) { - getIoThread().execute(new Runnable() { - @Override - public void run() { - ChannelListeners.invokeChannelListener((S) AbstractFramedStreamSinkChannel.this, closeListener); - } - }); - } + readyForFlush = false; if (isWriteResumed() && !channelClosed) { wakeupWrites(); + } else if(isWriteResumed()) { + //we need to execute the write listener one last time + //we need to dispatch it back to the IO thread, so we don't invoke it recursivly + ChannelListeners.invokeChannelListener(getIoThread(), (S)this, getWriteListener()); } - handleFlushComplete(); + + final ChannelListener closeListener = this.closeSetter.get(); + if (channelClosed && closeListener != null) { + ChannelListeners.invokeChannelListener(getIoThread(), (S) AbstractFramedStreamSinkChannel.this, closeListener); + } + handleFlushComplete(channelClosed); } finally { wakeupWaiters(); } } - protected void handleFlushComplete() { + protected void handleFlushComplete(boolean finalFrame) { } + protected boolean isFirstDataWritten() { + return anyAreSet(state, STATE_FIRST_DATA_WRITTEN); + } + public void markBroken() { - this.state |= STATE_BROKEN; - wakeupWrites(); - wakeupWaiters(); - if (isWriteResumed()) { - ChannelListener writeListener = this.writeSetter.get(); - if (writeListener != null) { - ChannelListeners.invokeChannelListener(getIoThread(), (S) this, writeListener); + this.broken = true; + try { + wakeupWrites(); + wakeupWaiters(); + if (isWriteResumed()) { + ChannelListener writeListener = this.writeSetter.get(); + if (writeListener != null) { + ChannelListeners.invokeChannelListener(getIoThread(), (S) this, writeListener); + } } + ChannelListener closeListener = this.closeSetter.get(); + if (closeListener != null) { + ChannelListeners.invokeChannelListener(getIoThread(), (S) this, closeListener); + } + } finally { + if(header != null && header.getByteBuffer() != null) { + header.getByteBuffer().free(); + } + if(trailer != null) { + trailer.free(); + } + if(buffer != null) { + buffer.free(); + } } - ChannelListener closeListener = this.closeSetter.get(); - if (closeListener != null) { - ChannelListeners.invokeChannelListener(getIoThread(), (S) this, closeListener); - } } ChannelListener getWriteListener() { return writeSetter.get(); } - /** - * Method than is called when the sender is the first sender in the queued channel. This can be called from any thread, - * and may be called even if the channel is already activated. - */ - void activated() { - if (allAreClear(state, STATE_ACTIVE)) { - state |= STATE_ACTIVE; - if (isWriteResumed()) { - channel.resumeWrites(); + private void wakeupWaiters() { + if(waiterCount > 0) { + synchronized (lock) { + lock.notifyAll(); } - wakeupWaiters(); } } - private void wakeupWaiters() { - synchronized (lock) { - lock.notifyAll(); - } - } - - protected boolean isActivated() { - return anyAreSet(state, STATE_ACTIVE); - } - public C getChannel() { return channel; } + + public boolean isBroken() { + return broken; + } } Index: 3rdParty_sources/undertow/io/undertow/server/protocol/framed/AbstractFramedStreamSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/framed/Attic/AbstractFramedStreamSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/framed/AbstractFramedStreamSourceChannel.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/framed/AbstractFramedStreamSourceChannel.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,8 +1,39 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.framed; +import static org.xnio.Bits.allAreClear; +import static org.xnio.Bits.allAreSet; +import static org.xnio.Bits.anyAreSet; + +import java.io.IOException; +import java.io.InterruptedIOException; +import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; +import java.nio.channels.FileChannel; +import java.util.Deque; +import java.util.LinkedList; +import java.util.concurrent.TimeUnit; import org.xnio.Buffers; import org.xnio.ChannelListener; import org.xnio.ChannelListeners; +import org.xnio.IoUtils; import org.xnio.Option; import org.xnio.Pooled; import org.xnio.XnioExecutor; @@ -11,17 +42,8 @@ import org.xnio.channels.StreamSinkChannel; import org.xnio.channels.StreamSourceChannel; -import java.io.IOException; -import java.io.InterruptedIOException; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.util.Deque; -import java.util.LinkedList; -import java.util.concurrent.TimeUnit; +import io.undertow.UndertowMessages; -import static org.xnio.Bits.allAreClear; -import static org.xnio.Bits.anyAreSet; - /** * Source channel, used to receive framed messages. * @@ -32,13 +54,8 @@ private final ChannelListener.SimpleSetter readSetter = new ChannelListener.SimpleSetter(); private final ChannelListener.SimpleSetter closeSetter = new ChannelListener.SimpleSetter(); - /** - * The underlying channel. Should not be used directly unless the data - * buffer is null and {@link #frameDataRemaining} is non-zero. - */ - private final StreamSourceChannel underlying; - private final AbstractFramedChannel framedChannel; - private final Deque pendingFrameData = new LinkedList(); + private final C framedChannel; + private final Deque pendingFrameData = new LinkedList<>(); private int state = 0; @@ -47,6 +64,7 @@ private static final int STATE_CLOSED = 1 << 3; private static final int STATE_LAST_FRAME = 1 << 4; private static final int STATE_IN_LISTENER_LOOP = 1 << 5; + private static final int STATE_STREAM_BROKEN = 1 << 6; /** @@ -63,19 +81,27 @@ private int waiters; private volatile boolean waitingForFrame; private int readFrameCount = 0; + private long maxStreamSize = -1; + private long currentStreamSize; - public AbstractFramedStreamSourceChannel(AbstractFramedChannel framedChannel) { - this.underlying = framedChannel.getSourceChannel(); + public AbstractFramedStreamSourceChannel(C framedChannel) { this.framedChannel = framedChannel; this.waitingForFrame = true; } - public AbstractFramedStreamSourceChannel(AbstractFramedChannel framedChannel, Pooled data, long frameDataRemaining) { - this.underlying = framedChannel.getSourceChannel(); + public AbstractFramedStreamSourceChannel(C framedChannel, Pooled data, long frameDataRemaining) { this.framedChannel = framedChannel; this.waitingForFrame = data == null && frameDataRemaining <= 0; this.data = data; this.frameDataRemaining = frameDataRemaining; + this.currentStreamSize = frameDataRemaining; + if (data != null) { + if (!data.getResource().hasRemaining()) { + data.free(); + this.data = null; + this.waitingForFrame = frameDataRemaining <= 0; + } + } } @Override @@ -102,14 +128,6 @@ } finally { data.getResource().limit(old); } - } else if (frameDataRemaining > 0) { - long toTransfer = count; - if (toTransfer > frameDataRemaining) { - toTransfer = frameDataRemaining; - } - long written = underlying.transferTo(position, toTransfer, target); - frameDataRemaining -= written; - return written; } return 0; } finally { @@ -124,38 +142,59 @@ } beforeRead(); if (waitingForFrame) { + throughBuffer.position(throughBuffer.limit()); return 0; } try { if (frameDataRemaining == 0 && anyAreSet(state, STATE_LAST_FRAME)) { return -1; - } else if (data != null) { + } else if (data != null && data.getResource().hasRemaining()) { int old = data.getResource().limit(); try { if (count < data.getResource().remaining()) { data.getResource().limit((int) (data.getResource().position() + count)); } int written = streamSinkChannel.write(data.getResource()); frameDataRemaining -= written; + if(data.getResource().hasRemaining()) { + //we can still add more data + //stick it it throughbuffer, otherwise transfer code will continue to attempt to use this method + throughBuffer.clear(); + frameDataRemaining -= Buffers.copy(throughBuffer, data.getResource()); + throughBuffer.flip(); + } else { + throughBuffer.position(throughBuffer.limit()); + } return written; } finally { data.getResource().limit(old); } - } else if (frameDataRemaining > 0) { - long toTransfer = count; - if (toTransfer > frameDataRemaining) { - toTransfer = frameDataRemaining; - } - long written = underlying.transferTo(toTransfer, throughBuffer, streamSinkChannel); - frameDataRemaining -= written; - return written; + } else { + throughBuffer.position(throughBuffer.limit()); } return 0; } finally { exitRead(); } } + public long getMaxStreamSize() { + return maxStreamSize; + } + + public void setMaxStreamSize(long maxStreamSize) { + this.maxStreamSize = maxStreamSize; + if(maxStreamSize > 0) { + if(maxStreamSize < currentStreamSize) { + handleStreamTooLarge(); + } + } + } + + private void handleStreamTooLarge() { + IoUtils.safeClose(this); + } + @Override public void suspendReads() { state &= ~STATE_READS_RESUMED; @@ -176,7 +215,7 @@ @Override public void resumeReads() { - resumeReads(false); + resumeReadsInternal(false); } @Override @@ -186,25 +225,24 @@ @Override public void wakeupReads() { - resumeReads(true); + resumeReadsInternal(true); } - void resumeReads(final boolean wakeup) { + /** + * For this class there is no difference between a resume and a wakeup + */ + void resumeReadsInternal(boolean wakeup) { + boolean alreadyResumed = anyAreSet(state, STATE_READS_RESUMED); state |= STATE_READS_RESUMED; - if (data == null && frameDataRemaining > 0) { - if (wakeup) { - underlying.wakeupReads(); - } else { - underlying.resumeReads(); - } - } else { + if(!alreadyResumed || wakeup) { if (!anyAreSet(state, STATE_IN_LISTENER_LOOP)) { + state |= STATE_IN_LISTENER_LOOP; getIoThread().execute(new Runnable() { @Override public void run() { - state |= STATE_IN_LISTENER_LOOP; try { + boolean moreData; do { ChannelListener listener = getReadListener(); if (listener == null || !isReadResumed()) { @@ -214,7 +252,8 @@ //if writes are shutdown or we become active then we stop looping //we stop when writes are shutdown because we can't flush until we are active //although we may be flushed as part of a batch - } while (allAreClear(state, STATE_CLOSED) && frameDataRemaining > 0); + moreData = (frameDataRemaining > 0 && data != null) || !pendingFrameData.isEmpty(); + } while (allAreSet(state, STATE_READS_RESUMED) && allAreClear(state, STATE_CLOSED) && moreData); } finally { state &= ~STATE_IN_LISTENER_LOOP; } @@ -235,25 +274,30 @@ protected void lastFrame() { state |= STATE_LAST_FRAME; + waitingForFrame = false; + if(data == null && pendingFrameData.isEmpty() && frameDataRemaining == 0) { + state |= STATE_DONE | STATE_CLOSED; + getFramedChannel().notifyFrameReadComplete(this); + getFramedChannel().notifyClosed(this); + } } @Override public void awaitReadable() throws IOException { - if (data == null) { - if (frameDataRemaining > 0) { - underlying.awaitReadable(); - } else { - synchronized (lock) { - if (data == null) { - try { - waiters++; - lock.wait(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new InterruptedIOException(); - } finally { - waiters--; - } + if(Thread.currentThread() == getIoThread()) { + throw UndertowMessages.MESSAGES.awaitCalledFromIoThread(); + } + if (data == null && pendingFrameData.isEmpty()) { + synchronized (lock) { + if (data == null && pendingFrameData.isEmpty()) { + try { + waiters++; + lock.wait(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new InterruptedIOException(); + } finally { + waiters--; } } } @@ -262,53 +306,69 @@ @Override public void awaitReadable(long l, TimeUnit timeUnit) throws IOException { + if(Thread.currentThread() == getIoThread()) { + throw UndertowMessages.MESSAGES.awaitCalledFromIoThread(); + } if (data == null) { - if (frameDataRemaining > 0) { - underlying.awaitReadable(l, timeUnit); - } else { - synchronized (lock) { - if (data == null) { - try { - waiters++; - lock.wait(timeUnit.toMillis(l)); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new InterruptedIOException(); - } finally { - waiters--; - } + synchronized (lock) { + if (data == null) { + try { + waiters++; + lock.wait(timeUnit.toMillis(l)); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new InterruptedIOException(); + } finally { + waiters--; } } } } } + /** + * Called when data has been read from the underlying channel. + * + * @param headerData The frame header data. This may be null if the data is part of a an existing frame + * @param frameData The frame data + */ void dataReady(FrameHeaderData headerData, Pooled frameData) { + if(anyAreSet(state, STATE_STREAM_BROKEN)) { + frameData.free(); + return; + } synchronized (lock) { - if (this.frameDataRemaining == 0 && pendingFrameData.isEmpty()) { - this.data = frameData; - this.frameDataRemaining = headerData.getFrameLength(); + boolean newData = pendingFrameData.isEmpty(); + this.pendingFrameData.add(new FrameData(headerData, frameData)); + if (newData) { if (waiters > 0) { lock.notifyAll(); } - handleHeaderData(headerData); - if (anyAreSet(state, STATE_READS_RESUMED)) { - resumeReads(false); - } - waitingForFrame = false; - } else { - this.pendingFrameData.add(new FrameData(headerData, frameData)); } + waitingForFrame = false; } + if (anyAreSet(state, STATE_READS_RESUMED)) { + resumeReadsInternal(true); + } + if(headerData != null) { + currentStreamSize += headerData.getFrameLength(); + if(maxStreamSize > 0 && currentStreamSize > maxStreamSize) { + handleStreamTooLarge(); + } + } } + protected long handleFrameData(Pooled frameData, long frameDataRemaining) { + return frameDataRemaining; + } + protected void handleHeaderData(FrameHeaderData headerData) { } @Override public XnioExecutor getReadThread() { - return underlying.getIoThread(); + return framedChannel.getIoThread(); } @Override @@ -323,12 +383,12 @@ @Override public XnioWorker getWorker() { - return underlying.getWorker(); + return framedChannel.getWorker(); } @Override public XnioIoThread getIoThread() { - return underlying.getIoThread(); + return framedChannel.getIoThread(); } @Override @@ -373,35 +433,6 @@ } finally { data.getResource().limit(old); } - } else if (frameDataRemaining > 0) { - long toTransfer = Buffers.remaining(dsts, offset, length); - if (toTransfer > frameDataRemaining) { - toTransfer = frameDataRemaining; - } - int lim; - // The total amount of buffer space discovered so far. - long t = 0L; - for (int i = 0; i < length; i++) { - final ByteBuffer buffer = dsts[i + offset]; - // Grow the discovered buffer space by the remaining size of the current buffer. - // We want to capture the limit so we calculate "remaining" ourselves. - t += (lim = buffer.limit()) - buffer.position(); - if (t > toTransfer) { - // only read up to this point, and trim the last buffer by the number of extra bytes - buffer.limit(lim - (int) (t - toTransfer)); - try { - long read = underlying.read(dsts, offset, i + 1); - frameDataRemaining -= read; - return read; - } finally { - // restore the original limit - buffer.limit(lim); - } - } - } - long read = underlying.read(dsts, offset, length); - frameDataRemaining -= read; - return read; } return 0; } finally { @@ -419,7 +450,7 @@ if (anyAreSet(state, STATE_DONE)) { return -1; } - if(!dst.hasRemaining()) { + if (!dst.hasRemaining()) { return 0; } beforeRead(); @@ -444,33 +475,36 @@ } finally { data.getResource().limit(old); } - } else if (frameDataRemaining > 0) { - int old = dst.limit(); - try { - if (dst.remaining() > frameDataRemaining) { - dst.limit((int) (dst.position() + frameDataRemaining)); - } - int written = underlying.read(dst); - frameDataRemaining -= written; - return written; - } finally { - dst.limit(old); - } } return 0; } finally { exitRead(); } } - private void beforeRead() { - if (frameDataRemaining == 0) { + private void beforeRead() throws ClosedChannelException { + if (anyAreSet(state, STATE_STREAM_BROKEN)) { + throw UndertowMessages.MESSAGES.channelIsClosed(); + } + if (data == null) { synchronized (lock) { FrameData pending = pendingFrameData.poll(); if (pending != null) { - this.data = pending.getFrameData(); - this.frameDataRemaining = pending.getFrameHeaderData().getFrameLength(); - handleHeaderData(pending.getFrameHeaderData()); + Pooled frameData = pending.getFrameData(); + boolean hasData = true; + if(frameData.getResource().hasRemaining()) { + this.data = frameData; + } else { + frameData.free(); + hasData = false; + } + if (pending.getFrameHeaderData() != null) { + this.frameDataRemaining = pending.getFrameHeaderData().getFrameLength(); + handleHeaderData(pending.getFrameHeaderData()); + } + if(hasData) { + this.frameDataRemaining = handleFrameData(frameData, frameDataRemaining); + } } } } @@ -482,20 +516,23 @@ data = null; } if (frameDataRemaining == 0) { - synchronized (lock) { - readFrameCount++; - if (pendingFrameData.isEmpty()) { - try { + try { + synchronized (lock) { + readFrameCount++; + if (pendingFrameData.isEmpty()) { if (anyAreSet(state, STATE_LAST_FRAME)) { state |= STATE_DONE; + getFramedChannel().notifyClosed(this); complete(); } else { waitingForFrame = true; } - } finally { - framedChannel.notifyFrameReadComplete(this); } } + } finally { + if (pendingFrameData.isEmpty()) { + framedChannel.notifyFrameReadComplete(this); + } } } } @@ -507,24 +544,60 @@ @Override public void close() throws IOException { + if(anyAreSet(state, STATE_CLOSED)) { + return; + } state |= STATE_CLOSED; - if (allAreClear(state, STATE_DONE)) { - framedChannel.markReadsBroken(null); + if (allAreClear(state, STATE_DONE | STATE_LAST_FRAME)) { + state |= STATE_STREAM_BROKEN; + getFramedChannel().notifyClosed(this); + channelForciblyClosed(); } - if(data != null) { + if (data != null) { data.free(); + data = null; } - ChannelListeners.invokeChannelListener(this, (ChannelListener>) closeSetter.get()); + while (!pendingFrameData.isEmpty()) { + pendingFrameData.poll().frameData.free(); + } + ChannelListeners.invokeChannelListener(this, (ChannelListener>) closeSetter.get()); } - protected AbstractFramedChannel getFramedChannel() { + protected void channelForciblyClosed() { + //TODO: what should be the default action? + //we can probably just ignore it, as it does not affect the underlying protocol + } + + protected C getFramedChannel() { return framedChannel; } protected int getReadFrameCount() { return readFrameCount; } + /** + * Called when this stream is no longer valid. Reads from the stream will result + * in an exception. + */ + protected synchronized void markStreamBroken() { + state |= STATE_STREAM_BROKEN; + if(data != null) { + data.free(); + data = null; + } + for(FrameData frame : pendingFrameData) { + frame.frameData.free(); + } + pendingFrameData.clear(); + if(isReadResumed()) { + resumeReadsInternal(true); + } + if (waiters > 0) { + lock.notifyAll(); + } + } + private class FrameData { private final FrameHeaderData frameHeaderData; Index: 3rdParty_sources/undertow/io/undertow/server/protocol/framed/FrameHeaderData.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/framed/Attic/FrameHeaderData.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/framed/FrameHeaderData.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/framed/FrameHeaderData.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.framed; /** Index: 3rdParty_sources/undertow/io/undertow/server/protocol/framed/FramePriority.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/framed/Attic/FramePriority.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/framed/FramePriority.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/framed/FramePriority.java 25 Nov 2014 10:46:48 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.framed; import java.util.Deque; @@ -35,6 +53,9 @@ * If frames in the held frame queue are now eligible to be sent they can be added * to the pending frames queue. * + * Note that if the protocol has explicitly asked for the held frames to be recalculated + * then the added frame may be null. + * * @param addedFrame The newly added frame * @param pendingFrames The pending frame queue * @param holdFrames The held frame queue Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/protocol/framed/SendFrameHeader.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/protocol/http/AlpnOpenListener.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpAttachments.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/http/Attic/HttpAttachments.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpAttachments.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpAttachments.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.http; import io.undertow.util.AttachmentKey; Index: 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpContinue.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/http/Attic/HttpContinue.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpContinue.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpContinue.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,7 +1,26 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.http; import io.undertow.UndertowMessages; import io.undertow.io.IoCallback; +import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.util.Headers; import org.xnio.ChannelExceptionHandler; @@ -33,7 +52,7 @@ * @return true if the server needs to send a continue response */ public static boolean requiresContinueResponse(final HttpServerExchange exchange) { - if (!exchange.isHttp11()) { + if (!exchange.isHttp11() || exchange.isResponseStarted()) { return false; } if (exchange.getConnection() instanceof HttpServerConnection) { @@ -62,7 +81,8 @@ */ public static void sendContinueResponse(final HttpServerExchange exchange, final IoCallback callback) { if (!exchange.isResponseChannelAvailable()) { - throw UndertowMessages.MESSAGES.responseChannelAlreadyProvided(); + callback.onException(exchange, null, UndertowMessages.MESSAGES.cannotSendContinueResponse()); + return; } internalSendContinueResponse(exchange, callback); } @@ -73,9 +93,9 @@ * @param exchange The exchange * @return The response sender */ - public static ContinueResponseSender createResponseSender(final HttpServerExchange exchange) { + public static ContinueResponseSender createResponseSender(final HttpServerExchange exchange) throws IOException { if (!exchange.isResponseChannelAvailable()) { - throw UndertowMessages.MESSAGES.responseChannelAlreadyProvided(); + throw UndertowMessages.MESSAGES.cannotSendContinueResponse(); } HttpServerExchange newExchange = exchange.getConnection().sendOutOfBandResponse(exchange); @@ -113,7 +133,7 @@ */ public static void sendContinueResponseBlocking(final HttpServerExchange exchange) throws IOException { if (!exchange.isResponseChannelAvailable()) { - throw UndertowMessages.MESSAGES.responseChannelAlreadyProvided(); + throw UndertowMessages.MESSAGES.cannotSendContinueResponse(); } HttpServerExchange newExchange = exchange.getConnection().sendOutOfBandResponse(exchange); newExchange.setResponseCode(100); @@ -143,23 +163,31 @@ try { responseChannel.shutdownWrites(); if (!responseChannel.flush()) { - exchange.dispatch(); responseChannel.getWriteSetter().set(ChannelListeners.flushingChannelListener( new ChannelListener() { @Override public void handleEvent(StreamSinkChannel channel) { - callback.onComplete(exchange, null); channel.suspendWrites(); + exchange.dispatch(new HttpHandler() { + @Override + public void handleRequest(HttpServerExchange exchange) throws Exception { + callback.onComplete(exchange, null); + } + }); } }, new ChannelExceptionHandler() { @Override - public void handleException(Channel channel, IOException e) { - callback.onException(exchange, null, e); - } - } - )); - responseChannel.resumeWrites(); - } else { + public void handleException(Channel channel, final IOException e) { + exchange.dispatch(new HttpHandler() { + @Override + public void handleRequest(HttpServerExchange exchange) throws Exception { + callback.onException(exchange, null, e); + } + }); + }})); + responseChannel.resumeWrites(); + exchange.dispatch(); + }else { callback.onComplete(exchange, null); } } catch (IOException e) { Index: 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpOpenListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/http/Attic/HttpOpenListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpOpenListener.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpOpenListener.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,26 +9,28 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.protocol.http; import io.undertow.UndertowLogger; import io.undertow.UndertowMessages; +import io.undertow.UndertowOptions; import io.undertow.conduits.ReadTimeoutStreamSourceConduit; import io.undertow.conduits.WriteTimeoutStreamSinkConduit; +import io.undertow.server.DelegateOpenListener; import io.undertow.server.HttpHandler; -import io.undertow.server.OpenListener; import org.xnio.ChannelListener; import org.xnio.IoUtils; import org.xnio.OptionMap; import org.xnio.Options; import org.xnio.Pool; +import org.xnio.Pooled; import org.xnio.StreamConnection; import java.io.IOException; @@ -40,7 +42,7 @@ * * @author David M. Lloyd */ -public final class HttpOpenListener implements ChannelListener, OpenListener { +public final class HttpOpenListener implements ChannelListener, DelegateOpenListener { private final Pool bufferPool; private final int bufferSize; @@ -51,32 +53,60 @@ private volatile HttpRequestParser parser; + @Deprecated public HttpOpenListener(final Pool pool, final int bufferSize) { - this(pool, OptionMap.EMPTY, bufferSize); + this(pool, OptionMap.EMPTY); } + @Deprecated public HttpOpenListener(final Pool pool, final OptionMap undertowOptions, final int bufferSize) { + this(pool, undertowOptions); + } + + public HttpOpenListener(final Pool pool) { + this(pool, OptionMap.EMPTY); + } + + public HttpOpenListener(final Pool pool, final OptionMap undertowOptions) { this.undertowOptions = undertowOptions; this.bufferPool = pool; - this.bufferSize = bufferSize; + Pooled buf = pool.allocate(); + this.bufferSize = buf.getResource().remaining(); + buf.free(); parser = HttpRequestParser.instance(undertowOptions); } - public void handleEvent(final StreamConnection channel) { + @Override + public void handleEvent(StreamConnection channel) { + handleEvent(channel, null); + } + @Override + public void handleEvent(final StreamConnection channel, Pooled buffer) { if (UndertowLogger.REQUEST_LOGGER.isTraceEnabled()) { UndertowLogger.REQUEST_LOGGER.tracef("Opened connection with %s", channel.getPeerAddress()); } //set read and write timeouts try { Integer readTimeout = channel.getOption(Options.READ_TIMEOUT); + Integer idleTimeout = undertowOptions.get(UndertowOptions.IDLE_TIMEOUT); + if ((readTimeout == null || readTimeout <= 0) && idleTimeout != null) { + readTimeout = idleTimeout; + } else if (readTimeout != null && idleTimeout != null && idleTimeout > 0) { + readTimeout = Math.min(readTimeout, idleTimeout); + } if (readTimeout != null && readTimeout > 0) { - channel.getSourceChannel().setConduit(new ReadTimeoutStreamSourceConduit(channel.getSourceChannel().getConduit(), channel)); + channel.getSourceChannel().setConduit(new ReadTimeoutStreamSourceConduit(channel.getSourceChannel().getConduit(), channel, this)); } Integer writeTimeout = channel.getOption(Options.WRITE_TIMEOUT); - if (writeTimeout != 0 && writeTimeout > 0) { - channel.getSinkChannel().setConduit(new WriteTimeoutStreamSinkConduit(channel.getSinkChannel().getConduit(), channel)); + if ((writeTimeout == null || writeTimeout <= 0) && idleTimeout != null) { + writeTimeout = idleTimeout; + } else if (writeTimeout != null && idleTimeout != null && idleTimeout > 0) { + writeTimeout = Math.min(writeTimeout, idleTimeout); } + if (writeTimeout != null && writeTimeout > 0) { + channel.getSinkChannel().setConduit(new WriteTimeoutStreamSinkConduit(channel.getSinkChannel().getConduit(), channel, this)); + } } catch (IOException e) { IoUtils.safeClose(channel); UndertowLogger.REQUEST_IO_LOGGER.ioException(e); @@ -86,6 +116,14 @@ HttpServerConnection connection = new HttpServerConnection(channel, bufferPool, rootHandler, undertowOptions, bufferSize); HttpReadListener readListener = new HttpReadListener(connection, parser); + if(buffer != null) { + if(buffer.getResource().hasRemaining()) { + connection.setExtraBytes(buffer); + } else { + buffer.free(); + } + } + connection.setReadListener(readListener); readListener.newRequest(); channel.getSourceChannel().setReadListener(readListener); Index: 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpReadListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/http/Attic/HttpReadListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpReadListener.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpReadListener.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.protocol.http; @@ -23,13 +23,17 @@ import io.undertow.conduits.ReadDataStreamSourceConduit; import io.undertow.server.Connectors; import io.undertow.server.HttpServerExchange; +import io.undertow.server.protocol.ParseTimeoutUpdater; +import io.undertow.util.ClosingChannelExceptionHandler; import io.undertow.util.StringWriteChannelListener; import org.xnio.ChannelListener; +import org.xnio.ChannelListeners; import org.xnio.IoUtils; import org.xnio.Pooled; import org.xnio.StreamConnection; import org.xnio.channels.StreamSinkChannel; import org.xnio.channels.StreamSourceChannel; +import org.xnio.conduits.ConduitStreamSinkChannel; import org.xnio.conduits.ConduitStreamSourceChannel; import java.io.IOException; @@ -64,18 +68,31 @@ private static final AtomicIntegerFieldUpdater requestStateUpdater = AtomicIntegerFieldUpdater.newUpdater(HttpReadListener.class, "requestState"); + private ParseTimeoutUpdater parseTimeoutUpdater; + HttpReadListener(final HttpServerConnection connection, final HttpRequestParser parser) { this.connection = connection; this.parser = parser; this.maxRequestSize = connection.getUndertowOptions().get(UndertowOptions.MAX_HEADER_SIZE, UndertowOptions.DEFAULT_MAX_HEADER_SIZE); - this.maxEntitySize = connection.getUndertowOptions().get(UndertowOptions.MAX_ENTITY_SIZE, 0); + this.maxEntitySize = connection.getUndertowOptions().get(UndertowOptions.MAX_ENTITY_SIZE, UndertowOptions.DEFAULT_MAX_ENTITY_SIZE); this.recordRequestStartTime = connection.getUndertowOptions().get(UndertowOptions.RECORD_REQUEST_START_TIME, false); + int requestParseTimeout = connection.getUndertowOptions().get(UndertowOptions.REQUEST_PARSE_TIMEOUT, -1); + int requestIdleTimeout = connection.getUndertowOptions().get(UndertowOptions.NO_REQUEST_TIMEOUT, -1); + if(requestIdleTimeout < 0 && requestParseTimeout < 0) { + this.parseTimeoutUpdater = null; + } else { + this.parseTimeoutUpdater = new ParseTimeoutUpdater(connection, requestParseTimeout, requestIdleTimeout); + connection.addCloseListener(parseTimeoutUpdater); + } } public void newRequest() { state.reset(); read = 0; httpServerExchange = new HttpServerExchange(connection, maxEntitySize); + if(parseTimeoutUpdater != null) { + parseTimeoutUpdater.connectionIdle(); + } } public void handleEvent(final ConduitStreamSourceChannel channel) { @@ -99,13 +116,13 @@ return; } - final Pooled pooled = existing == null ? connection.getBufferPool().allocate() : existing; final ByteBuffer buffer = pooled.getResource(); boolean free = true; try { int res; + boolean bytesRead = false; do { if (existing == null) { buffer.clear(); @@ -121,8 +138,13 @@ } if (res <= 0) { + if(bytesRead && parseTimeoutUpdater != null) { + parseTimeoutUpdater.failedParse(); + } handleFailedRead(channel, res); return; + } else { + bytesRead = true; } if (existing != null) { existing = null; @@ -143,6 +165,9 @@ return; } } while (!state.isComplete()); + if(parseTimeoutUpdater != null) { + parseTimeoutUpdater.requestStarted(); + } final HttpServerExchange httpServerExchange = this.httpServerExchange; httpServerExchange.setRequestScheme(connection.getSslSession() != null ? "https" : "http"); @@ -268,7 +293,22 @@ if (connection.getExtraBytes() != null) { connection.getChannel().getSourceChannel().setConduit(new ReadDataStreamSourceConduit(connection.getChannel().getSourceChannel().getConduit(), connection)); } - connection.getUpgradeListener().handleUpgrade(connection.getChannel(), exchange); + try { + if (!connection.getChannel().getSinkChannel().flush()) { + connection.getChannel().getSinkChannel().setWriteListener(ChannelListeners.flushingChannelListener(new ChannelListener() { + @Override + public void handleEvent(ConduitStreamSinkChannel conduitStreamSinkChannel) { + connection.getUpgradeListener().handleUpgrade(connection.getChannel(), exchange); + } + }, new ClosingChannelExceptionHandler(connection))); + connection.getChannel().getSinkChannel().resumeWrites(); + return; + } + connection.getUpgradeListener().handleUpgrade(connection.getChannel(), exchange); + } catch (IOException e) { + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); + IoUtils.safeClose(connection); + } } } Index: 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpRequestParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/http/Attic/HttpRequestParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpRequestParser.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpRequestParser.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.protocol.http; @@ -182,7 +182,7 @@ public static final HttpRequestParser instance(final OptionMap options) { try { - final Class cls = HttpRequestParser.class.getClassLoader().loadClass(HttpRequestParser.class.getName() + "$$generated"); + final Class cls = Class.forName(HttpRequestParser.class.getName() + "$$generated", false, HttpRequestParser.class.getClassLoader()); Constructor ctor = cls.getConstructor(OptionMap.class); return (HttpRequestParser) ctor.newInstance(options); @@ -342,7 +342,7 @@ boolean urlDecodeRequired = state.urlDecodeRequired; while (buffer.hasRemaining()) { - char next = (char) buffer.get(); + char next = (char) (buffer.get() & 0xFF); if (next == ' ' || next == '\t') { if (stringBuilder.length() != 0) { final String path = stringBuilder.toString(); @@ -373,7 +373,7 @@ return; } else { - if (decode && (next == '+' || next == '%')) { + if (decode && (next == '+' || next == '%' || next > 127)) { urlDecodeRequired = true; } else if (next == ':' && parseState == START) { parseState = FIRST_COLON; @@ -468,7 +468,7 @@ //we encounter an encoded character while (buffer.hasRemaining()) { - char next = (char) buffer.get(); + char next = (char) (buffer.get() & 0xFF); if (next == ' ' || next == '\t') { final String queryString = stringBuilder.toString(); exchange.setQueryString(queryString); @@ -489,7 +489,7 @@ } else if (next == '\r' || next == '\n') { throw UndertowMessages.MESSAGES.failedToParsePath(); } else { - if (decode && (next == '+' || next == '%')) { + if (decode && (next == '+' || next == '%' || next > 127)) { urlDecodeRequired = true; } else if (next == '=' && nextQueryParam == null) { nextQueryParam = decode(stringBuilder.substring(queryParamPos), urlDecodeRequired, state, true); @@ -548,7 +548,7 @@ //we encounter an encoded character while (buffer.hasRemaining()) { - char next = (char) buffer.get(); + char next = (char) (buffer.get() & 0xFF); if (next == ' ' || next == '\t' || next == '?') { if (nextQueryParam == null) { if (queryParamPos != stringBuilder.length()) { @@ -573,7 +573,7 @@ } else if (next == '\r' || next == '\n') { throw UndertowMessages.MESSAGES.failedToParsePath(); } else { - if (decode && (next == '+' || next == '%')) { + if (decode && (next == '+' || next == '%' || next > 127)) { urlDecodeRequired = true; } if (next == '=' && nextQueryParam == null) { @@ -655,7 +655,7 @@ } else if (next == ' ' || next == '\t') { parseState = WHITESPACE; } else { - stringBuilder.append((char) next); + stringBuilder.append((char) (next & 0xFF)); } } @@ -670,7 +670,7 @@ } else if (next == ' ' || next == '\t') { parseState = WHITESPACE; } else { - stringBuilder.append((char) next); + stringBuilder.append((char) (next & 0xFF)); } break; } @@ -684,7 +684,7 @@ if (stringBuilder.length() > 0) { stringBuilder.append(' '); } - stringBuilder.append((char) next); + stringBuilder.append((char) (next & 0xFF)); parseState = NORMAL; } break; @@ -719,6 +719,9 @@ state.stringBuilder.setLength(0); if (next == '\r') { parseState = AWAIT_DATA_END; + } else if (next == '\n') { + state.state = ParseState.PARSE_COMPLETE; + return; } else { state.state = ParseState.HEADER; state.parseState = 0; @@ -816,7 +819,7 @@ * @return */ protected static Map httpStrings() { - final Map results = new HashMap(); + final Map results = new HashMap<>(); final Class[] classs = {Headers.class, Methods.class, Protocols.class}; for (Class c : classs) { Index: 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpResponseConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/http/Attic/HttpResponseConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpResponseConduit.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpResponseConduit.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.protocol.http; @@ -30,11 +30,15 @@ import io.undertow.util.HeaderValues; import io.undertow.util.HttpString; import io.undertow.util.StatusCodes; + +import org.xnio.Buffers; +import org.xnio.IoUtils; import org.xnio.Pool; import org.xnio.Pooled; import org.xnio.XnioWorker; import org.xnio.channels.StreamSourceChannel; import org.xnio.conduits.AbstractStreamSinkConduit; +import org.xnio.conduits.ConduitWritableByteChannel; import org.xnio.conduits.Conduits; import org.xnio.conduits.StreamSinkConduit; @@ -59,6 +63,7 @@ private HttpServerExchange exchange; private ByteBuffer[] writevBuffer; + private boolean done = false; private static final int STATE_BODY = 0; // Message body, normal pass-through operation private static final int STATE_START = 1; // No headers written yet @@ -109,22 +114,33 @@ * @return * @throws IOException */ - private int processWrite(int state, final ByteBuffer userData) throws IOException { + private int processWrite(int state, final Object userData, int pos, int length) throws IOException { + if(done) { + throw new ClosedChannelException(); + } assert state != STATE_BODY; if (state == STATE_BUF_FLUSH) { final ByteBuffer byteBuffer = pooledBuffer.getResource(); do { long res = 0; ByteBuffer[] data; - if (userData == null) { + if (userData == null || length == 0) { res = next.write(byteBuffer); - } else { + } else if (userData instanceof ByteBuffer){ data = writevBuffer; if(data == null) { data = writevBuffer = new ByteBuffer[2]; } data[0] = byteBuffer; - data[1] = userData; + data[1] = (ByteBuffer) userData; + res = next.write(data, 0, 2); + } else { + data = writevBuffer; + if(data == null || data.length < length + 1) { + data = writevBuffer = new ByteBuffer[length + 1]; + } + data[0] = byteBuffer; + System.arraycopy(userData, pos, data, 1, length); res = next.write(data, 0, data.length); } if (res == 0) { @@ -134,7 +150,7 @@ bufferDone(); return STATE_BODY; } else if (state != STATE_START) { - return processStatefulWrite(state, userData); + return processStatefulWrite(state, userData, pos, length); } //merge the cookies into the header map @@ -181,7 +197,7 @@ this.charIndex = 0; this.state = STATE_HDR_NAME; buffer.flip(); - return processStatefulWrite(STATE_HDR_NAME, userData); + return processStatefulWrite(STATE_HDR_NAME, userData, pos, length); } header.appendTo(buffer); buffer.put((byte) ':').put((byte) ' '); @@ -196,7 +212,7 @@ this.charIndex = 0; this.state = STATE_HDR_VAL; buffer.flip(); - return processStatefulWrite(STATE_HDR_VAL, userData); + return processStatefulWrite(STATE_HDR_VAL, userData, pos ,length); } writeString(buffer, string); buffer.put((byte) '\r').put((byte) '\n'); @@ -210,13 +226,21 @@ ByteBuffer[] data; if (userData == null) { res = next.write(buffer); - } else { + } else if (userData instanceof ByteBuffer){ data = writevBuffer; if(data == null) { data = writevBuffer = new ByteBuffer[2]; } data[0] = buffer; - data[1] = userData; + data[1] = (ByteBuffer) userData; + res = next.write(data, 0, 2); + } else { + data = writevBuffer; + if(data == null || data.length < length + 1) { + data = writevBuffer = new ByteBuffer[length + 1]; + } + data[0] = buffer; + System.arraycopy(userData, pos, data, 1, length); res = next.write(data, 0, data.length); } if (res == 0) { @@ -250,7 +274,7 @@ /** * Handles writing out the header data in the case where is is too big to fit into a buffer. This is a much slower code path. */ - private int processStatefulWrite(int state, final ByteBuffer userData) throws IOException { + private int processStatefulWrite(int state, final Object userData, int pos, int len) throws IOException { ByteBuffer buffer = pooledBuffer.getResource(); long fiCookie = this.fiCookie; int valueIdx = this.valueIdx; @@ -401,8 +425,18 @@ return STATE_BUF_FLUSH; } } while (buffer.hasRemaining()); + } else if(userData instanceof ByteBuffer) { + ByteBuffer[] b = {buffer, (ByteBuffer) userData}; + do { + long r = next.write(b, 0, b.length); + if (r == 0 && buffer.hasRemaining()) { + return STATE_BUF_FLUSH; + } + } while (buffer.hasRemaining()); } else { - ByteBuffer[] b = {buffer, userData}; + ByteBuffer[] b = new ByteBuffer[1 + len]; + b[0] = buffer; + System.arraycopy(userData, pos, b, 1, len); do { long r = next.write(b, 0, b.length); if (r == 0 && buffer.hasRemaining()) { @@ -468,8 +502,18 @@ return STATE_BUF_FLUSH; } } while (buffer.hasRemaining()); + } else if(userData instanceof ByteBuffer) { + ByteBuffer[] b = {buffer, (ByteBuffer) userData}; + do { + long r = next.write(b, 0, b.length); + if (r == 0 && buffer.hasRemaining()) { + return STATE_BUF_FLUSH; + } + } while (buffer.hasRemaining()); } else { - ByteBuffer[] b = {buffer, userData}; + ByteBuffer[] b = new ByteBuffer[1 + len]; + b[0] = buffer; + System.arraycopy(userData, pos, b, 1, len); do { long r = next.write(b, 0, b.length); if (r == 0 && buffer.hasRemaining()) { @@ -517,7 +561,7 @@ try { if (state != 0) { originalRemaining = src.remaining(); - state = processWrite(state, src); + state = processWrite(state, src, -1, -1); if (state != 0) { return 0; } @@ -548,15 +592,19 @@ int state = oldVal & MASK_STATE; try { if (state != 0) { - //todo: use gathering write here - state = processWrite(state, null); + long rem = Buffers.remaining(srcs, offset, length); + state = processWrite(state, srcs, offset, length); + + long ret = rem - Buffers.remaining(srcs, offset, length); if (state != 0) { - return 0; + return ret; } if (allAreSet(oldVal, FLAG_SHUTDOWN)) { next.terminateWrites(); throw new ClosedChannelException(); } + //we don't attempt to write again + return ret; } return length == 1 ? next.write(srcs[offset]) : next.write(srcs, offset, length); } finally { @@ -565,50 +613,11 @@ } public long transferFrom(final FileChannel src, final long position, final long count) throws IOException { - if (count == 0L) { - return 0L; - } - int oldVal = state; - int state = oldVal & MASK_STATE; - try { - if (state != 0) { - state = processWrite(state, null); - if (state != 0) { - return 0; - } - if (allAreSet(oldVal, FLAG_SHUTDOWN)) { - next.terminateWrites(); - throw new ClosedChannelException(); - } - } - return next.transferFrom(src, position, count); - } finally { - this.state = oldVal & ~MASK_STATE | state; - } + return src.transferTo(position, count, new ConduitWritableByteChannel(this)); } public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException { - if (count == 0) { - throughBuffer.clear().limit(0); - return 0L; - } - int oldVal = state; - int state = oldVal & MASK_STATE; - try { - if (state != 0) { - state = processWrite(state, null); - if (state != 0) { - return 0; - } - if (allAreSet(oldVal, FLAG_SHUTDOWN)) { - next.terminateWrites(); - throw new ClosedChannelException(); - } - } - return next.transferFrom(source, count, throughBuffer); - } finally { - this.state = oldVal & ~MASK_STATE | state; - } + return IoUtils.transfer(source, count, throughBuffer, new ConduitWritableByteChannel(this)); } @Override @@ -626,7 +635,7 @@ int state = oldVal & MASK_STATE; try { if (state != 0) { - state = processWrite(state, null); + state = processWrite(state, null, -1, -1); if (state != 0) { return false; } @@ -672,6 +681,7 @@ } void freeBuffers() { + done = true; if(pooledBuffer != null) { bufferDone(); } Index: 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpServerConnection.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/http/Attic/HttpServerConnection.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpServerConnection.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpServerConnection.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.protocol.http; @@ -33,6 +33,7 @@ import io.undertow.util.ConduitFactory; import io.undertow.util.Headers; import io.undertow.util.HttpString; +import io.undertow.util.ImmediatePooled; import org.xnio.OptionMap; import org.xnio.Pool; import org.xnio.Pooled; @@ -125,6 +126,11 @@ return newExchange; } + @Override + public void terminateRequestChannel(HttpServerExchange exchange) { + + } + /** * Pushes back the given data. This should only be used by transfer coding handlers that have read past * the end of the request when handling pipelined requests @@ -155,22 +161,7 @@ eb.free(); unget.free(); final ByteBuffer newBuffer = ByteBuffer.wrap(data); - setExtraBytes(new Pooled() { - @Override - public void discard() { - - } - - @Override - public void free() { - - } - - @Override - public ByteBuffer getResource() throws IllegalStateException { - return newBuffer; - } - }); + setExtraBytes(new ImmediatePooled<>(newBuffer)); } } } Index: 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpTransferEncoding.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/http/Attic/HttpTransferEncoding.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpTransferEncoding.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/http/HttpTransferEncoding.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.protocol.http; Index: 3rdParty_sources/undertow/io/undertow/server/protocol/http/ParseState.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/http/Attic/ParseState.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/http/ParseState.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/http/ParseState.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.protocol.http; @@ -110,7 +110,7 @@ * In general browsers will often send the same header with every request. This cache allows us to re-use the resulting * strings. */ - final HashMap headerValuesCache = new HashMap(); + final HashMap headerValuesCache = new HashMap<>(); public ParseState() { this.parseState = 0; Index: 3rdParty_sources/undertow/io/undertow/server/protocol/http/PipeliningBufferingStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/http/Attic/PipeliningBufferingStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/http/PipeliningBufferingStreamSinkConduit.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/http/PipeliningBufferingStreamSinkConduit.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.http; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/server/protocol/http/ServerFixedLengthStreamSinkConduit.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/protocol/http/Attic/ServerFixedLengthStreamSinkConduit.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/protocol/http/ServerFixedLengthStreamSinkConduit.java 8 Sep 2014 10:52:11 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/protocol/http/ServerFixedLengthStreamSinkConduit.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.protocol.http; import io.undertow.conduits.AbstractFixedLengthStreamSinkConduit; Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/protocol/spdy/SpdyOpenListener.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/protocol/spdy/SpdyPlainOpenListener.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/protocol/spdy/SpdyReceiveListener.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/protocol/spdy/SpdyServerConnection.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/server/protocol/spdy/SpdySslSessionInfo.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/server/session/InMemorySessionManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/InMemorySessionManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/InMemorySessionManager.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/InMemorySessionManager.java 25 Nov 2014 10:46:57 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.session; @@ -23,9 +23,8 @@ import io.undertow.server.HttpServerExchange; import io.undertow.util.ConcurrentDirectDeque; -import org.xnio.XnioExecutor; -import org.xnio.XnioWorker; - +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -34,6 +33,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; +import org.xnio.XnioExecutor; +import org.xnio.XnioWorker; + /** * The default in memory session manager. This basically just stores sessions in an in memory hash map. *

    @@ -61,7 +63,7 @@ public InMemorySessionManager(String deploymentName, int maxSessions) { this.deploymentName = deploymentName; - this.sessions = new ConcurrentHashMap(); + this.sessions = new ConcurrentHashMap<>(); this.maxSize = maxSessions; ConcurrentDirectDeque evictionQueue = null; if (maxSessions > 0) { @@ -184,7 +186,7 @@ @Override public Set getAllSessions() { - return new HashSet(sessions.keySet()); + return new HashSet<>(sessions.keySet()); } @Override @@ -201,7 +203,7 @@ @Override public String toString() { - return this.deploymentName.toString(); + return this.deploymentName; } /** @@ -211,24 +213,46 @@ private final InMemorySessionManager sessionManager; - private static volatile AtomicReferenceFieldUpdater evictionTokenUpdater = AtomicReferenceFieldUpdater.newUpdater(SessionImpl.class, Object.class, "evictionToken"); + static volatile AtomicReferenceFieldUpdater evictionTokenUpdater; + static { + //this is needed in case there is unprivileged code on the stack + //it needs to delegate to the createTokenUpdater() method otherwise the creation will fail + //as the inner class cannot access the member + evictionTokenUpdater = AccessController.doPrivileged(new PrivilegedAction>() { + @Override + public AtomicReferenceFieldUpdater run() { + return createTokenUpdater(); + } + }); + } + private static AtomicReferenceFieldUpdater createTokenUpdater() { + return AtomicReferenceFieldUpdater.newUpdater(SessionImpl.class, Object.class, "evictionToken"); + } + + private String sessionId; private volatile Object evictionToken; private final SessionConfig sessionCookieConfig; + private volatile long expireTime = -1; final XnioExecutor executor; final XnioWorker worker; - XnioExecutor.Key cancelKey; + XnioExecutor.Key timerCancelKey; Runnable cancelTask = new Runnable() { @Override public void run() { worker.execute(new Runnable() { @Override public void run() { - invalidate(null, SessionListener.SessionDestroyedReason.TIMEOUT); + long currentTime = System.currentTimeMillis(); + if(currentTime >= expireTime) { + invalidate(null, SessionListener.SessionDestroyedReason.TIMEOUT); + } else { + timerCancelKey = executor.executeAfter(cancelTask, expireTime - currentTime, TimeUnit.MILLISECONDS); + } } }); } @@ -244,14 +268,24 @@ } synchronized void bumpTimeout() { - if (cancelKey != null) { - if (!cancelKey.remove()) { - return; + final int maxInactiveInterval = getMaxInactiveInterval(); + if (maxInactiveInterval > 0) { + long newExpireTime = System.currentTimeMillis() + (maxInactiveInterval * 1000); + if(timerCancelKey != null && (newExpireTime < expireTime)) { + // We have to re-schedule as the new maxInactiveInterval is lower than the old one + if (!timerCancelKey.remove()) { + return; + } + timerCancelKey = null; } + expireTime = newExpireTime; + if(timerCancelKey == null) { + //+1 second, to make sure that the time has actually expired + //we don't re-schedule every time, as it is expensive + //instead when it expires we check if the timeout has been bumped, and if so we re-schedule + timerCancelKey = executor.executeAfter(cancelTask, (maxInactiveInterval * 1000) + 1, TimeUnit.MILLISECONDS); + } } - if (getMaxInactiveInterval() > 0) { - cancelKey = executor.executeAfter(cancelTask, getMaxInactiveInterval(), TimeUnit.SECONDS); - } if (evictionToken != null) { Object token = evictionToken; if (evictionTokenUpdater.compareAndSet(this, token, null)) { @@ -366,8 +400,8 @@ } synchronized void invalidate(final HttpServerExchange exchange, SessionListener.SessionDestroyedReason reason) { - if (cancelKey != null) { - cancelKey.remove(); + if (timerCancelKey != null) { + timerCancelKey.remove(); } InMemorySession sess = sessionManager.sessions.get(sessionId); if (sess == null) { @@ -402,8 +436,8 @@ } private synchronized void destroy() { - if (cancelKey != null) { - cancelKey.remove(); + if (timerCancelKey != null) { + timerCancelKey.remove(); } cancelTask = null; } @@ -423,7 +457,7 @@ this.maxInactiveInterval = maxInactiveInterval; } - final ConcurrentMap attributes = new ConcurrentHashMap(); + final ConcurrentMap attributes = new ConcurrentHashMap<>(); volatile long lastAccessed; final long creationTime; volatile int maxInactiveInterval; Index: 3rdParty_sources/undertow/io/undertow/server/session/PathParameterSessionConfig.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/PathParameterSessionConfig.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/PathParameterSessionConfig.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/PathParameterSessionConfig.java 25 Nov 2014 10:46:57 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.session; import java.util.Deque; Index: 3rdParty_sources/undertow/io/undertow/server/session/SecureRandomSessionIdGenerator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/SecureRandomSessionIdGenerator.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/SecureRandomSessionIdGenerator.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/SecureRandomSessionIdGenerator.java 25 Nov 2014 10:46:57 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.session; Index: 3rdParty_sources/undertow/io/undertow/server/session/Session.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/Session.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/Session.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/Session.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.session; Index: 3rdParty_sources/undertow/io/undertow/server/session/SessionAttachmentHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/SessionAttachmentHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/SessionAttachmentHandler.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/SessionAttachmentHandler.java 25 Nov 2014 10:46:57 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.session; Index: 3rdParty_sources/undertow/io/undertow/server/session/SessionConfig.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/SessionConfig.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/SessionConfig.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/SessionConfig.java 25 Nov 2014 10:46:57 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.session; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/server/session/SessionCookieConfig.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/SessionCookieConfig.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/SessionCookieConfig.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/SessionCookieConfig.java 25 Nov 2014 10:46:57 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.session; Index: 3rdParty_sources/undertow/io/undertow/server/session/SessionIdGenerator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/SessionIdGenerator.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/SessionIdGenerator.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/SessionIdGenerator.java 25 Nov 2014 10:46:57 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.session; Index: 3rdParty_sources/undertow/io/undertow/server/session/SessionListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/SessionListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/SessionListener.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/SessionListener.java 25 Nov 2014 10:46:57 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.session; @@ -38,9 +38,9 @@ /** * Called when a session is destroyed - * @param session The new session - * @param exchange The {@link HttpServerExchange} that destroyed the session, or null if the session timed out - * @param expired If the session expired + * @param session The new session + * @param exchange The {@link HttpServerExchange} that destroyed the session, or null if the session timed out + * @param reason The reason why the session was expired */ void sessionDestroyed(final Session session, final HttpServerExchange exchange, SessionDestroyedReason reason); Index: 3rdParty_sources/undertow/io/undertow/server/session/SessionListeners.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/SessionListeners.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/SessionListeners.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/SessionListeners.java 25 Nov 2014 10:46:57 -0000 1.1.2.3 @@ -1,6 +1,26 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.server.session; +import java.util.ArrayList; import java.util.List; +import java.util.ListIterator; import java.util.concurrent.CopyOnWriteArrayList; import io.undertow.server.HttpServerExchange; @@ -13,7 +33,7 @@ */ public class SessionListeners { - private final List sessionListeners = new CopyOnWriteArrayList(); + private final List sessionListeners = new CopyOnWriteArrayList<>(); public void addSessionListener(final SessionListener listener) { this.sessionListeners.add(listener); @@ -34,10 +54,12 @@ } public void sessionDestroyed(final Session session, final HttpServerExchange exchange, SessionListener.SessionDestroyedReason reason) { - for (SessionListener listener : sessionListeners) { - listener.sessionDestroyed(session, exchange, reason); + // We need to create our own snapshot to safely iterate over a concurrent list in reverse + List listeners = new ArrayList<>(sessionListeners); + ListIterator iterator = listeners.listIterator(listeners.size()); + while (iterator.hasPrevious()) { + iterator.previous().sessionDestroyed(session, exchange, reason); } - } public void attributeAdded(final Session session, final String name, final Object value) { Index: 3rdParty_sources/undertow/io/undertow/server/session/SessionManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/SessionManager.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/SessionManager.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/SessionManager.java 25 Nov 2014 10:46:57 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.session; Index: 3rdParty_sources/undertow/io/undertow/server/session/SslSessionConfig.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/server/session/Attic/SslSessionConfig.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/server/session/SslSessionConfig.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/server/session/SslSessionConfig.java 25 Nov 2014 10:46:57 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.server.session; @@ -34,8 +34,8 @@ public class SslSessionConfig implements SessionConfig { private final SessionConfig fallbackSessionConfig; - private final Map sessions = new HashMap(); - private final Map reverse = new HashMap(); + private final Map sessions = new HashMap<>(); + private final Map reverse = new HashMap<>(); public SslSessionConfig(final SessionConfig fallbackSessionConfig, SessionManager sessionManager) { this.fallbackSessionConfig = fallbackSessionConfig; Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/servlet/ExceptionLog.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/servlet/ServletExtension.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/Attic/ServletExtension.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/ServletExtension.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/ServletExtension.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet; Index: 3rdParty_sources/undertow/io/undertow/servlet/Servlets.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/Attic/Servlets.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/Servlets.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/Servlets.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,10 +1,29 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet; import javax.servlet.Filter; import javax.servlet.MultipartConfigElement; import javax.servlet.Servlet; import io.undertow.servlet.api.DeploymentInfo; +import io.undertow.servlet.api.ErrorPage; import io.undertow.servlet.api.FilterInfo; import io.undertow.servlet.api.InstanceFactory; import io.undertow.servlet.api.ListenerInfo; @@ -155,4 +174,34 @@ public static LoginConfig loginConfig(String mechanismName, final String realmName) { return new LoginConfig(mechanismName, realmName); } + + /** + * Create an ErrorPage instance for a given exception type + * @param location The location to redirect to + * @param exceptionType The exception type + * @return The error page definition + */ + public static ErrorPage errorPage(String location, Class exceptionType) { + return new ErrorPage(location, exceptionType); + } + + /** + * Create an ErrorPage instance for a given response code + * @param location The location to redirect to + * @param statusCode The status code + * @return The error page definition + */ + public static ErrorPage errorPage(String location, int statusCode) { + return new ErrorPage(location, statusCode); + } + + /** + * Create an ErrorPage that corresponds to the default error page + * + * @param location The error page location + * @return The error page instance + */ + public static ErrorPage errorPage(String location) { + return new ErrorPage(location); + } } Index: 3rdParty_sources/undertow/io/undertow/servlet/UndertowServletLogger.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/Attic/UndertowServletLogger.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/UndertowServletLogger.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/UndertowServletLogger.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet; Index: 3rdParty_sources/undertow/io/undertow/servlet/UndertowServletMessages.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/Attic/UndertowServletMessages.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/UndertowServletMessages.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/UndertowServletMessages.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet; @@ -199,4 +199,11 @@ @Message(id = 10051, value = "Deployment %s has stopped") ServletException deploymentStopped(String deployment); + + @Message(id = 10052, value = "Header name was null") + NullPointerException headerNameWasNull(); + + @Message(id = 10053, value = "No confidential port is available to redirect the current request.") + IllegalStateException noConfidentialPortAvailable(); + } Index: 3rdParty_sources/undertow/io/undertow/servlet/api/AuthMethodConfig.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/AuthMethodConfig.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/AuthMethodConfig.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/AuthMethodConfig.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; import java.util.HashMap; @@ -13,12 +31,12 @@ public AuthMethodConfig(String name, Map properties) { this.name = name; - this.properties = new HashMap(properties); + this.properties = new HashMap<>(properties); } public AuthMethodConfig(String name) { this.name = name; - this.properties = new HashMap(); + this.properties = new HashMap<>(); } public String getName() { Index: 3rdParty_sources/undertow/io/undertow/servlet/api/AuthorizationManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/AuthorizationManager.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/AuthorizationManager.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/AuthorizationManager.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; import io.undertow.security.idm.Account; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ClassIntrospecter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ClassIntrospecter.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ClassIntrospecter.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ClassIntrospecter.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ConfidentialPortManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ConfidentialPortManager.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ConfidentialPortManager.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ConfidentialPortManager.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,5 +1,6 @@ /* - * Copyright 2013 Red Hat, Inc., and individual contributors + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -8,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; @@ -26,6 +27,12 @@ */ public interface ConfidentialPortManager { + /** + * Obtain the port number to redirect the current request to to provide the transport guarantee of CONDIFENTIAL. + * + * @param exchange The current {@link HttpServerExchange} being redirected. + * @return The port to use in the redirection URI or {@code -1} if no configured port is available. + */ int getConfidentialPort(final HttpServerExchange exchange); } Index: 3rdParty_sources/undertow/io/undertow/servlet/api/DefaultServletConfig.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/DefaultServletConfig.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/DefaultServletConfig.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/DefaultServletConfig.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; import java.util.Arrays; @@ -26,24 +44,24 @@ public DefaultServletConfig(final boolean defaultAllowed, final Set exceptions) { this.defaultAllowed = defaultAllowed; if(defaultAllowed) { - disallowed = Collections.unmodifiableSet(new HashSet(exceptions)); + disallowed = Collections.unmodifiableSet(new HashSet<>(exceptions)); allowed = null; } else { - allowed = Collections.unmodifiableSet(new HashSet(exceptions)); + allowed = Collections.unmodifiableSet(new HashSet<>(exceptions)); disallowed = null; } } public DefaultServletConfig(final boolean defaultAllowed) { this.defaultAllowed = defaultAllowed; - this.allowed = Collections.unmodifiableSet(new HashSet(Arrays.asList(DEFAULT_ALLOWED_EXTENSIONS))); - this.disallowed = Collections.unmodifiableSet(new HashSet(Arrays.asList(DEFAULT_DISALLOWED_EXTENSIONS))); + this.allowed = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DEFAULT_ALLOWED_EXTENSIONS))); + this.disallowed = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DEFAULT_DISALLOWED_EXTENSIONS))); } public DefaultServletConfig() { this.defaultAllowed = false; - this.allowed = Collections.unmodifiableSet(new HashSet(Arrays.asList(DEFAULT_ALLOWED_EXTENSIONS))); - this.disallowed = Collections.unmodifiableSet(new HashSet(Arrays.asList(DEFAULT_DISALLOWED_EXTENSIONS))); + this.allowed = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DEFAULT_ALLOWED_EXTENSIONS))); + this.disallowed = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DEFAULT_DISALLOWED_EXTENSIONS))); } public boolean isDefaultAllowed() { Index: 3rdParty_sources/undertow/io/undertow/servlet/api/Deployment.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/Deployment.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/Deployment.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/Deployment.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/DeploymentInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/DeploymentInfo.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/DeploymentInfo.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/DeploymentInfo.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; @@ -42,6 +42,7 @@ import io.undertow.security.idm.IdentityManager; import io.undertow.server.HandlerWrapper; import io.undertow.server.handlers.resource.ResourceManager; +import io.undertow.server.session.SessionListener; import io.undertow.servlet.ServletExtension; import io.undertow.servlet.UndertowServletMessages; import io.undertow.servlet.core.DefaultAuthorizationManager; @@ -94,51 +95,55 @@ private SessionConfigWrapper sessionConfigWrapper = null; private boolean eagerFilterInit = false; private boolean disableCachingForSecuredPages = true; - private final Map servlets = new HashMap(); - private final Map filters = new HashMap(); - private final List filterServletNameMappings = new ArrayList(); - private final List filterUrlMappings = new ArrayList(); - private final List listeners = new ArrayList(); - private final List servletContainerInitializers = new ArrayList(); - private final List threadSetupActions = new ArrayList(); - private final Map initParameters = new HashMap(); - private final Map servletContextAttributes = new HashMap(); - private final Map localeCharsetMapping = new HashMap(); - private final List welcomePages = new ArrayList(); - private final List errorPages = new ArrayList(); - private final List mimeMappings = new ArrayList(); - private final List securityConstraints = new ArrayList(); - private final Set securityRoles = new HashSet(); - private final List notificationReceivers = new ArrayList(); - private final Map authenticationMechanisms = new HashMap(); + private boolean escapeErrorMessage = true; + private ExceptionHandler exceptionHandler; + private final Map servlets = new HashMap<>(); + private final Map filters = new HashMap<>(); + private final List filterServletNameMappings = new ArrayList<>(); + private final List filterUrlMappings = new ArrayList<>(); + private final List listeners = new ArrayList<>(); + private final List servletContainerInitializers = new ArrayList<>(); + private final List threadSetupActions = new ArrayList<>(); + private final Map initParameters = new HashMap<>(); + private final Map servletContextAttributes = new HashMap<>(); + private final Map localeCharsetMapping = new HashMap<>(); + private final List welcomePages = new ArrayList<>(); + private final List errorPages = new ArrayList<>(); + private final List mimeMappings = new ArrayList<>(); + private final List securityConstraints = new ArrayList<>(); + private final Set securityRoles = new HashSet<>(); + private final List notificationReceivers = new ArrayList<>(); + private final Map authenticationMechanisms = new HashMap<>(); + private final List lifecycleInterceptors = new ArrayList<>(); + private final List sessionListeners = new ArrayList<>(); /** * additional servlet extensions */ - private final List servletExtensions = new ArrayList(); + private final List servletExtensions = new ArrayList<>(); /** * map of additional roles that should be applied to the given principal. */ - private final Map> principalVersusRolesMap = new HashMap>(); + private final Map> principalVersusRolesMap = new HashMap<>(); /** * Wrappers that are applied before the servlet initial handler, and before any servlet related object have been * created. If a wrapper wants to bypass servlet entirely it should register itself here. */ - private final List initialHandlerChainWrappers = new ArrayList(); + private final List initialHandlerChainWrappers = new ArrayList<>(); /** * Handler chain wrappers that are applied outside all other handlers, including security but after the initial * servlet handler. */ - private final List outerHandlerChainWrappers = new ArrayList(); + private final List outerHandlerChainWrappers = new ArrayList<>(); /** * Handler chain wrappers that are applied just before the servlet request is dispatched. At this point the security * handlers have run, and any security information is attached to the request. */ - private final List innerHandlerChainWrappers = new ArrayList(); + private final List innerHandlerChainWrappers = new ArrayList<>(); public void validate() { @@ -351,7 +356,7 @@ } public List getFilterMappings() { - final ArrayList ret = new ArrayList(filterUrlMappings); + final ArrayList ret = new ArrayList<>(filterUrlMappings); ret.addAll(filterServletNameMappings); return Collections.unmodifiableList(ret); } @@ -818,7 +823,7 @@ public DeploymentInfo addPrincipalVsRoleMapping(final String principal, final String mapping) { Set set = principalVersusRolesMap.get(principal); if (set == null) { - principalVersusRolesMap.put(principal, set = new HashSet()); + principalVersusRolesMap.put(principal, set = new HashSet<>()); } set.add(mapping); return this; @@ -827,7 +832,7 @@ public DeploymentInfo addPrincipalVsRoleMappings(final String principal, final String... mappings) { Set set = principalVersusRolesMap.get(principal); if (set == null) { - principalVersusRolesMap.put(principal, set = new HashSet()); + principalVersusRolesMap.put(principal, set = new HashSet<>()); } set.addAll(Arrays.asList(mappings)); return this; @@ -836,7 +841,7 @@ public DeploymentInfo addPrincipalVsRoleMappings(final String principal, final Collection mappings) { Set set = principalVersusRolesMap.get(principal); if (set == null) { - principalVersusRolesMap.put(principal, set = new HashSet()); + principalVersusRolesMap.put(principal, set = new HashSet<>()); } set.addAll(mappings); return this; @@ -1004,6 +1009,58 @@ this.disableCachingForSecuredPages = disableCachingForSecuredPages; } + public DeploymentInfo addLifecycleInterceptor(final LifecycleInterceptor interceptor) { + lifecycleInterceptors.add(interceptor); + return this; + } + + public List getLifecycleInterceptors() { + return Collections.unmodifiableList(lifecycleInterceptors); + } + + /** + * Returns the exception handler that is used by this deployment. By default this will simply + * log unhandled exceptions + */ + public ExceptionHandler getExceptionHandler() { + return exceptionHandler; + } + + /** + * Sets the default exception handler for this deployment + * @param exceptionHandler The exception handler + * @return + */ + public DeploymentInfo setExceptionHandler(ExceptionHandler exceptionHandler) { + this.exceptionHandler = exceptionHandler; + return this; + } + + public boolean isEscapeErrorMessage() { + return escapeErrorMessage; + } + + /** + * Set if if the message passed to {@link javax.servlet.http.HttpServletResponse#sendError(int, String)} should be escaped. + * + * If this is false applications must be careful not to use user provided data (such as the URI) in the message + * + * @param escapeErrorMessage If the error message should be escaped + */ + public void setEscapeErrorMessage(boolean escapeErrorMessage) { + this.escapeErrorMessage = escapeErrorMessage; + } + + + public DeploymentInfo addSessionListener(SessionListener sessionListener) { + this.sessionListeners.add(sessionListener); + return this; + } + + public List getSessionListeners() { + return Collections.unmodifiableList(sessionListeners); + } + @Override public DeploymentInfo clone() { final DeploymentInfo info = new DeploymentInfo() @@ -1075,6 +1132,10 @@ info.sessionConfigWrapper = sessionConfigWrapper; info.eagerFilterInit = eagerFilterInit; info.disableCachingForSecuredPages = disableCachingForSecuredPages; + info.exceptionHandler = exceptionHandler; + info.escapeErrorMessage = escapeErrorMessage; + info.sessionListeners.addAll(sessionListeners); + info.lifecycleInterceptors.addAll(lifecycleInterceptors); return info; } Index: 3rdParty_sources/undertow/io/undertow/servlet/api/DeploymentManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/DeploymentManager.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/DeploymentManager.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/DeploymentManager.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ErrorPage.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ErrorPage.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ErrorPage.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ErrorPage.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/servlet/api/ExceptionHandler.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/servlet/api/FilterInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/FilterInfo.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/FilterInfo.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/FilterInfo.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; @@ -37,7 +37,7 @@ private final String name; private final InstanceFactory instanceFactory; - private final Map initParams = new HashMap(); + private final Map initParams = new HashMap<>(); private volatile boolean asyncSupported; @@ -54,7 +54,7 @@ try { final Constructor ctor = (Constructor) filterClass.getDeclaredConstructor(); ctor.setAccessible(true); - this.instanceFactory = new ConstructorInstanceFactory(ctor); + this.instanceFactory = new ConstructorInstanceFactory<>(ctor); this.name = name; this.filterClass = filterClass; } catch (NoSuchMethodException e) { Index: 3rdParty_sources/undertow/io/undertow/servlet/api/FilterMappingInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/FilterMappingInfo.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/FilterMappingInfo.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/FilterMappingInfo.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/HttpMethodSecurityInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/HttpMethodSecurityInfo.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/HttpMethodSecurityInfo.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/HttpMethodSecurityInfo.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; /** Index: 3rdParty_sources/undertow/io/undertow/servlet/api/InstanceFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/InstanceFactory.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/InstanceFactory.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/InstanceFactory.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/InstanceHandle.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/InstanceHandle.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/InstanceHandle.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/InstanceHandle.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/servlet/api/LifecycleInterceptor.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ListenerInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ListenerInfo.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ListenerInfo.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ListenerInfo.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; @@ -48,7 +48,7 @@ try { final Constructor ctor = (Constructor) listenerClass.getDeclaredConstructor(); ctor.setAccessible(true); - this.instanceFactory = new ConstructorInstanceFactory(ctor); + this.instanceFactory = new ConstructorInstanceFactory<>(ctor); } catch (NoSuchMethodException e) { throw UndertowServletMessages.MESSAGES.componentMustHaveDefaultConstructor("Listener", listenerClass); } Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/servlet/api/LoggingExceptionHandler.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/servlet/api/LoginConfig.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/LoginConfig.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/LoginConfig.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/LoginConfig.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; import java.util.LinkedList; @@ -7,7 +25,7 @@ * @author Stuart Douglas */ public class LoginConfig implements Cloneable { - private final LinkedList authMethods = new LinkedList(); + private final LinkedList authMethods = new LinkedList<>(); private final String realmName; private final String loginPage; private final String errorPage; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/MetricsCollector.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/MetricsCollector.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/MetricsCollector.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/MetricsCollector.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; import io.undertow.server.handlers.MetricsHandler; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/MimeMapping.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/MimeMapping.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/MimeMapping.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/MimeMapping.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/SecurityConstraint.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/SecurityConstraint.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/SecurityConstraint.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/SecurityConstraint.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; import java.util.Arrays; @@ -11,7 +29,7 @@ */ public class SecurityConstraint extends SecurityInfo { - private final Set webResourceCollections = new HashSet(); + private final Set webResourceCollections = new HashSet<>(); public Set getWebResourceCollections() { return Collections.unmodifiableSet(webResourceCollections); Index: 3rdParty_sources/undertow/io/undertow/servlet/api/SecurityInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/SecurityInfo.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/SecurityInfo.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/SecurityInfo.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; @@ -51,7 +51,7 @@ } private volatile EmptyRoleSemantic emptyRoleSemantic = EmptyRoleSemantic.DENY; - private final Set rolesAllowed = new HashSet(); + private final Set rolesAllowed = new HashSet<>(); private volatile TransportGuaranteeType transportGuaranteeType = TransportGuaranteeType.NONE; public EmptyRoleSemantic getEmptyRoleSemantic() { @@ -86,7 +86,7 @@ return (T) this; } public Set getRolesAllowed() { - return new HashSet(rolesAllowed); + return new HashSet<>(rolesAllowed); } @Override Index: 3rdParty_sources/undertow/io/undertow/servlet/api/SecurityRoleRef.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/SecurityRoleRef.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/SecurityRoleRef.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/SecurityRoleRef.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ServletContainer.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ServletContainer.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ServletContainer.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ServletContainer.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ServletContainerInitializerInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ServletContainerInitializerInfo.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ServletContainerInitializerInfo.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ServletContainerInitializerInfo.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ServletDispatcher.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ServletDispatcher.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ServletDispatcher.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ServletDispatcher.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ServletInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ServletInfo.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ServletInfo.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ServletInfo.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,18 +9,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; import java.lang.reflect.Constructor; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -43,10 +42,10 @@ private final Class servletClass; private final String name; - private final List mappings = new ArrayList(); - private final Map initParams = new HashMap(); - private final List securityRoleRefs = new ArrayList(); - private final List handlerChainWrappers = new ArrayList(); + private final List mappings = new ArrayList<>(); + private final Map initParams = new HashMap<>(); + private final List securityRoleRefs = new ArrayList<>(); + private final List handlerChainWrappers = new ArrayList<>(); private InstanceFactory instanceFactory; private String jspFile; @@ -152,19 +151,28 @@ } public ServletInfo addMapping(final String mapping) { - mappings.add(mapping); + if(!mapping.startsWith("/") && !mapping.startsWith("*") && !mapping.isEmpty()) { + //if the user adds a mapping like 'index.html' we transparently translate it to '/index.html' + mappings.add("/" + mapping); + } else { + mappings.add(mapping); + } return this; } public ServletInfo addMappings(final Collection mappings) { - this.mappings.addAll(mappings); + for(String m : mappings) { + addMapping(m); + } return this; } public ServletInfo addMappings(final String... mappings) { - this.mappings.addAll(Arrays.asList(mappings)); + for(String m : mappings) { + addMapping(m); + } return this; } Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ServletSecurityInfo.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ServletSecurityInfo.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ServletSecurityInfo.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ServletSecurityInfo.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; import java.util.ArrayList; @@ -8,7 +26,7 @@ */ public class ServletSecurityInfo extends SecurityInfo implements Cloneable { - private final List httpMethodSecurityInfo = new ArrayList(); + private final List httpMethodSecurityInfo = new ArrayList<>(); @Override protected ServletSecurityInfo createInstance() { @@ -21,7 +39,7 @@ } public List getHttpMethodSecurityInfo() { - return new ArrayList(httpMethodSecurityInfo); + return new ArrayList<>(httpMethodSecurityInfo); } @Override Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ServletSessionConfig.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ServletSessionConfig.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ServletSessionConfig.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ServletSessionConfig.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ServletStackTraces.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ServletStackTraces.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ServletStackTraces.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ServletStackTraces.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; /** Index: 3rdParty_sources/undertow/io/undertow/servlet/api/SessionConfigWrapper.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/SessionConfigWrapper.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/SessionConfigWrapper.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/SessionConfigWrapper.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; import io.undertow.server.session.SessionConfig; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/SessionManagerFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/SessionManagerFactory.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/SessionManagerFactory.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/SessionManagerFactory.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/SessionPersistenceManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/SessionPersistenceManager.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/SessionPersistenceManager.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/SessionPersistenceManager.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; import java.util.Collections; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/SingleConstraintMatch.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/SingleConstraintMatch.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/SingleConstraintMatch.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/SingleConstraintMatch.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/ThreadSetupAction.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/ThreadSetupAction.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/ThreadSetupAction.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/ThreadSetupAction.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.api; Index: 3rdParty_sources/undertow/io/undertow/servlet/api/TransportGuaranteeType.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/TransportGuaranteeType.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/TransportGuaranteeType.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/TransportGuaranteeType.java 25 Nov 2014 10:46:56 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; /** Index: 3rdParty_sources/undertow/io/undertow/servlet/api/WebResourceCollection.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/api/Attic/WebResourceCollection.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/api/WebResourceCollection.java 9 Sep 2014 14:33:13 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/api/WebResourceCollection.java 25 Nov 2014 10:46:57 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.api; import java.util.Arrays; @@ -10,9 +28,9 @@ */ public class WebResourceCollection implements Cloneable { - private final Set httpMethods = new HashSet(); - private final Set httpMethodOmissions = new HashSet(); - private final Set urlPatterns = new HashSet(); + private final Set httpMethods = new HashSet<>(); + private final Set httpMethodOmissions = new HashSet<>(); + private final Set urlPatterns = new HashSet<>(); public WebResourceCollection addHttpMethod(final String s) { httpMethods.add(s); Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/servlet/attribute/ServletRelativePathAttribute.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/servlet/attribute/ServletRequestAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/attribute/Attic/ServletRequestAttribute.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/attribute/ServletRequestAttribute.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/attribute/ServletRequestAttribute.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.attribute; import io.undertow.attribute.ExchangeAttribute; @@ -54,5 +72,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/servlet/attribute/ServletRequestLineAttribute.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/servlet/attribute/ServletRequestURLAttribute.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/servlet/attribute/ServletSessionAttribute.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/attribute/Attic/ServletSessionAttribute.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/attribute/ServletSessionAttribute.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/attribute/ServletSessionAttribute.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.attribute; import javax.servlet.ServletRequest; @@ -70,5 +88,10 @@ } return null; } + + @Override + public int priority() { + return 0; + } } } Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/servlet/attribute/ServletSessionIdAttribute.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/servlet/core/ApplicationListeners.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/ApplicationListeners.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/ApplicationListeners.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/ApplicationListeners.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; @@ -74,7 +74,7 @@ }; private ServletContext servletContext; - private final List allListeners = new ArrayList(); + private final List allListeners = new ArrayList<>(); private ManagedListener[] servletContextListeners; private ManagedListener[] servletContextAttributeListeners; private ManagedListener[] servletRequestListeners; Index: 3rdParty_sources/undertow/io/undertow/servlet/core/BlockingWriterSenderImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/BlockingWriterSenderImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/BlockingWriterSenderImpl.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/BlockingWriterSenderImpl.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; Index: 3rdParty_sources/undertow/io/undertow/servlet/core/CompositeThreadSetupAction.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/CompositeThreadSetupAction.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/CompositeThreadSetupAction.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/CompositeThreadSetupAction.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; Index: 3rdParty_sources/undertow/io/undertow/servlet/core/ContextClassLoaderSetupAction.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/ContextClassLoaderSetupAction.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/ContextClassLoaderSetupAction.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/ContextClassLoaderSetupAction.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; Index: 3rdParty_sources/undertow/io/undertow/servlet/core/DefaultAuthorizationManager.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/DefaultAuthorizationManager.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/DefaultAuthorizationManager.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/DefaultAuthorizationManager.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.core; import io.undertow.security.idm.Account; Index: 3rdParty_sources/undertow/io/undertow/servlet/core/DeploymentImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/DeploymentImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/DeploymentImpl.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/DeploymentImpl.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; @@ -53,7 +53,7 @@ private final DeploymentManager deploymentManager; private final DeploymentInfo deploymentInfo; private final ServletContainer servletContainer; - private final List lifecycleObjects = new ArrayList(); + private final List lifecycleObjects = new ArrayList<>(); private final ServletPathMatches servletPaths; private final ManagedServlets servlets; private final ManagedFilters filters; @@ -175,7 +175,7 @@ } public void setMimeExtensionMappings(final Map mimeExtensionMappings) { - this.mimeExtensionMappings = Collections.unmodifiableMap(new HashMap(mimeExtensionMappings)); + this.mimeExtensionMappings = Collections.unmodifiableMap(new HashMap<>(mimeExtensionMappings)); } @Override Index: 3rdParty_sources/undertow/io/undertow/servlet/core/DeploymentManagerImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/DeploymentManagerImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/DeploymentManagerImpl.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/DeploymentManagerImpl.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; @@ -40,6 +40,7 @@ import io.undertow.server.handlers.PredicateHandler; import io.undertow.server.handlers.form.FormEncodedDataDefinition; import io.undertow.server.handlers.form.FormParserFactory; +import io.undertow.server.session.SessionListener; import io.undertow.server.session.SessionManager; import io.undertow.servlet.ServletExtension; import io.undertow.servlet.UndertowServletLogger; @@ -87,7 +88,6 @@ import javax.servlet.ServletContainerInitializer; import javax.servlet.ServletContext; import javax.servlet.ServletException; -import javax.servlet.SessionTrackingMode; import java.io.File; import java.nio.charset.Charset; import java.util.ArrayList; @@ -154,8 +154,11 @@ deployment.setSessionManager(deploymentInfo.getSessionManagerFactory().createSessionManager(deployment)); deployment.getSessionManager().setDefaultSessionTimeout(deploymentInfo.getDefaultSessionTimeout()); + for(SessionListener listener : deploymentInfo.getSessionListeners()) { + deployment.getSessionManager().registerSessionListener(listener); + } - final List setup = new ArrayList(); + final List setup = new ArrayList<>(); setup.add(new ContextClassLoaderSetupAction(deploymentInfo.getClassLoader())); setup.addAll(deploymentInfo.getThreadSetupActions()); final CompositeThreadSetupAction threadSetupAction = new CompositeThreadSetupAction(setup); @@ -233,7 +236,7 @@ } private void handleExtensions(final DeploymentInfo deploymentInfo, final ServletContextImpl servletContext) { - Set> loadedExtensions = new HashSet>(); + Set> loadedExtensions = new HashSet<>(); for (ServletExtension extension : ServiceLoader.load(ServletExtension.class, deploymentInfo.getClassLoader())) { loadedExtensions.add(extension.getClass()); @@ -267,7 +270,7 @@ final DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); final LoginConfig loginConfig = deploymentInfo.getLoginConfig(); - final Map factoryMap = new HashMap(deploymentInfo.getAuthenticationMechanisms()); + final Map factoryMap = new HashMap<>(deploymentInfo.getAuthenticationMechanisms()); if(!factoryMap.containsKey(BASIC_AUTH)) { factoryMap.put(BASIC_AUTH, BasicAuthenticationMechanism.FACTORY); } @@ -298,7 +301,7 @@ if (!securityPathMatches.isEmpty()) { current = new ServletSecurityConstraintHandler(securityPathMatches, current); } - List authenticationMechanisms = new LinkedList(); + List authenticationMechanisms = new LinkedList<>(); authenticationMechanisms.add(new CachedAuthenticatedSessionMechanism()); //TODO: does this really need to be hard coded? String mechName = null; @@ -323,7 +326,7 @@ mechName = method.getName(); } - final Map properties = new HashMap(); + final Map properties = new HashMap<>(); properties.put(AuthenticationMechanismFactory.CONTEXT_PATH, deploymentInfo.getContextPath()); properties.put(AuthenticationMechanismFactory.REALM, loginConfig.getRealmName()); properties.put(AuthenticationMechanismFactory.ERROR_PAGE, loginConfig.getErrorPage()); @@ -369,7 +372,7 @@ private SecurityPathMatches buildSecurityConstraints() { SecurityPathMatches.Builder builder = SecurityPathMatches.builder(deployment.getDeploymentInfo()); - final Set urlPatterns = new HashSet(); + final Set urlPatterns = new HashSet<>(); for (SecurityConstraint constraint : deployment.getDeploymentInfo().getSecurityConstraints()) { builder.addSecurityConstraint(constraint); for (WebResourceCollection webResources : constraint.getWebResourceCollections()) { @@ -380,10 +383,10 @@ for (final ServletInfo servlet : deployment.getDeploymentInfo().getServlets().values()) { final ServletSecurityInfo securityInfo = servlet.getServletSecurityInfo(); if (securityInfo != null) { - final Set mappings = new HashSet(servlet.getMappings()); + final Set mappings = new HashSet<>(servlet.getMappings()); mappings.removeAll(urlPatterns); if (!mappings.isEmpty()) { - final Set methods = new HashSet(); + final Set methods = new HashSet<>(); for (HttpMethodSecurityInfo method : securityInfo.getHttpMethodSecurityInfo()) { methods.add(method.getMethod()); @@ -427,16 +430,16 @@ } private void initializeMimeMappings(final DeploymentImpl deployment, final DeploymentInfo deploymentInfo) { - final Map mappings = new HashMap(MimeMappings.DEFAULT_MIME_MAPPINGS); + final Map mappings = new HashMap<>(MimeMappings.DEFAULT_MIME_MAPPINGS); for (MimeMapping mapping : deploymentInfo.getMimeMappings()) { mappings.put(mapping.getExtension(), mapping.getMimeType()); } deployment.setMimeExtensionMappings(mappings); } private void initializeErrorPages(final DeploymentImpl deployment, final DeploymentInfo deploymentInfo) { - final Map codes = new HashMap(); - final Map, String> exceptions = new HashMap, String>(); + final Map codes = new HashMap<>(); + final Map, String> exceptions = new HashMap<>(); String defaultErrorPage = null; for (final ErrorPage page : deploymentInfo.getErrorPages()) { if (page.getExceptionType() != null) { @@ -456,7 +459,7 @@ private ApplicationListeners createListeners() { - final List managedListeners = new ArrayList(); + final List managedListeners = new ArrayList<>(); for (final ListenerInfo listener : deployment.getDeploymentInfo().getListeners()) { managedListeners.add(new ManagedListener(listener, false)); } @@ -480,12 +483,12 @@ //we need to copy before iterating //because listeners can add other listeners - ArrayList lifecycles = new ArrayList(deployment.getLifecycleObjects()); + ArrayList lifecycles = new ArrayList<>(deployment.getLifecycleObjects()); for (Lifecycle object : lifecycles) { object.start(); } HttpHandler root = deployment.getHandler(); - final TreeMap> loadOnStartup = new TreeMap>(); + final TreeMap> loadOnStartup = new TreeMap<>(); for(Map.Entry entry: deployment.getServlets().getServletHandlers().entrySet()) { ManagedServlet servlet = entry.getValue().getManagedServlet(); Integer loadOnStartupNumber = servlet.getServletInfo().getLoadOnStartup(); @@ -495,7 +498,7 @@ } List list = loadOnStartup.get(loadOnStartupNumber); if(list == null) { - loadOnStartup.put(loadOnStartupNumber, list = new ArrayList()); + loadOnStartup.put(loadOnStartupNumber, list = new ArrayList<>()); } list.add(servlet); } @@ -559,7 +562,7 @@ } sessionCookieConfig.setSecure(sc.isSecure()); if (sc.getSessionTrackingModes() != null) { - servletContext.setDefaultSessionTrackingModes(new HashSet(sc.getSessionTrackingModes())); + servletContext.setDefaultSessionTrackingModes(new HashSet<>(sc.getSessionTrackingModes())); } } } Index: 3rdParty_sources/undertow/io/undertow/servlet/core/ErrorPages.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/ErrorPages.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/ErrorPages.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/ErrorPages.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; Index: 3rdParty_sources/undertow/io/undertow/servlet/core/InMemorySessionManagerFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/InMemorySessionManagerFactory.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/InMemorySessionManagerFactory.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/InMemorySessionManagerFactory.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; Index: 3rdParty_sources/undertow/io/undertow/servlet/core/Lifecycle.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/Lifecycle.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/Lifecycle.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/Lifecycle.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/servlet/core/LifecyleInterceptorInvocation.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/ManagedFilter.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedFilter.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedFilter.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; @@ -76,7 +76,7 @@ throw UndertowServletMessages.MESSAGES.couldNotInstantiateComponent(filterInfo.getName(), e); } Filter filter = handle.getInstance(); - filter.init(new FilterConfigImpl(filterInfo, servletContext)); + new LifecyleInterceptorInvocation(servletContext.getDeployment().getDeploymentInfo().getLifecycleInterceptors(), filterInfo, filter, new FilterConfigImpl(filterInfo, servletContext)).proceed(); this.filter = filter; } } @@ -92,7 +92,11 @@ public synchronized void stop() { started = false; if (handle != null) { - filter.destroy(); + try { + new LifecyleInterceptorInvocation(servletContext.getDeployment().getDeploymentInfo().getLifecycleInterceptors(), filterInfo, filter).proceed(); + } catch (ServletException e) { + throw new RuntimeException(e); + } handle.release(); } filter = null; Index: 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedFilters.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/ManagedFilters.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedFilters.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedFilters.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.core; import java.util.HashMap; @@ -14,7 +32,7 @@ */ public class ManagedFilters { - private final Map managedFilterMap = new CopyOnWriteMap(); + private final Map managedFilterMap = new CopyOnWriteMap<>(); private final DeploymentImpl deployment; private final ServletPathMatches servletPathMatches; @@ -36,7 +54,7 @@ } public Map getFilters() { - return new HashMap(managedFilterMap); + return new HashMap<>(managedFilterMap); } } Index: 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/ManagedListener.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedListener.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedListener.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; Index: 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedServlet.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/ManagedServlet.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedServlet.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedServlet.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,16 +9,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; import java.io.File; +import java.util.List; import javax.servlet.MultipartConfigElement; import javax.servlet.Servlet; @@ -35,6 +36,7 @@ import io.undertow.servlet.api.DeploymentManager; import io.undertow.servlet.api.InstanceFactory; import io.undertow.servlet.api.InstanceHandle; +import io.undertow.servlet.api.LifecycleInterceptor; import io.undertow.servlet.api.ServletInfo; import io.undertow.servlet.spec.ServletConfigImpl; import io.undertow.servlet.spec.ServletContextImpl; @@ -53,8 +55,8 @@ private final InstanceStrategy instanceStrategy; private volatile boolean permanentlyUnavailable = false; - private final long maxRequestSize; - private final FormParserFactory formParserFactory; + private long maxRequestSize; + private FormParserFactory formParserFactory; public ManagedServlet(final ServletInfo servletInfo, final ServletContextImpl servletContext) { this.servletInfo = servletInfo; @@ -64,6 +66,10 @@ } else { instanceStrategy = new DefaultInstanceStrategy(servletInfo.getInstanceFactory(), servletInfo, servletContext); } + setupMultipart(servletContext); + } + + public void setupMultipart(ServletContextImpl servletContext) { FormEncodedDataDefinition formDataParser = new FormEncodedDataDefinition() .setDefaultEncoding(servletContext.getDeployment().getDeploymentInfo().getDefaultEncoding()); if (servletInfo.getMultipartConfig() != null) { @@ -74,7 +80,7 @@ } else { maxRequestSize = -1; } - final File tempDir; + final File tempDir; if(config.getLocation() == null || config.getLocation().isEmpty()) { tempDir = servletContext.getDeployment().getDeploymentInfo().getTempDir(); } else { @@ -211,7 +217,8 @@ throw UndertowServletMessages.MESSAGES.couldNotInstantiateComponent(servletInfo.getName(), e); } instance = handle.getInstance(); - instance.init(new ServletConfigImpl(servletInfo, servletContext)); + new LifecyleInterceptorInvocation(servletContext.getDeployment().getDeploymentInfo().getLifecycleInterceptors(), servletInfo, instance, new ServletConfigImpl(servletInfo, servletContext)).proceed(); + //if a servlet implements FileChangeCallback it will be notified of file change events final ResourceManager resourceManager = servletContext.getDeployment().getDeploymentInfo().getResourceManager(); if(instance instanceof ResourceChangeListener && resourceManager.isResourceChangeListenerSupported()) { @@ -225,11 +232,20 @@ if(changeListener != null) { resourceManager.removeResourceChangeListener(changeListener); } - instance.destroy(); + invokeDestroy(); handle.release(); } } + private void invokeDestroy() { + List interceptors = servletContext.getDeployment().getDeploymentInfo().getLifecycleInterceptors(); + try { + new LifecyleInterceptorInvocation(interceptors, servletInfo, instance).proceed(); + } catch (ServletException e) { + throw new RuntimeException(e); + } + } + public InstanceHandle getServlet() { return new InstanceHandle() { @Override @@ -282,8 +298,8 @@ throw UndertowServletMessages.MESSAGES.couldNotInstantiateComponent(servletInfo.getName(), e); } instance = instanceHandle.getInstance(); + new LifecyleInterceptorInvocation(servletContext.getDeployment().getDeploymentInfo().getLifecycleInterceptors(), servletInfo, instance, new ServletConfigImpl(servletInfo, servletContext)).proceed(); - instance.init(new ServletConfigImpl(servletInfo, servletContext)); return new InstanceHandle() { @Override public Servlet getInstance() { Index: 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedServlets.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/ManagedServlets.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedServlets.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/ManagedServlets.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.core; import java.util.HashMap; @@ -15,7 +33,7 @@ */ public class ManagedServlets { - private final Map managedServletMap = new CopyOnWriteMap(); + private final Map managedServletMap = new CopyOnWriteMap<>(); private final DeploymentImpl deployment; private final ServletPathMatches servletPaths; @@ -47,7 +65,7 @@ } public Map getServletHandlers() { - return new HashMap(managedServletMap); + return new HashMap<>(managedServletMap); } } Index: 3rdParty_sources/undertow/io/undertow/servlet/core/MetricsChainHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/MetricsChainHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/MetricsChainHandler.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/MetricsChainHandler.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.core; import io.undertow.server.HttpHandler; @@ -24,7 +42,7 @@ public MetricsChainHandler(HttpHandler next, MetricsCollector collector, Deployment deployment) { this.next = next; - final Map servletHandlers = new HashMap(); + final Map servletHandlers = new HashMap<>(); for(Map.Entry entry : deployment.getServlets().getServletHandlers().entrySet()) { MetricsHandler handler = new MetricsHandler(next); servletHandlers.put(entry.getKey(), handler); Index: 3rdParty_sources/undertow/io/undertow/servlet/core/SecurityActions.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/SecurityActions.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/SecurityActions.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/SecurityActions.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; Index: 3rdParty_sources/undertow/io/undertow/servlet/core/ServletBlockingHttpExchange.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/ServletBlockingHttpExchange.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/ServletBlockingHttpExchange.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/ServletBlockingHttpExchange.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.core; import java.io.IOException; @@ -62,15 +80,23 @@ @Override public void close() throws IOException { + ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (!exchange.isComplete()) { - ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); try { HttpServletRequestImpl request = servletRequestContext.getOriginalRequest(); request.closeAndDrainRequest(); } finally { HttpServletResponseImpl response = servletRequestContext.getOriginalResponse(); response.closeStreamAndWriter(); } + } else { + try { + HttpServletRequestImpl request = servletRequestContext.getOriginalRequest(); + request.freeResources(); + } finally { + HttpServletResponseImpl response = servletRequestContext.getOriginalResponse(); + response.freeResources(); + } } } } Index: 3rdParty_sources/undertow/io/undertow/servlet/core/ServletContainerImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/ServletContainerImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/ServletContainerImpl.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/ServletContainerImpl.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.core; @@ -42,7 +42,7 @@ @Override public Collection listDeployments() { - return new HashSet(deployments.keySet()); + return new HashSet<>(deployments.keySet()); } @Override Index: 3rdParty_sources/undertow/io/undertow/servlet/core/ServletUpgradeListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/ServletUpgradeListener.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/ServletUpgradeListener.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/ServletUpgradeListener.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.core; import io.undertow.server.HttpServerExchange; @@ -73,7 +91,7 @@ private final Executor delegate; private volatile boolean queue = true; - private final List tasks = new ArrayList(); + private final List tasks = new ArrayList<>(); private DelayedExecutor(Executor delegate) { this.delegate = delegate; Index: 3rdParty_sources/undertow/io/undertow/servlet/core/SessionListenerBridge.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/core/Attic/SessionListenerBridge.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/core/SessionListenerBridge.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/core/SessionListenerBridge.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.core; import javax.servlet.ServletContext; @@ -11,6 +29,7 @@ import io.undertow.servlet.handlers.ServletRequestContext; import io.undertow.servlet.spec.HttpSessionImpl; +import java.security.AccessController; import java.util.HashSet; /** @@ -48,7 +67,7 @@ applicationListeners.sessionDestroyed(httpSession); //we make a defensive copy here, as there is no guarantee that the underlying session map //is a concurrent map, and as a result a concurrent modification exception may be thrown - HashSet names = new HashSet(session.getAttributeNames()); + HashSet names = new HashSet<>(session.getAttributeNames()); for(String attribute : names) { session.removeAttribute(attribute); } @@ -57,7 +76,16 @@ handle.tearDown(); } ServletRequestContext current = SecurityActions.currentServletRequestContext(); - if (current != null) { + Session underlying = null; + if(current != null && current.getSession() != null) { + if(System.getSecurityManager() == null) { + underlying = current.getSession().getSession(); + } else { + underlying = AccessController.doPrivileged(new HttpSessionImpl.UnwrapSessionAction(current.getSession())); + } + } + + if (current != null && underlying == session) { current.setSession(null); } } Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/DefaultServlet.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/DefaultServlet.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/DefaultServlet.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/DefaultServlet.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers; @@ -27,6 +27,7 @@ import io.undertow.servlet.api.DefaultServletConfig; import io.undertow.servlet.api.Deployment; import io.undertow.servlet.spec.ServletContextImpl; +import io.undertow.util.CanonicalPathUtils; import io.undertow.util.DateUtils; import io.undertow.util.ETag; import io.undertow.util.ETagUtils; @@ -40,6 +41,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Arrays; @@ -73,8 +75,7 @@ public static final String DISALLOWED_EXTENSIONS = "disallowed-extensions"; public static final String RESOLVE_AGAINST_CONTEXT_ROOT = "resolve-against-context-root"; - private static final Set DEFAULT_ALLOWED_EXTENSIONS = Collections.unmodifiableSet(new HashSet(Arrays.asList("js", "css", "png", "jpg", "gif", "html", "htm", "txt", "pdf", "jpeg", "xml"))); - private static final Set DEFAULT_DISALLOWED_EXTENSIONS = Collections.unmodifiableSet(new HashSet(Arrays.asList("class", "jar", "war"))); + private static final Set DEFAULT_ALLOWED_EXTENSIONS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("js", "css", "png", "jpg", "gif", "html", "htm", "txt", "pdf", "jpeg", "xml"))); private Deployment deployment; @@ -83,7 +84,7 @@ private boolean defaultAllowed = true; private Set allowed = DEFAULT_ALLOWED_EXTENSIONS; - private Set disallowed = DEFAULT_DISALLOWED_EXTENSIONS; + private Set disallowed = Collections.emptySet(); private boolean resolveAgainstContextRoot; @Override @@ -94,11 +95,11 @@ DefaultServletConfig defaultServletConfig = deployment.getDeploymentInfo().getDefaultServletConfig(); if (defaultServletConfig != null) { defaultAllowed = defaultServletConfig.isDefaultAllowed(); - allowed = new HashSet(); + allowed = new HashSet<>(); if (defaultServletConfig.getAllowed() != null) { allowed.addAll(defaultServletConfig.getAllowed()); } - disallowed = new HashSet(); + disallowed = new HashSet<>(); if (defaultServletConfig.getDisallowed() != null) { disallowed.addAll(defaultServletConfig.getDisallowed()); } @@ -108,11 +109,11 @@ } if (config.getInitParameter(ALLOWED_EXTENSIONS) != null) { String extensions = config.getInitParameter(ALLOWED_EXTENSIONS); - allowed = new HashSet(Arrays.asList(extensions.split(","))); + allowed = new HashSet<>(Arrays.asList(extensions.split(","))); } if (config.getInitParameter(DISALLOWED_EXTENSIONS) != null) { String extensions = config.getInitParameter(DISALLOWED_EXTENSIONS); - disallowed = new HashSet(Arrays.asList(extensions.split(","))); + disallowed = new HashSet<>(Arrays.asList(extensions.split(","))); } if (config.getInitParameter(RESOLVE_AGAINST_CONTEXT_ROOT) != null) { resolveAgainstContextRoot = Boolean.parseBoolean(config.getInitParameter(RESOLVE_AGAINST_CONTEXT_ROOT)); @@ -126,12 +127,22 @@ @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { - final String path = getPath(req); - if (!isAllowed(path)) { + String path = getPath(req); + if (!isAllowed(path, req.getDispatcherType())) { resp.sendError(404); return; } - final Resource resource = resourceManager.getResource(path); + if(File.separatorChar != '/') { + //if the separator char is not / we want to replace it with a / and canonicalise + path = CanonicalPathUtils.canonicalize(path.replace(File.separatorChar, '/')); + } + final Resource resource; + //we want to disallow windows characters in the path + if(File.separatorChar == '/' || !path.contains(File.separator)) { + resource = resourceManager.getResource(path); + } else { + resource = null; + } if (resource == null) { if (req.getDispatcherType() == DispatcherType.INCLUDE) { //servlet 9.3 @@ -244,11 +255,13 @@ } //todo: handle range requests //we are going to proceed. Set the appropriate headers - final String contentType = deployment.getServletContext().getMimeType(resource.getName()); - if (contentType != null) { - resp.setHeader(Headers.CONTENT_TYPE_STRING, contentType); - } else { - resp.setHeader(Headers.CONTENT_TYPE_STRING, "application/octet-stream"); + if(resp.getContentType() == null) { + final String contentType = deployment.getServletContext().getMimeType(resource.getName()); + if (contentType != null) { + resp.setContentType(contentType); + } else { + resp.setContentType("application/octet-stream"); + } } if (lastModified != null) { resp.setHeader(Headers.LAST_MODIFIED_STRING, resource.getLastModifiedString()); @@ -297,7 +310,6 @@ if (request.getDispatcherType() == DispatcherType.INCLUDE && request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != null) { pathInfo = (String) request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO); servletPath = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH); - } else { pathInfo = request.getPathInfo(); servletPath = request.getServletPath(); @@ -306,7 +318,9 @@ if (result == null) { result = servletPath; } else if(resolveAgainstContextRoot) { - result = servletPath + pathInfo; + result = servletPath + CanonicalPathUtils.canonicalize(pathInfo); + } else { + result = CanonicalPathUtils.canonicalize(result); } if ((result == null) || (result.equals(""))) { result = "/"; @@ -315,13 +329,16 @@ } - private boolean isAllowed(String path) { + private boolean isAllowed(String path, DispatcherType dispatcherType) { if (!path.isEmpty()) { - if (path.startsWith("/META-INF") || - path.startsWith("META-INF") || - path.startsWith("/WEB-INF") || - path.startsWith("WEB-INF")) { - return false; + if(dispatcherType == DispatcherType.REQUEST) { + //WFLY-3543 allow the dispatcher to access stuff in web-inf and meta inf + if (path.startsWith("/META-INF") || + path.startsWith("META-INF") || + path.startsWith("/WEB-INF") || + path.startsWith("WEB-INF")) { + return false; + } } } int pos = path.lastIndexOf('/'); Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/FilterHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/FilterHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/FilterHandler.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/FilterHandler.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers; @@ -51,8 +51,8 @@ public FilterHandler(final Map> filters, final boolean allowNonStandardWrappers, final HttpHandler next) { this.allowNonStandardWrappers = allowNonStandardWrappers; this.next = next; - this.filters = new EnumMap>(filters); - Map asyncSupported = new EnumMap(DispatcherType.class); + this.filters = new EnumMap<>(filters); + Map asyncSupported = new EnumMap<>(DispatcherType.class); for(Map.Entry> entry : filters.entrySet()) { boolean supported = true; for(ManagedFilter i : entry.getValue()) { Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/SecurityActions.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/SecurityActions.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/SecurityActions.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/SecurityActions.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletChain.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/ServletChain.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletChain.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletChain.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.handlers; import java.util.concurrent.Executor; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletDebugPageHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/ServletDebugPageHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletDebugPageHandler.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletDebugPageHandler.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.handlers; import io.undertow.server.HttpServerExchange; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletDispatchingHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/ServletDispatchingHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletDispatchingHandler.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletDispatchingHandler.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/ServletHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletHandler.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletHandler.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletInitialHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/ServletInitialHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletInitialHandler.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletInitialHandler.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers; @@ -24,6 +24,8 @@ import io.undertow.server.HttpUpgradeListener; import io.undertow.server.SSLSessionInfo; import io.undertow.server.ServerConnection; +import io.undertow.servlet.api.ExceptionHandler; +import io.undertow.servlet.api.LoggingExceptionHandler; import io.undertow.servlet.api.ServletDispatcher; import io.undertow.servlet.api.ThreadSetupAction; import io.undertow.servlet.core.ApplicationListeners; @@ -37,6 +39,7 @@ import io.undertow.util.HttpString; import io.undertow.util.Protocols; import io.undertow.util.RedirectBuilder; +import io.undertow.util.StatusCodes; import org.xnio.BufferAllocator; import org.xnio.ByteBufferSlicePool; import org.xnio.ChannelListener; @@ -72,6 +75,8 @@ */ public class ServletInitialHandler implements HttpHandler, ServletDispatcher { + private static final String HTTP2_UPGRADE_PREFIX = "h2"; + private static final RuntimePermission PERMISSION = new RuntimePermission("io.undertow.servlet.CREATE_INITIAL_HANDLER"); private final HttpHandler next; @@ -85,6 +90,8 @@ private final ServletPathMatches paths; + private final ExceptionHandler exceptionHandler; + public ServletInitialHandler(final ServletPathMatches paths, final HttpHandler next, final CompositeThreadSetupAction setupAction, final ServletContextImpl servletContext) { this.next = next; this.setupAction = setupAction; @@ -96,6 +103,12 @@ //we need to make sure this is not abused AccessController.checkPermission(PERMISSION); } + ExceptionHandler handler = servletContext.getDeployment().getDeploymentInfo().getExceptionHandler(); + if(handler != null) { + this.exceptionHandler = handler; + } else { + this.exceptionHandler = LoggingExceptionHandler.DEFAULT; + } } @Override @@ -106,7 +119,14 @@ return; } final ServletPathMatch info = paths.getServletHandlerByPath(path); - if (info.getType() == ServletPathMatch.Type.REDIRECT) { + //https://issues.jboss.org/browse/WFLY-3439 + //if the request is an upgrade request then we don't want to redirect + //as there is a good chance the web socket client won't understand the redirect + //we make an exception for HTTP2 upgrade requests, as this would have already be handled at + //the connector level if it was going to be handled. + String upgradeString = exchange.getRequestHeaders().getFirst(Headers.UPGRADE); + boolean isUpgradeRequest = upgradeString != null && !upgradeString.startsWith(HTTP2_UPGRADE_PREFIX); + if (info.getType() == ServletPathMatch.Type.REDIRECT && !isUpgradeRequest) { //UNDERTOW-89 //we redirect on GET requests to the root context to add an / to the end exchange.setResponseCode(302); @@ -235,20 +255,22 @@ ThreadSetupAction.Handle handle = setupAction.setup(exchange); try { SecurityActions.setCurrentRequestContext(servletRequestContext); + servletRequestContext.setRunningInsideHandler(true); try { listeners.requestInitialized(request); next.handleRequest(exchange); // + if(servletRequestContext.getErrorCode() > 0) { + servletRequestContext.getOriginalResponse().doErrorDispatch(servletRequestContext.getErrorCode(), servletRequestContext.getErrorMessage()); + } } catch (Throwable t) { - if(t instanceof IOException) { - //we log IOExceptions at a lower level - //because they can be easily caused by malicious remote clients in at attempt to DOS the server by filling the logs - UndertowLogger.REQUEST_IO_LOGGER.debugf(t, "Exception handling request to %s", exchange.getRequestURI()); - } else { - UndertowLogger.REQUEST_LOGGER.exceptionHandlingRequest(t, exchange.getRequestURI()); - } - if (request.isAsyncStarted() || request.getDispatcherType() == DispatcherType.ASYNC) { + //by default this will just log the exception + boolean handled = exceptionHandler.handleThrowable(exchange, request, response, t); + + if(handled) { + exchange.endExchange(); + } else if (request.isAsyncStarted() || request.getDispatcherType() == DispatcherType.ASYNC) { exchange.unDispatch(); servletRequestContext.getOriginalRequest().getAsyncContextInternal().handleError(t); } else { @@ -257,29 +279,28 @@ exchange.setResponseCode(500); exchange.getResponseHeaders().clear(); String location = servletContext.getDeployment().getErrorPages().getErrorLocation(t); + if (location == null) { + location = servletContext.getDeployment().getErrorPages().getErrorLocation(500); + } if (location != null) { RequestDispatcherImpl dispatcher = new RequestDispatcherImpl(location, servletContext); try { - dispatcher.error(request, response, servletChain.getManagedServlet().getServletInfo().getName(), t); + dispatcher.error(servletRequestContext, request, response, servletChain.getManagedServlet().getServletInfo().getName(), t); } catch (Exception e) { UndertowLogger.REQUEST_LOGGER.exceptionGeneratingErrorPage(e, location); } } else { if (servletRequestContext.displayStackTraces()) { ServletDebugPageHandler.handleRequest(exchange, servletRequestContext, t); } else { - //TODO: we need a debug mode to generate a debug error page - if (response instanceof HttpServletResponse) { - ((HttpServletResponse) response).sendError(500); - } else { - servletRequestContext.getOriginalResponse().sendError(500); - } + servletRequestContext.getOriginalResponse().doErrorDispatch(500, StatusCodes.INTERNAL_SERVER_ERROR_STRING); } } } } } finally { + servletRequestContext.setRunningInsideHandler(false); listeners.requestDestroyed(request); } //if it is not dispatched and is not a mock request @@ -328,6 +349,11 @@ } @Override + public void terminateRequestChannel(HttpServerExchange exchange) { + + } + + @Override public boolean isOpen() { return true; } @@ -433,6 +459,10 @@ protected void setUpgradeListener(HttpUpgradeListener upgradeListener) { //ignore } + + @Override + protected void maxEntitySizeUpdated(HttpServerExchange exchange) { + } } } Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletPathMatch.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/ServletPathMatch.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletPathMatch.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletPathMatch.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletPathMatches.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/ServletPathMatches.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletPathMatches.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletPathMatches.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers; @@ -34,6 +34,7 @@ import io.undertow.servlet.handlers.security.ServletSecurityRoleHandler; import javax.servlet.DispatcherType; +import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.EnumMap; @@ -126,9 +127,12 @@ } private ServletPathMatch findWelcomeFile(final String path, boolean requiresRedirect) { + if(File.separatorChar != '/' && path.contains(File.separator)) { + return null; + } for (String i : welcomePages) { try { - String mergedPath = path + i; + final String mergedPath = path + i; Resource resource = resourceManager.getResource(mergedPath); if (resource != null) { final ServletPathMatch handler = data.getServletHandlerByPath(mergedPath); @@ -166,11 +170,11 @@ final ManagedServlets servlets = deployment.getServlets(); final ManagedFilters filters = deployment.getFilters(); - final Map extensionServlets = new HashMap(); - final Map pathServlets = new HashMap(); + final Map extensionServlets = new HashMap<>(); + final Map pathServlets = new HashMap<>(); - final Set pathMatches = new HashSet(); - final Set extensionMatches = new HashSet(); + final Set pathMatches = new HashSet<>(); + final Set extensionMatches = new HashSet<>(); DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); @@ -240,8 +244,8 @@ //resolve the target servlet, will return null if this is the default servlet MatchData targetServletMatch = resolveServletForPath(path, pathServlets, extensionServlets, defaultServlet); - final Map> noExtension = new EnumMap>(DispatcherType.class); - final Map>> extension = new HashMap>>(); + final Map> noExtension = new EnumMap<>(DispatcherType.class); + final Map>> extension = new HashMap<>(); //initalize the extension map. This contains all the filers in the noExtension map, plus //any filters that match the extension key for (String ext : extensionMatches) { @@ -308,7 +312,13 @@ builder.addExactMatch("/", createHandler(deploymentInfo, targetServletMatch.handler, noExtension, targetServletMatch.matchedPath, targetServletMatch.defaultServlet)); } else { //we need to check for an extension match, so paths like /exact.txt will have the correct filter applied - String lastSegment = path.substring(path.lastIndexOf('/')); + int lastSegmentIndex = path.lastIndexOf('/'); + String lastSegment; + if(lastSegmentIndex > 0) { + lastSegment = path.substring(lastSegmentIndex); + } else { + lastSegment = path; + } if (lastSegment.contains(".")) { String ext = lastSegment.substring(lastSegment.lastIndexOf('.') + 1); if (extension.containsKey(ext)) { @@ -327,7 +337,7 @@ //now setup name based mappings //these are used for name based dispatch for (Map.Entry entry : servlets.getServletHandlers().entrySet()) { - final Map> filtersByDispatcher = new EnumMap>(DispatcherType.class); + final Map> filtersByDispatcher = new EnumMap<>(DispatcherType.class); for (final FilterMappingInfo filterMapping : deploymentInfo.getFilterMappings()) { ManagedFilter filter = filters.getManagedFilter(filterMapping.getFilterName()); if (filterMapping.getMappingType() == FilterMappingInfo.MappingType.SERVLET) { @@ -416,7 +426,7 @@ private static void addToListMap(final Map> map, final K key, final V value) { List list = map.get(key); if (list == null) { - map.put(key, list = new ArrayList()); + map.put(key, list = new ArrayList<>()); } list.add(value); } Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletPathMatchesData.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/ServletPathMatchesData.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletPathMatchesData.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletPathMatchesData.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers; @@ -40,9 +40,9 @@ public ServletPathMatchesData(final Map exactPathMatches, final Map prefixMatches, final Map nameMatches) { this.prefixMatches = prefixMatches; this.nameMatches = nameMatches; - Map newExactPathMatches = new HashMap(); + Map newExactPathMatches = new HashMap<>(); for (Map.Entry entry : exactPathMatches.entrySet()) { - newExactPathMatches.put(entry.getKey(), new ServletPathMatch(entry.getValue(), entry.getKey(), false)); + newExactPathMatches.put(entry.getKey(), new ServletPathMatch(entry.getValue(), entry.getKey(), entry.getValue().isDefaultServletMapping())); } this.exactPathMatches = newExactPathMatches; @@ -74,10 +74,8 @@ if (match != null) { return handleMatch(path, match, extensionPos); } - } else if (c == '.') { - if (extensionPos == -1) { + } else if (c == '.' && extensionPos == -1) { extensionPos = i; - } } } //this should never happen @@ -88,20 +86,17 @@ private ServletPathMatch handleMatch(final String path, final PathMatch match, final int extensionPos) { if (match.extensionMatches.isEmpty()) { return new ServletPathMatch(match.defaultHandler, path, match.requireWelcomeFileMatch); - } else { - if (extensionPos == -1) { - return new ServletPathMatch(match.defaultHandler, path, match.requireWelcomeFileMatch); - } else { - final String ext; - ext = path.substring(extensionPos + 1, path.length()); - ServletChain handler = match.extensionMatches.get(ext); - if (handler != null) { - return new ServletPathMatch(handler, path, handler.getManagedServlet().getServletInfo().isRequireWelcomeFileMapping()); - } else { - return new ServletPathMatch(match.defaultHandler, path, match.requireWelcomeFileMatch); - } - } } + if (extensionPos == -1) { + return new ServletPathMatch(match.defaultHandler, path, match.requireWelcomeFileMatch); + } + final String ext; + ext = path.substring(extensionPos + 1, path.length()); + ServletChain handler = match.extensionMatches.get(ext); + if (handler != null) { + return new ServletPathMatch(handler, path, handler.getManagedServlet().getServletInfo().isRequireWelcomeFileMapping()); + } + return new ServletPathMatch(match.defaultHandler, path, match.requireWelcomeFileMatch); } public static Builder builder() { @@ -110,11 +105,11 @@ public static final class Builder { - private final Map exactPathMatches = new HashMap(); + private final Map exactPathMatches = new HashMap<>(); - private final Map prefixMatches = new HashMap(); + private final Map prefixMatches = new HashMap<>(); - private final Map nameMatches = new HashMap(); + private final Map nameMatches = new HashMap<>(); public void addExactMatch(final String exactMatch, final ServletChain match) { exactPathMatches.put(exactMatch, match); @@ -150,7 +145,7 @@ private static class PathMatch { - private final Map extensionMatches = new HashMap(); + private final Map extensionMatches = new HashMap<>(); private volatile ServletChain defaultHandler; private volatile boolean requireWelcomeFileMatch; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletRequestContext.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/ServletRequestContext.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletRequestContext.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/ServletRequestContext.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,5 +1,24 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.handlers; +import java.net.InetAddress; import java.net.InetSocketAddress; import java.security.AccessController; import java.util.List; @@ -38,7 +57,7 @@ private static final RuntimePermission GET_CURRENT_REQUEST = new RuntimePermission("io.undertow.servlet.GET_CURRENT_REQUEST"); private static final RuntimePermission SET_CURRENT_REQUEST = new RuntimePermission("io.undertow.servlet.SET_CURRENT_REQUEST"); - private static final ThreadLocal CURRENT = new ThreadLocal(); + private static final ThreadLocal CURRENT = new ThreadLocal<>(); public static void setCurrentRequestContext(ServletRequestContext servletRequestContext) { if(System.getSecurityManager() != null) { @@ -91,6 +110,13 @@ private ServletContextImpl currentServletContext; + /** + * If this is true the request is running inside the context of ServletInitialHandler + */ + private boolean runningInsideHandler = false; + private int errorCode = -1; + private String errorMessage; + public ServletRequestContext(final Deployment deployment, final HttpServletRequestImpl originalRequest, final HttpServletResponseImpl originalResponse, final ServletPathMatch originalServletPathMatch) { this.deployment = deployment; this.originalRequest = originalRequest; @@ -204,11 +230,36 @@ if(localAddress == null) { return false; } - if(!localAddress.getAddress().isLoopbackAddress()) { + InetAddress address = localAddress.getAddress(); + if(address == null) { return false; } + if(!address.isLoopbackAddress()) { + return false; + } return !getExchange().getRequestHeaders().contains(Headers.X_FORWARDED_FOR); } } + + public void setError(int sc, String msg) { + this.errorCode = sc; + this.errorMessage = msg; + } + + public int getErrorCode() { + return errorCode; + } + + public String getErrorMessage() { + return errorMessage; + } + + public boolean isRunningInsideHandler() { + return runningInsideHandler; + } + + public void setRunningInsideHandler(boolean runningInsideHandler) { + this.runningInsideHandler = runningInsideHandler; + } } Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/SessionRestoringHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/Attic/SessionRestoringHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/SessionRestoringHandler.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/SessionRestoringHandler.java 25 Nov 2014 10:46:54 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.handlers; import io.undertow.server.HttpHandler; @@ -44,7 +62,7 @@ this.servletContext = servletContext; this.next = next; this.sessionPersistenceManager = sessionPersistenceManager; - this.data = new ConcurrentHashMap(); + this.data = new ConcurrentHashMap<>(); } public void start() { @@ -71,12 +89,12 @@ try { setTccl(servletContext.getClassLoader()); this.started = false; - final Map objectData = new HashMap(); + final Map objectData = new HashMap<>(); for (String sessionId : sessionManager.getTransientSessions()) { Session session = sessionManager.getSession(sessionId); if (session != null) { final HttpSessionEvent event = new HttpSessionEvent(SecurityActions.forSession(session, servletContext, false)); - final Map sessionData = new HashMap(); + final Map sessionData = new HashMap<>(); for (String attr : session.getAttributeNames()) { final Object attribute = session.getAttribute(attr); sessionData.put(attr, attribute); @@ -112,9 +130,13 @@ for (Map.Entry entry : result.getSessionData().entrySet()) { if (entry.getValue() instanceof HttpSessionActivationListener) { - ((HttpSessionActivationListener) entry.getValue()).sessionWillPassivate(event); + ((HttpSessionActivationListener) entry.getValue()).sessionDidActivate(event); } - session.setAttribute(entry.getKey(), entry.getValue()); + if(entry.getKey().startsWith(HttpSessionImpl.IO_UNDERTOW)) { + session.getSession().setAttribute(entry.getKey(), entry.getValue()); + } else { + session.setAttribute(entry.getKey(), entry.getValue()); + } } } } Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/CachedAuthenticatedSessionHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/security/Attic/CachedAuthenticatedSessionHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/CachedAuthenticatedSessionHandler.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/CachedAuthenticatedSessionHandler.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers.security; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/SSLInformationAssociationHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/security/Attic/SSLInformationAssociationHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/SSLInformationAssociationHandler.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/SSLInformationAssociationHandler.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.handlers.security; import java.io.ByteArrayInputStream; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/SecurityPathMatch.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/security/Attic/SecurityPathMatch.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/SecurityPathMatch.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/SecurityPathMatch.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers.security; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/SecurityPathMatches.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/security/Attic/SecurityPathMatches.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/SecurityPathMatches.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/SecurityPathMatches.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.handlers.security; import java.util.ArrayList; @@ -53,11 +71,13 @@ PathSecurityInformation match = exactPathRoleInformation.get(path); if (match != null) { handleMatch(method, match, currentMatch); + return new SecurityPathMatch(currentMatch.type, mergeConstraints(currentMatch)); } match = prefixPathRoleInformation.get(path); if (match != null) { handleMatch(method, match, currentMatch); + return new SecurityPathMatch(currentMatch.type, mergeConstraints(currentMatch)); } int qsPos = -1; @@ -70,6 +90,7 @@ match = exactPathRoleInformation.get(part); if (match != null) { handleMatch(method, match, currentMatch); + return new SecurityPathMatch(currentMatch.type, mergeConstraints(currentMatch)); } qsPos = i; extension = false; @@ -79,6 +100,7 @@ match = prefixPathRoleInformation.get(part); if (match != null) { handleMatch(method, match, currentMatch); + return new SecurityPathMatch(currentMatch.type, mergeConstraints(currentMatch)); } } else if (c == '.') { if (!extension) { @@ -92,24 +114,22 @@ match = extensionRoleInformation.get(ext); if (match != null) { handleMatch(method, match, currentMatch); + return new SecurityPathMatch(currentMatch.type, mergeConstraints(currentMatch)); } } } } - - return new SecurityPathMatch(currentMatch.type, mergeConstraints(currentMatch)); } /** * merge all constraints, as per 13.8.1 Combining Constraints - * @param constraintSet */ private SingleConstraintMatch mergeConstraints(final RuntimeMatch currentMatch) { if(currentMatch.uncovered && denyUncoveredHttpMethods) { return new SingleConstraintMatch(SecurityInfo.EmptyRoleSemantic.DENY, Collections.emptySet()); } - final Set allowedRoles = new HashSet(); + final Set allowedRoles = new HashSet<>(); for(SingleConstraintMatch match : currentMatch.constraints) { if(match.getRequiredRoles().isEmpty()) { return new SingleConstraintMatch(match.getEmptyRoleSemantic(), Collections.emptySet()); @@ -159,9 +179,9 @@ public static class Builder { private final DeploymentInfo deploymentInfo; private final PathSecurityInformation defaultPathSecurityInformation = new PathSecurityInformation(); - private final Map exactPathRoleInformation = new HashMap(); - private final Map prefixPathRoleInformation = new HashMap(); - private final Map extensionRoleInformation = new HashMap(); + private final Map exactPathRoleInformation = new HashMap<>(); + private final Map prefixPathRoleInformation = new HashMap<>(); + private final Map extensionRoleInformation = new HashMap<>(); private Builder(final DeploymentInfo deploymentInfo) { this.deploymentInfo = deploymentInfo; @@ -203,7 +223,7 @@ } private Set expandRolesAllowed(final Set rolesAllowed) { - final Set roles = new HashSet(rolesAllowed); + final Set roles = new HashSet<>(rolesAllowed); if (roles.contains("*")) { roles.remove("*"); roles.addAll(deploymentInfo.getSecurityRoles()); @@ -220,7 +240,7 @@ for (String method : webResources.getHttpMethods()) { List securityInformations = info.perMethodRequiredRoles.get(method); if (securityInformations == null) { - info.perMethodRequiredRoles.put(method, securityInformations = new ArrayList()); + info.perMethodRequiredRoles.put(method, securityInformations = new ArrayList<>()); } securityInformations.add(securityConstraint); } @@ -236,9 +256,9 @@ private static class PathSecurityInformation { - final List defaultRequiredRoles = new ArrayList(); - final Map> perMethodRequiredRoles = new HashMap>(); - final List excludedMethodRoles = new ArrayList(); + final List defaultRequiredRoles = new ArrayList<>(); + final Map> perMethodRequiredRoles = new HashMap<>(); + final List excludedMethodRoles = new ArrayList<>(); } private static final class ExcludedMethodRoles { @@ -258,14 +278,14 @@ private SecurityInformation(final Set roles, final TransportGuaranteeType transportGuaranteeType, final SecurityInfo.EmptyRoleSemantic emptyRoleSemantic) { this.emptyRoleSemantic = emptyRoleSemantic; - this.roles = new HashSet(roles); + this.roles = new HashSet<>(roles); this.transportGuaranteeType = transportGuaranteeType; } } private static final class RuntimeMatch { TransportGuaranteeType type = TransportGuaranteeType.NONE; - final List constraints = new ArrayList(); + final List constraints = new ArrayList<>(); boolean uncovered = true; } } Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletAuthenticationCallHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/security/Attic/ServletAuthenticationCallHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletAuthenticationCallHandler.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletAuthenticationCallHandler.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers.security; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletAuthenticationConstraintHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/security/Attic/ServletAuthenticationConstraintHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletAuthenticationConstraintHandler.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletAuthenticationConstraintHandler.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers.security; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletConfidentialityConstraintHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/security/Attic/ServletConfidentialityConstraintHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletConfidentialityConstraintHandler.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletConfidentialityConstraintHandler.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,14 +9,16 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers.security; +import static io.undertow.servlet.UndertowServletMessages.MESSAGES; + import io.undertow.security.handlers.SinglePortConfidentialityHandler; import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; @@ -72,7 +74,12 @@ @Override protected URI getRedirectURI(HttpServerExchange exchange) throws URISyntaxException { - return super.getRedirectURI(exchange, portManager.getConfidentialPort(exchange)); + int port = portManager.getConfidentialPort(exchange); + if (port < 0) { + throw MESSAGES.noConfidentialPortAvailable(); + } + + return super.getRedirectURI(exchange, port); } } Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletFormAuthenticationMechanism.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/security/Attic/ServletFormAuthenticationMechanism.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletFormAuthenticationMechanism.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletFormAuthenticationMechanism.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.handlers.security; import io.undertow.security.api.AuthenticationMechanism; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletSecurityConstraintHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/security/Attic/ServletSecurityConstraintHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletSecurityConstraintHandler.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletSecurityConstraintHandler.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers.security; @@ -46,7 +46,7 @@ final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); List list = servletRequestContext.getRequiredConstrains(); if (list == null) { - servletRequestContext.setRequiredConstrains(list = new ArrayList()); + servletRequestContext.setRequiredConstrains(list = new ArrayList<>()); } list.add(securityMatch.getMergedConstraint()); TransportGuaranteeType type = servletRequestContext.getTransportGuarenteeType(); Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletSecurityRoleHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/security/Attic/ServletSecurityRoleHandler.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletSecurityRoleHandler.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletSecurityRoleHandler.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.handlers.security; Index: 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletSingleSignOnAuthenticationMechainism.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/handlers/security/Attic/ServletSingleSignOnAuthenticationMechainism.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletSingleSignOnAuthenticationMechainism.java 9 Sep 2014 14:33:15 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/handlers/security/ServletSingleSignOnAuthenticationMechainism.java 25 Nov 2014 10:46:59 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.handlers.security; import io.undertow.security.impl.SingleSignOnAuthenticationMechanism; Index: 3rdParty_sources/undertow/io/undertow/servlet/predicate/DispatcherTypePredicate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/predicate/Attic/DispatcherTypePredicate.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/predicate/DispatcherTypePredicate.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/predicate/DispatcherTypePredicate.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.predicate; import java.util.HashMap; @@ -47,14 +65,14 @@ @Override public Map> parameters() { - final Map> params = new HashMap>(); + final Map> params = new HashMap<>(); params.put("value", String.class); return params; } @Override public Set requiredParameters() { - final Set params = new HashSet(); + final Set params = new HashSet<>(); params.add("value"); return params; } Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/AsyncContextImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/AsyncContextImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/AsyncContextImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/AsyncContextImpl.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -60,6 +60,7 @@ import io.undertow.servlet.handlers.ServletRequestContext; import io.undertow.util.AttachmentKey; import io.undertow.util.CanonicalPathUtils; +import io.undertow.util.Headers; import io.undertow.util.SameThreadExecutor; import org.xnio.IoUtils; import org.xnio.XnioExecutor; @@ -71,7 +72,7 @@ public static final AttachmentKey ASYNC_SUPPORTED = AttachmentKey.create(Boolean.class); - private final List asyncListeners = new CopyOnWriteArrayList(); + private final List asyncListeners = new CopyOnWriteArrayList<>(); private final HttpServerExchange exchange; private final ServletRequest servletRequest; @@ -92,7 +93,7 @@ private boolean initialRequestDone; private Thread initiatingThread; - private final Deque asyncTaskQueue = new ArrayDeque(); + private final Deque asyncTaskQueue = new ArrayDeque<>(); private boolean processingAsyncTask = false; private boolean complete = false; @@ -227,7 +228,7 @@ String newRequestUri = context.getContextPath() + newServletPath; //todo: a more efficient impl - Map> newQueryParameters = new HashMap>(); + Map> newQueryParameters = new HashMap<>(); for (String part : newQueryString.split("&")) { String name = part; String value = ""; @@ -238,7 +239,7 @@ } Deque queue = newQueryParameters.get(name); if (queue == null) { - newQueryParameters.put(name, queue = new ArrayDeque(1)); + newQueryParameters.put(name, queue = new ArrayDeque<>(1)); } queue.add(value); } @@ -275,8 +276,13 @@ } public synchronized void completeInternal() { - - if (!initialRequestDone && Thread.currentThread() == initiatingThread) { + if(timeoutKey != null) { + timeoutKey.remove(); + timeoutKey = null; + } + servletRequestContext.getOriginalRequest().asyncRequestDispatched(); + Thread currentThread = Thread.currentThread(); + if (!initialRequestDone && currentThread == initiatingThread) { //the context was stopped in the same request context it was started, we don't do anything if (dispatched) { throw UndertowServletMessages.MESSAGES.asyncRequestAlreadyDispatched(); @@ -285,15 +291,35 @@ dispatched = true; initialRequestDone(); } else { - doDispatch(new Runnable() { - @Override - public void run() { - //we do not run the ServletRequestListeners here, as the request does not come into the scope - //of a web application, as defined by the javadoc on ServletRequestListener - HttpServletResponseImpl response = servletRequestContext.getOriginalResponse(); - response.responseDone(); + //we do not run the ServletRequestListeners here, as the request does not come into the scope + //of a web application, as defined by the javadoc on ServletRequestListener + if(currentThread == exchange.getIoThread()) { + //the thread safety semantics here are a bit weird. + //basically if we are doing async IO we can't do a dispatch here, as then the IO thread can be racing + //with the dispatch thread. + //at all other times the dispatch is desirable + HttpServletResponseImpl response = servletRequestContext.getOriginalResponse(); + response.responseDone(); + try { + servletRequestContext.getOriginalRequest().closeAndDrainRequest(); + } catch (IOException e) { + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); } - }); + } else { + doDispatch(new Runnable() { + @Override + public void run() { + + HttpServletResponseImpl response = servletRequestContext.getOriginalResponse(); + response.responseDone(); + try { + servletRequestContext.getOriginalRequest().closeAndDrainRequest(); + } catch (IOException e) { + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); + } + } + }); + } } } @@ -444,28 +470,60 @@ public void run() { synchronized (AsyncContextImpl.this) { if (!dispatched) { - UndertowServletLogger.REQUEST_LOGGER.debug("Async request timed out"); - onAsyncTimeout(); - if (!dispatched) { - if(!getResponse().isCommitted()) { - //servlet + addAsyncTask(new Runnable() { + @Override + public void run() { + + final boolean setupRequired = SecurityActions.currentServletRequestContext() == null; + ThreadSetupAction.Handle handle = null; + if (setupRequired) { + handle = servletRequestContext.getDeployment().getThreadSetupAction().setup(exchange); + } + UndertowServletLogger.REQUEST_LOGGER.debug("Async request timed out"); + try { - if (servletResponse instanceof HttpServletResponse) { - ((HttpServletResponse) servletResponse).sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); - } else { - servletRequestContext.getOriginalResponse().sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + //now run request listeners + setupRequestContext(setupRequired); + try { + onAsyncTimeout(); + if (!dispatched) { + if (!getResponse().isCommitted()) { + //close the connection on timeout + exchange.setPersistent(false); + exchange.getResponseHeaders().put(Headers.CONNECTION, Headers.CLOSE.toString()); + Connectors.executeRootHandler(new HttpHandler() { + @Override + public void handleRequest(HttpServerExchange exchange) throws Exception { + //servlet + try { + if (servletResponse instanceof HttpServletResponse) { + ((HttpServletResponse) servletResponse).sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } else { + servletRequestContext.getOriginalResponse().sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } catch (IOException e) { + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); + } + } + }, exchange); + } else { + //not much we can do, just break the connection + IoUtils.safeClose(exchange.getConnection()); + } + if (!dispatched) { + complete(); + } + } + } finally { + tearDownRequestContext(setupRequired); } - } catch (IOException e) { - UndertowLogger.REQUEST_IO_LOGGER.ioException(e); + } finally { + if (setupRequired) { + handle.tearDown(); + } } - } else { - //not much we can do, just break the connection - IoUtils.safeClose(exchange.getConnection()); } - if (!dispatched) { - complete(); - } - } + }); } } } @@ -551,15 +609,6 @@ } private void onAsyncTimeout() { - final boolean setupRequired = SecurityActions.currentServletRequestContext() == null; - ThreadSetupAction.Handle handle = null; - if (setupRequired) { - handle = servletRequestContext.getDeployment().getThreadSetupAction().setup(exchange); - } - try { - //now run request listeners - setupRequestContext(setupRequired); - try { for (final BoundAsyncListener listener : asyncListeners) { AsyncEvent event = new AsyncEvent(this, listener.servletRequest, listener.servletResponse); try { @@ -568,14 +617,6 @@ UndertowServletLogger.REQUEST_LOGGER.ioExceptionDispatchingAsyncEvent(e); } } - } finally { - tearDownRequestContext(setupRequired); - } - } finally { - if (setupRequired) { - handle.tearDown(); - } - } } private void onAsyncStart(AsyncContext newAsyncContext) { Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/FilterConfigImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/FilterConfigImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/FilterConfigImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/FilterConfigImpl.java 25 Nov 2014 10:46:46 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -56,6 +56,6 @@ @Override public Enumeration getInitParameterNames() { - return new IteratorEnumeration(filterInfo.getInitParams().keySet().iterator()); + return new IteratorEnumeration<>(filterInfo.getInitParams().keySet().iterator()); } } Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/FilterRegistrationImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/FilterRegistrationImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/FilterRegistrationImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/FilterRegistrationImpl.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -41,42 +41,23 @@ private final FilterInfo filterInfo; private final Deployment deployment; + private final ServletContextImpl servletContext; - public FilterRegistrationImpl(final FilterInfo filterInfo, final Deployment deployment) { + public FilterRegistrationImpl(final FilterInfo filterInfo, final Deployment deployment, ServletContextImpl servletContext) { this.filterInfo = filterInfo; this.deployment = deployment; + this.servletContext = servletContext; } @Override public void addMappingForServletNames(final EnumSet dispatcherTypes, final boolean isMatchAfter, final String... servletNames) { - DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); - - for(final String servlet : servletNames){ - if(isMatchAfter) { - if(dispatcherTypes == null || dispatcherTypes.isEmpty()) { - deploymentInfo.addFilterServletNameMapping(filterInfo.getName(), servlet, DispatcherType.REQUEST); - } else { - for(final DispatcherType dispatcher : dispatcherTypes) { - deploymentInfo.addFilterServletNameMapping(filterInfo.getName(), servlet, dispatcher); - } - } - } else { - if(dispatcherTypes == null || dispatcherTypes.isEmpty()) { - deploymentInfo.insertFilterServletNameMapping(0, filterInfo.getName(), servlet, DispatcherType.REQUEST); - } else { - for(final DispatcherType dispatcher : dispatcherTypes) { - deploymentInfo.insertFilterServletNameMapping(0, filterInfo.getName(), servlet, dispatcher); - } - } - } - } - deployment.getServletPaths().invalidate(); + servletContext.addMappingForServletNames(filterInfo, dispatcherTypes, isMatchAfter, servletNames); } @Override public Collection getServletNameMappings() { DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); - final List ret = new ArrayList(); + final List ret = new ArrayList<>(); for(final FilterMappingInfo mapping : deploymentInfo.getFilterMappings()) { if(mapping.getMappingType() == FilterMappingInfo.MappingType.SERVLET) { if(mapping.getFilterName().equals(filterInfo.getName())) { @@ -89,33 +70,13 @@ @Override public void addMappingForUrlPatterns(final EnumSet dispatcherTypes, final boolean isMatchAfter, final String... urlPatterns) { - DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); - for(final String url : urlPatterns){ - if(isMatchAfter) { - if(dispatcherTypes == null || dispatcherTypes.isEmpty()) { - deploymentInfo.addFilterUrlMapping(filterInfo.getName(), url, DispatcherType.REQUEST); - } else { - for(final DispatcherType dispatcher : dispatcherTypes) { - deploymentInfo.addFilterUrlMapping(filterInfo.getName(), url, dispatcher); - } - } - } else { - if(dispatcherTypes == null || dispatcherTypes.isEmpty()) { - deploymentInfo.insertFilterUrlMapping(0, filterInfo.getName(), url, DispatcherType.REQUEST); - } else { - for(final DispatcherType dispatcher : dispatcherTypes) { - deploymentInfo.insertFilterUrlMapping(0, filterInfo.getName(), url, dispatcher); - } - } - } - } - deployment.getServletPaths().invalidate(); + servletContext.addMappingForUrlPatterns(filterInfo, dispatcherTypes, isMatchAfter, urlPatterns); } @Override public Collection getUrlPatternMappings() { DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); - final List ret = new ArrayList(); + final List ret = new ArrayList<>(); for(final FilterMappingInfo mapping : deploymentInfo.getFilterMappings()) { if(mapping.getMappingType() == FilterMappingInfo.MappingType.URL) { if(mapping.getFilterName().equals(filterInfo.getName())) { @@ -152,7 +113,7 @@ @Override public Set setInitParameters(final Map initParameters) { - final Set ret = new HashSet(); + final Set ret = new HashSet<>(); for(Map.Entry entry : initParameters.entrySet()) { if(!setInitParameter(entry.getKey(), entry.getValue())) { ret.add(entry.getKey()); Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/HttpServletRequestImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/HttpServletRequestImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/HttpServletRequestImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/HttpServletRequestImpl.java 25 Nov 2014 10:46:46 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -75,6 +75,7 @@ import java.security.Principal; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.Deque; import java.util.Enumeration; @@ -138,25 +139,35 @@ if (cookies.isEmpty()) { return null; } - Cookie[] value = new Cookie[cookies.size()]; + int count = cookies.size(); + Cookie[] value = new Cookie[count]; int i = 0; for (Map.Entry entry : cookies.entrySet()) { io.undertow.server.handlers.Cookie cookie = entry.getValue(); - Cookie c = new Cookie(cookie.getName(), cookie.getValue()); - if (cookie.getDomain() != null) { - c.setDomain(cookie.getDomain()); + try { + Cookie c = new Cookie(cookie.getName(), cookie.getValue()); + if (cookie.getDomain() != null) { + c.setDomain(cookie.getDomain()); + } + c.setHttpOnly(cookie.isHttpOnly()); + if (cookie.getMaxAge() != null) { + c.setMaxAge(cookie.getMaxAge()); + } + if (cookie.getPath() != null) { + c.setPath(cookie.getPath()); + } + c.setSecure(cookie.isSecure()); + c.setVersion(cookie.getVersion()); + value[i++] = c; + } catch (IllegalArgumentException e) { + // Ignore bad cookie } - c.setHttpOnly(cookie.isHttpOnly()); - if (cookie.getMaxAge() != null) { - c.setMaxAge(cookie.getMaxAge()); - } - if (cookie.getPath() != null) { - c.setPath(cookie.getPath()); - } - c.setSecure(cookie.isSecure()); - c.setVersion(cookie.getVersion()); - value[i++] = c; } + if( i < count ) { + Cookie[] shrunkCookies = new Cookie[i]; + System.arraycopy(value, 0, shrunkCookies, 0, i); + value = shrunkCookies; + } this.cookies = value; } return cookies; @@ -193,16 +204,16 @@ if (headers == null) { return EmptyEnumeration.instance(); } - return new IteratorEnumeration(headers.iterator()); + return new IteratorEnumeration<>(headers.iterator()); } @Override public Enumeration getHeaderNames() { - final Set headers = new HashSet(); + final Set headers = new HashSet<>(); for (final HttpString i : exchange.getRequestHeaders().getHeaderNames()) { headers.add(i.toString()); } - return new IteratorEnumeration(headers.iterator()); + return new IteratorEnumeration<>(headers.iterator()); } @Override @@ -397,10 +408,13 @@ throw UndertowServletMessages.MESSAGES.authenticationFailed(); } } else { - // Not authenticated and response already sent. - HttpServletResponseImpl responseImpl = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getOriginalResponse(); - responseImpl.closeStreamAndWriter(); - return false; + if(exchange.isResponseStarted()) { + //the auth mechanism commited the response, so we return false + return false; + } else { + //as the response was not commited we throw an exception as per the javadoc + throw UndertowServletMessages.MESSAGES.authenticationFailed(); + } } } @@ -465,7 +479,7 @@ try { InstanceFactory factory = servletContext.getDeployment().getDeploymentInfo().getClassIntrospecter().createInstanceFactory(handlerClass); final InstanceHandle instance = factory.createInstance(); - exchange.upgradeChannel(new ServletUpgradeListener(instance, servletContext.getDeployment().getThreadSetupAction(), exchange)); + exchange.upgradeChannel(new ServletUpgradeListener<>(instance, servletContext.getDeployment().getThreadSetupAction(), exchange)); return instance.getInstance(); } catch (InstantiationException e) { throw new RuntimeException(e); @@ -478,7 +492,7 @@ final ServletRequestContext requestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); if (parts == null) { - final List parts = new ArrayList(); + final List parts = new ArrayList<>(); String mimeType = exchange.getRequestHeaders().getFirst(Headers.CONTENT_TYPE); if (mimeType != null && mimeType.startsWith(MultiPartParserDefinition.MULTIPART_FORM_DATA)) { @@ -510,7 +524,7 @@ if (attributes == null) { return EmptyEnumeration.instance(); } - return new IteratorEnumeration(attributes.keySet().iterator()); + return new IteratorEnumeration<>(attributes.keySet().iterator()); } @Override @@ -588,6 +602,19 @@ servletInputStream.close(); } + /** + * Frees any resources (namely buffers) that may be associated with this request. + * + */ + public void freeResources() throws IOException { + if(reader != null) { + reader.close(); + } + if(servletInputStream != null) { + servletInputStream.close(); + } + } + @Override public String getParameter(final String name) { if(queryParameters == null) { @@ -616,7 +643,7 @@ if (queryParameters == null) { queryParameters = exchange.getQueryParameters(); } - final Set parameterNames = new HashSet(queryParameters.keySet()); + final Set parameterNames = new HashSet<>(queryParameters.keySet()); if (exchange.getRequestMethod().equals(Methods.POST)) { final FormData parsedFormData = parseFormData(); if (parsedFormData != null) { @@ -632,15 +659,15 @@ } } } - return new IteratorEnumeration(parameterNames.iterator()); + return new IteratorEnumeration<>(parameterNames.iterator()); } @Override public String[] getParameterValues(final String name) { if (queryParameters == null) { queryParameters = exchange.getQueryParameters(); } - final List ret = new ArrayList(); + final List ret = new ArrayList<>(); Deque params = queryParameters.get(name); if (params != null) { for (String param : params) { @@ -671,9 +698,9 @@ if (queryParameters == null) { queryParameters = exchange.getQueryParameters(); } - final Map> arrayMap = new HashMap>(); + final Map> arrayMap = new HashMap<>(); for (Map.Entry> entry : queryParameters.entrySet()) { - arrayMap.put(entry.getKey(), new ArrayList(entry.getValue())); + arrayMap.put(entry.getKey(), new ArrayList<>(entry.getValue())); } if (exchange.getRequestMethod().equals(Methods.POST)) { @@ -691,7 +718,7 @@ } } } else { - final ArrayList values = new ArrayList(); + final ArrayList values = new ArrayList<>(); int i = 0; for (final FormData.FormValue v : val) { if(!v.isFile()) { @@ -703,7 +730,7 @@ } } } - final Map ret = new HashMap(); + final Map ret = new HashMap<>(); for(Map.Entry> entry : arrayMap.entrySet()) { ret.put(entry.getKey(), entry.getValue().toArray(new String[entry.getValue().size()])); } @@ -715,12 +742,12 @@ if (readStarted) { return null; } - readStarted = true; - final ManagedServlet originalServlet = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getOriginalServletPathMatch().getServletChain().getManagedServlet(); + final ManagedServlet originalServlet = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getCurrentServlet().getManagedServlet(); final FormDataParser parser = originalServlet.getFormParserFactory().createParser(exchange); if (parser == null) { return null; } + readStarted = true; try { return parsedFormData = parser.parseBlocking(); } catch (IOException e) { @@ -807,7 +834,7 @@ @Override public void setAttribute(final String name, final Object object) { if (attributes == null) { - attributes = new HashMap(); + attributes = new HashMap<>(); } Object existing = attributes.put(name, object); if (existing != null) { @@ -835,7 +862,10 @@ public Enumeration getLocales() { final List acceptLanguage = exchange.getRequestHeaders().get(Headers.ACCEPT_LANGUAGE); List ret = LocaleUtils.getLocalesFromHeader(acceptLanguage); - return new IteratorEnumeration(ret.iterator()); + if(ret.isEmpty()) { + return new IteratorEnumeration<>(Collections.singletonList(Locale.getDefault()).iterator()); + } + return new IteratorEnumeration<>(ret.iterator()); } @Override Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/HttpServletResponseImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/HttpServletResponseImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/HttpServletResponseImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/HttpServletResponseImpl.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -24,6 +24,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Locale; @@ -37,11 +38,13 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import io.undertow.UndertowLogger; import io.undertow.server.HttpServerExchange; import io.undertow.servlet.UndertowServletMessages; import io.undertow.servlet.handlers.ServletRequestContext; import io.undertow.util.CanonicalPathUtils; import io.undertow.util.DateUtils; +import io.undertow.util.HeaderValues; import io.undertow.util.Headers; import io.undertow.util.HttpString; import io.undertow.util.RedirectBuilder; @@ -68,6 +71,7 @@ private boolean ignoredFlushPerformed = false; + private boolean treatAsCommitted = false; private boolean charsetSet = false; //if a content type has been set either implicitly or implicitly private String contentType; @@ -112,26 +116,47 @@ @Override public void sendError(final int sc, final String msg) throws IOException { + if(insideInclude) { + //not 100% sure this is the correct action + return; + } if (responseStarted()) { throw UndertowServletMessages.MESSAGES.responseAlreadyCommited(); } - resetBuffer(); writer = null; responseState = ResponseState.NONE; exchange.setResponseCode(sc); - //todo: is this the best way to handle errors? + ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); + if(src.isRunningInsideHandler()) { + //all we do is set the error on the context, we handle it when the request is returned + treatAsCommitted = true; + src.setError(sc, msg); + } else { + //if the src is null there is no outer handler, as we are in an asnc request + doErrorDispatch(sc, msg); + } + } + + public void doErrorDispatch(int sc, String error) throws IOException { + resetBuffer(); + treatAsCommitted = false; final String location = servletContext.getDeployment().getErrorPages().getErrorLocation(sc); if (location != null) { RequestDispatcherImpl requestDispatcher = new RequestDispatcherImpl(location, servletContext); final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); try { - requestDispatcher.error(servletRequestContext.getServletRequest(), servletRequestContext.getServletResponse(), exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getCurrentServlet().getManagedServlet().getServletInfo().getName(), msg); + requestDispatcher.error(servletRequestContext, servletRequestContext.getServletRequest(), servletRequestContext.getServletResponse(), exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getCurrentServlet().getManagedServlet().getServletInfo().getName(), error); } catch (ServletException e) { throw new RuntimeException(e); } - } else if (msg != null) { + } else if (error != null) { setContentType("text/html"); - getWriter().write("Error" + msg + ""); + setCharacterEncoding("UTF-8"); + if(servletContext.getDeployment().getDeploymentInfo().isEscapeErrorMessage()) { + getWriter().write("Error" + escapeHtml(error) + ""); + } else { + getWriter().write("Error" + error + ""); + } getWriter().close(); } responseDone(); @@ -181,27 +206,47 @@ @Override public void setHeader(final String name, final String value) { + if(name == null) { + throw UndertowServletMessages.MESSAGES.headerNameWasNull(); + } setHeader(new HttpString(name), value); } public void setHeader(final HttpString name, final String value) { + if(name == null) { + throw UndertowServletMessages.MESSAGES.headerNameWasNull(); + } if (insideInclude || ignoredFlushPerformed) { return; } - exchange.getResponseHeaders().put(name, value); + if(name.equals(Headers.CONTENT_TYPE)) { + setContentType(value); + } else { + exchange.getResponseHeaders().put(name, value); + } } @Override public void addHeader(final String name, final String value) { + if(name == null) { + throw UndertowServletMessages.MESSAGES.headerNameWasNull(); + } addHeader(new HttpString(name), value); } public void addHeader(final HttpString name, final String value) { - if (insideInclude || ignoredFlushPerformed) { + if(name == null) { + throw UndertowServletMessages.MESSAGES.headerNameWasNull(); + } + if (insideInclude || ignoredFlushPerformed || treatAsCommitted) { return; } - exchange.getResponseHeaders().add(name, value); + if(name.equals(Headers.CONTENT_TYPE) && !exchange.getResponseHeaders().contains(Headers.CONTENT_TYPE)) { + setContentType(value); + } else { + exchange.getResponseHeaders().add(name, value); + } } @Override @@ -216,7 +261,7 @@ @Override public void setStatus(final int sc) { - if (insideInclude) { + if (insideInclude || treatAsCommitted) { return; } if (responseStarted()) { @@ -227,9 +272,6 @@ @Override public void setStatus(final int sc, final String sm) { - if (insideInclude) { - return; - } setStatus(sc); } @@ -245,12 +287,16 @@ @Override public Collection getHeaders(final String name) { - return new ArrayList(exchange.getResponseHeaders().get(name)); + HeaderValues headers = exchange.getResponseHeaders().get(name); + if(headers == null) { + return Collections.emptySet(); + } + return new ArrayList<>(headers); } @Override public Collection getHeaderNames() { - final Set headers = new HashSet(); + final Set headers = new HashSet<>(); for (final HttpString i : exchange.getResponseHeaders().getHeaderNames()) { headers.add(i.toString()); } @@ -354,7 +400,7 @@ } private boolean responseStarted() { - return exchange.isResponseStarted() || ignoredFlushPerformed; + return exchange.isResponseStarted() || ignoredFlushPerformed || treatAsCommitted; } @Override @@ -438,10 +484,10 @@ } public void closeStreamAndWriter() throws IOException { + if(treatAsCommitted) { + return; + } if (writer != null) { - if (!servletOutputStream.isClosed()) { - writer.flush(); - } writer.close(); } else { if (servletOutputStream == null) { @@ -452,6 +498,15 @@ } } + public void freeResources() throws IOException { + if(writer != null) { + writer.close(); + } + if(servletOutputStream != null) { + servletOutputStream.close(); + } + } + @Override public void resetBuffer() { if (servletOutputStream != null) { @@ -476,6 +531,7 @@ responseState = ResponseState.NONE; exchange.getResponseHeaders().clear(); exchange.setResponseCode(200); + treatAsCommitted = false; } @Override @@ -516,15 +572,15 @@ } public void responseDone() { - if (responseDone) { + if (responseDone || treatAsCommitted) { return; } servletContext.updateSessionAccessTime(exchange); responseDone = true; try { closeStreamAndWriter(); } catch (IOException e) { - throw new RuntimeException(e); + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); } } @@ -713,4 +769,12 @@ STREAM, WRITER } + + private static String escapeHtml(String msg) { + return msg.replace("<", "<").replace(">", ">").replace("&", "&"); + } + + public boolean isTreatAsCommitted() { + return treatAsCommitted; + } } Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/HttpSessionImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/HttpSessionImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/HttpSessionImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/HttpSessionImpl.java 25 Nov 2014 10:46:46 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -132,11 +132,11 @@ @Override public Enumeration getAttributeNames() { Set attributeNames = getFilteredAttributeNames(); - return new IteratorEnumeration(attributeNames.iterator()); + return new IteratorEnumeration<>(attributeNames.iterator()); } private Set getFilteredAttributeNames() { - Set attributeNames = new HashSet(session.getAttributeNames()); + Set attributeNames = new HashSet<>(session.getAttributeNames()); Iterator it = attributeNames.iterator(); while (it.hasNext()) { if(it.next().startsWith(IO_UNDERTOW)) { Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/PartImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/PartImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/PartImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/PartImpl.java 25 Nov 2014 10:46:46 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -125,7 +125,7 @@ @Override public Collection getHeaderNames() { - final Set ret = new HashSet(); + final Set ret = new HashSet<>(); for (HttpString i : formValue.getHeaders().getHeaderNames()) { ret.add(i.toString()); } Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/RequestDispatcherImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/RequestDispatcherImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/RequestDispatcherImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/RequestDispatcherImpl.java 25 Nov 2014 10:46:46 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -133,7 +133,8 @@ String newQueryString = newServletPath.substring(qsPos + 1); newServletPath = newServletPath.substring(0, qsPos); - Map> newQueryParameters = QueryParameterUtils.mergeQueryParametersWithNewQueryString(queryParameters, newQueryString); + String encoding = QueryParameterUtils.getQueryParamEncoding(servletRequestContext.getExchange()); + Map> newQueryParameters = QueryParameterUtils.mergeQueryParametersWithNewQueryString(queryParameters, newQueryString, encoding); requestImpl.getExchange().setQueryString(newQueryString); requestImpl.setQueryParameters(newQueryParameters); } @@ -159,6 +160,7 @@ servletContext.getDeployment().getServletDispatcher().dispatchToPath(requestImpl.getExchange(), pathMatch, DispatcherType.FORWARD); } + //if we are not in an async or error dispatch then we close the response if (!request.isAsyncStarted()) { if (response instanceof HttpServletResponseImpl) { responseImpl.closeStreamAndWriter(); @@ -249,7 +251,8 @@ String newQueryString = newServletPath.substring(qsPos + 1); newServletPath = newServletPath.substring(0, qsPos); - Map> newQueryParameters = QueryParameterUtils.mergeQueryParametersWithNewQueryString(queryParameters, newQueryString); + String encoding = QueryParameterUtils.getQueryParamEncoding(servletRequestContext.getExchange()); + Map> newQueryParameters = QueryParameterUtils.mergeQueryParametersWithNewQueryString(queryParameters, newQueryString, encoding); requestImpl.setQueryParameters(newQueryParameters); requestImpl.setAttribute(INCLUDE_QUERY_STRING, newQueryString); } else { @@ -307,21 +310,19 @@ } } - public void error(final ServletRequest request, final ServletResponse response, final String servletName, final String message) throws ServletException, IOException { - error(request, response, servletName, null, message); + public void error(ServletRequestContext servletRequestContext, final ServletRequest request, final ServletResponse response, final String servletName, final String message) throws ServletException, IOException { + error(servletRequestContext, request, response, servletName, null, message); } - public void error(final ServletRequest request, final ServletResponse response, final String servletName) throws ServletException, IOException { - error(request, response, servletName, null, null); + public void error(ServletRequestContext servletRequestContext, final ServletRequest request, final ServletResponse response, final String servletName) throws ServletException, IOException { + error(servletRequestContext, request, response, servletName, null, null); } - public void error(final ServletRequest request, final ServletResponse response, final String servletName, final Throwable exception) throws ServletException, IOException { - error(request, response, servletName, exception, exception.getMessage()); + public void error(ServletRequestContext servletRequestContext, final ServletRequest request, final ServletResponse response, final String servletName, final Throwable exception) throws ServletException, IOException { + error(servletRequestContext, request, response, servletName, exception, exception.getMessage()); } - private void error(final ServletRequest request, final ServletResponse response, final String servletName, final Throwable exception, final String message) throws ServletException, IOException { - - final ServletRequestContext servletRequestContext = SecurityActions.requireCurrentServletRequestContext(); + private void error(ServletRequestContext servletRequestContext, final ServletRequest request, final ServletResponse response, final String servletName, final Throwable exception, final String message) throws ServletException, IOException { if(request.getDispatcherType() == DispatcherType.ERROR) { //we have already dispatched once with an error //if we dispatch again we run the risk of a stack overflow @@ -370,7 +371,7 @@ String newRequestUri = servletContext.getContextPath() + newServletPath; //todo: a more efficent impl - Map> newQueryParameters = new HashMap>(); + Map> newQueryParameters = new HashMap<>(); for (String part : newQueryString.split("&")) { String name = part; String value = ""; @@ -381,7 +382,7 @@ } Deque queue = newQueryParameters.get(name); if (queue == null) { - newQueryParameters.put(name, queue = new ArrayDeque(1)); + newQueryParameters.put(name, queue = new ArrayDeque<>(1)); } queue.add(value); } @@ -408,6 +409,10 @@ throw new RuntimeException(e); } } finally { + AsyncContextImpl ac = servletRequestContext.getOriginalRequest().getAsyncContextInternal(); + if(ac != null) { + ac.complete(); + } servletRequestContext.setServletRequest(oldRequest); servletRequestContext.setServletResponse(oldResponse); } Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/SecurityActions.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/SecurityActions.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/SecurityActions.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/SecurityActions.java 25 Nov 2014 10:46:46 -0000 1.1.2.2 @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletConfigImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/ServletConfigImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletConfigImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletConfigImpl.java 25 Nov 2014 10:46:46 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -60,6 +60,6 @@ @Override public Enumeration getInitParameterNames() { - return new IteratorEnumeration(servletInfo.getInitParams().keySet().iterator()); + return new IteratorEnumeration<>(servletInfo.getInitParams().keySet().iterator()); } } Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletContextImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/ServletContextImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletContextImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletContextImpl.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -43,14 +43,18 @@ import io.undertow.servlet.api.TransportGuaranteeType; import io.undertow.servlet.core.ApplicationListeners; import io.undertow.servlet.core.ManagedListener; +import io.undertow.servlet.core.ManagedServlet; import io.undertow.servlet.handlers.ServletChain; +import io.undertow.servlet.handlers.ServletHandler; import io.undertow.servlet.util.EmptyEnumeration; import io.undertow.servlet.util.ImmediateInstanceFactory; import io.undertow.servlet.util.IteratorEnumeration; import io.undertow.util.AttachmentKey; +import io.undertow.util.CanonicalPathUtils; import javax.annotation.security.DeclareRoles; import javax.annotation.security.RunAs; +import javax.servlet.DispatcherType; import javax.servlet.Filter; import javax.servlet.FilterRegistration; import javax.servlet.MultipartConfigElement; @@ -77,6 +81,7 @@ import java.security.PrivilegedAction; import java.util.Arrays; import java.util.Collections; +import java.util.EnumSet; import java.util.Enumeration; import java.util.EventListener; import java.util.HashMap; @@ -101,10 +106,11 @@ private final ConcurrentMap attributes; private final SessionCookieConfigImpl sessionCookieConfig; private final AttachmentKey sessionAttachmentKey = AttachmentKey.create(HttpSessionImpl.class); - private volatile Set sessionTrackingModes = new HashSet(Arrays.asList(new SessionTrackingMode[]{SessionTrackingMode.COOKIE, SessionTrackingMode.URL})); - private volatile Set defaultSessionTrackingModes = new HashSet(Arrays.asList(new SessionTrackingMode[]{SessionTrackingMode.COOKIE, SessionTrackingMode.URL})); + private volatile Set sessionTrackingModes = new HashSet<>(Arrays.asList(new SessionTrackingMode[]{SessionTrackingMode.COOKIE, SessionTrackingMode.URL})); + private volatile Set defaultSessionTrackingModes = new HashSet<>(Arrays.asList(new SessionTrackingMode[]{SessionTrackingMode.COOKIE, SessionTrackingMode.URL})); private volatile SessionConfig sessionConfig; private volatile boolean initialized = false; + private int filterMappingInsertPosition = 0; public ServletContextImpl(final ServletContainer servletContainer, final Deployment deployment) { @@ -114,7 +120,7 @@ sessionCookieConfig = new SessionCookieConfigImpl(this); sessionCookieConfig.setPath(deploymentInfo.getContextPath()); if (deploymentInfo.getServletContextAttributeBackingMap() == null) { - this.attributes = new ConcurrentHashMap(); + this.attributes = new ConcurrentHashMap<>(); } else { this.attributes = deploymentInfo.getServletContextAttributeBackingMap(); } @@ -145,7 +151,11 @@ @Override public String getContextPath() { - return deploymentInfo.getContextPath(); + String contextPath = deploymentInfo.getContextPath(); + if(contextPath.equals("/")) { + return ""; + } + return contextPath; } @Override @@ -197,7 +207,7 @@ if (resource == null || !resource.isDirectory()) { return null; } - final Set resources = new HashSet(); + final Set resources = new HashSet<>(); for (Resource res : resource.list()) { File file = res.getFile(); if (file != null) { @@ -309,9 +319,10 @@ if (path == null) { return null; } + String canonicalPath = CanonicalPathUtils.canonicalize(path); Resource resource = null; try { - resource = deploymentInfo.getResourceManager().getResource(path); + resource = deploymentInfo.getResourceManager().getResource(canonicalPath); } catch (IOException e) { return null; } @@ -340,7 +351,7 @@ @Override public Enumeration getInitParameterNames() { - return new IteratorEnumeration(deploymentInfo.getInitParameters().keySet().iterator()); + return new IteratorEnumeration<>(deploymentInfo.getInitParameters().keySet().iterator()); } @Override @@ -359,7 +370,7 @@ @Override public Enumeration getAttributeNames() { - return new IteratorEnumeration(attributes.keySet().iterator()); + return new IteratorEnumeration<>(attributes.keySet().iterator()); } @Override @@ -406,8 +417,8 @@ ServletInfo servlet = new ServletInfo(servletName, (Class) deploymentInfo.getClassLoader().loadClass(className)); readServletAnnotations(servlet); deploymentInfo.addServlet(servlet); - deployment.getServlets().addServlet(servlet); - return new ServletRegistrationImpl(servlet, deployment); + ServletHandler handler = deployment.getServlets().addServlet(servlet); + return new ServletRegistrationImpl(servlet, handler.getManagedServlet(), deployment); } catch (ClassNotFoundException e) { throw UndertowServletMessages.MESSAGES.cannotLoadClass(className, e); } @@ -420,11 +431,11 @@ if (deploymentInfo.getServlets().containsKey(servletName)) { return null; } - ServletInfo s = new ServletInfo(servletName, servlet.getClass(), new ImmediateInstanceFactory(servlet)); + ServletInfo s = new ServletInfo(servletName, servlet.getClass(), new ImmediateInstanceFactory<>(servlet)); readServletAnnotations(s); deploymentInfo.addServlet(s); - deployment.getServlets().addServlet(s); - return new ServletRegistrationImpl(s, deployment); + ServletHandler handler = deployment.getServlets().addServlet(s); + return new ServletRegistrationImpl(s, handler.getManagedServlet(), deployment); } @Override @@ -437,8 +448,8 @@ ServletInfo servlet = new ServletInfo(servletName, servletClass); readServletAnnotations(servlet); deploymentInfo.addServlet(servlet); - deployment.getServlets().addServlet(servlet); - return new ServletRegistrationImpl(servlet, deployment); + ServletHandler handler = deployment.getServlets().addServlet(servlet); + return new ServletRegistrationImpl(servlet, handler.getManagedServlet(), deployment); } @@ -455,19 +466,19 @@ @Override public ServletRegistration getServletRegistration(final String servletName) { ensureNotProgramaticListener(); - final ServletInfo servlet = deploymentInfo.getServlets().get(servletName); + final ManagedServlet servlet = deployment.getServlets().getManagedServlet(servletName); if (servlet == null) { return null; } - return new ServletRegistrationImpl(servlet, deployment); + return new ServletRegistrationImpl(servlet.getServletInfo(), servlet, deployment); } @Override public Map getServletRegistrations() { ensureNotProgramaticListener(); - final Map ret = new HashMap(); - for (Map.Entry entry : deploymentInfo.getServlets().entrySet()) { - ret.put(entry.getKey(), new ServletRegistrationImpl(entry.getValue(), deployment)); + final Map ret = new HashMap<>(); + for (Map.Entry entry : deployment.getServlets().getServletHandlers().entrySet()) { + ret.put(entry.getKey(), new ServletRegistrationImpl(entry.getValue().getManagedServlet().getServletInfo(), entry.getValue().getManagedServlet(), deployment)); } return ret; } @@ -483,7 +494,7 @@ FilterInfo filter = new FilterInfo(filterName, (Class) deploymentInfo.getClassLoader().loadClass(className)); deploymentInfo.addFilter(filter); deployment.getFilters().addFilter(filter); - return new FilterRegistrationImpl(filter, deployment); + return new FilterRegistrationImpl(filter, deployment, this); } catch (ClassNotFoundException e) { throw UndertowServletMessages.MESSAGES.cannotLoadClass(className, e); } @@ -497,10 +508,10 @@ if (deploymentInfo.getFilters().containsKey(filterName)) { return null; } - FilterInfo f = new FilterInfo(filterName, filter.getClass(), new ImmediateInstanceFactory(filter)); + FilterInfo f = new FilterInfo(filterName, filter.getClass(), new ImmediateInstanceFactory<>(filter)); deploymentInfo.addFilter(f); deployment.getFilters().addFilter(f); - return new FilterRegistrationImpl(f, deployment); + return new FilterRegistrationImpl(f, deployment, this); } @@ -514,7 +525,7 @@ FilterInfo filter = new FilterInfo(filterName, filterClass); deploymentInfo.addFilter(filter); deployment.getFilters().addFilter(filter); - return new FilterRegistrationImpl(filter, deployment); + return new FilterRegistrationImpl(filter, deployment, this); } @Override @@ -534,15 +545,15 @@ if (filterInfo == null) { return null; } - return new FilterRegistrationImpl(filterInfo, deployment); + return new FilterRegistrationImpl(filterInfo, deployment, this); } @Override public Map getFilterRegistrations() { ensureNotProgramaticListener(); - final Map ret = new HashMap(); + final Map ret = new HashMap<>(); for (Map.Entry entry : deploymentInfo.getFilters().entrySet()) { - ret.put(entry.getKey(), new FilterRegistrationImpl(entry.getValue(), deployment)); + ret.put(entry.getKey(), new FilterRegistrationImpl(entry.getValue(), deployment, this)); } return ret; } @@ -560,7 +571,7 @@ if (sessionTrackingModes.size() > 1 && sessionTrackingModes.contains(SessionTrackingMode.SSL)) { throw UndertowServletMessages.MESSAGES.sslCannotBeCombinedWithAnyOtherMethod(); } - this.sessionTrackingModes = new HashSet(sessionTrackingModes); + this.sessionTrackingModes = new HashSet<>(sessionTrackingModes); //TODO: actually make this work } @@ -804,4 +815,53 @@ return null; } } + + void addMappingForServletNames(FilterInfo filterInfo, final EnumSet dispatcherTypes, final boolean isMatchAfter, final String... servletNames) { + DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); + + for(final String servlet : servletNames){ + if(isMatchAfter) { + if(dispatcherTypes == null || dispatcherTypes.isEmpty()) { + deploymentInfo.addFilterServletNameMapping(filterInfo.getName(), servlet, DispatcherType.REQUEST); + } else { + for(final DispatcherType dispatcher : dispatcherTypes) { + deploymentInfo.addFilterServletNameMapping(filterInfo.getName(), servlet, dispatcher); + } + } + } else { + if(dispatcherTypes == null || dispatcherTypes.isEmpty()) { + deploymentInfo.insertFilterServletNameMapping(filterMappingInsertPosition++, filterInfo.getName(), servlet, DispatcherType.REQUEST); + } else { + for(final DispatcherType dispatcher : dispatcherTypes) { + deploymentInfo.insertFilterServletNameMapping(filterMappingInsertPosition++, filterInfo.getName(), servlet, dispatcher); + } + } + } + } + deployment.getServletPaths().invalidate(); + } + + void addMappingForUrlPatterns(FilterInfo filterInfo, final EnumSet dispatcherTypes, final boolean isMatchAfter, final String... urlPatterns) { + DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); + for(final String url : urlPatterns){ + if(isMatchAfter) { + if(dispatcherTypes == null || dispatcherTypes.isEmpty()) { + deploymentInfo.addFilterUrlMapping(filterInfo.getName(), url, DispatcherType.REQUEST); + } else { + for(final DispatcherType dispatcher : dispatcherTypes) { + deploymentInfo.addFilterUrlMapping(filterInfo.getName(), url, dispatcher); + } + } + } else { + if(dispatcherTypes == null || dispatcherTypes.isEmpty()) { + deploymentInfo.insertFilterUrlMapping(filterMappingInsertPosition++, filterInfo.getName(), url, DispatcherType.REQUEST); + } else { + for(final DispatcherType dispatcher : dispatcherTypes) { + deploymentInfo.insertFilterUrlMapping(filterMappingInsertPosition++, filterInfo.getName(), url, dispatcher); + } + } + } + } + deployment.getServletPaths().invalidate(); + } } Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletCookieAdaptor.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/ServletCookieAdaptor.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletCookieAdaptor.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletCookieAdaptor.java 25 Nov 2014 10:46:46 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletInputStreamImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/ServletInputStreamImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletInputStreamImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletInputStreamImpl.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,11 +1,23 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.spec; -import java.io.IOException; -import java.nio.ByteBuffer; - -import javax.servlet.ReadListener; -import javax.servlet.ServletInputStream; - import io.undertow.servlet.UndertowServletMessages; import io.undertow.servlet.api.ThreadSetupAction; import io.undertow.servlet.core.CompositeThreadSetupAction; @@ -18,6 +30,11 @@ import org.xnio.channels.EmptyStreamSourceChannel; import org.xnio.channels.StreamSourceChannel; +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import java.io.IOException; +import java.nio.ByteBuffer; + import static org.xnio.Bits.allAreClear; import static org.xnio.Bits.anyAreClear; import static org.xnio.Bits.anyAreSet; @@ -35,6 +52,7 @@ private final Pool bufferPool; private volatile ReadListener listener; + private volatile ServletInputStreamChannelListener internalListener; /** * If this stream is ready for a read @@ -83,13 +101,19 @@ asyncContext = request.getAsyncContext(); listener = readListener; - channel.getReadSetter().set(new ServletInputStreamChannelListener()); + channel.getReadSetter().set(internalListener = new ServletInputStreamChannelListener()); //we resume from an async task, after the request has been dispatched asyncContext.addAsyncTask(new Runnable() { @Override public void run() { - channel.wakeupReads(); + channel.getIoThread().execute(new Runnable() { + @Override + public void run() { + channel.resumeReads(); + internalListener.handleEvent(channel); + } + }); } }); } @@ -114,7 +138,7 @@ if (anyAreSet(state, FLAG_CLOSED)) { throw UndertowServletMessages.MESSAGES.streamIsClosed(); } - if(listener != null) { + if (listener != null) { if (anyAreClear(state, FLAG_READY)) { throw UndertowServletMessages.MESSAGES.streamNotReady(); } @@ -132,7 +156,7 @@ if (!buffer.hasRemaining()) { pooled.free(); pooled = null; - if(listener != null) { + if (listener != null) { readIntoBufferNonBlocking(); } } @@ -183,10 +207,12 @@ state &= ~FLAG_READY; pooled.free(); pooled = null; - asyncContext.addAsyncTask(new Runnable() { + channel.getIoThread().execute(new Runnable() { @Override public void run() { - channel.resumeReads(); + if(!channel.isReadResumed()) { + channel.resumeReads(); + } } }); } @@ -214,82 +240,85 @@ if (anyAreSet(state, FLAG_CLOSED)) { return; } - while (allAreClear(state, FLAG_FINISHED)) { - readIntoBuffer(); + try { + while (allAreClear(state, FLAG_FINISHED)) { + readIntoBuffer(); + if (pooled != null) { + pooled.free(); + pooled = null; + } + } + } finally { if (pooled != null) { pooled.free(); pooled = null; } } - if (pooled != null) { - pooled.free(); - pooled = null; - } channel.shutdownReads(); state |= FLAG_FINISHED | FLAG_CLOSED; } private class ServletInputStreamChannelListener implements ChannelListener { @Override public void handleEvent(final StreamSourceChannel channel) { - channel.suspendReads(); - asyncContext.addAsyncTask(new Runnable() { - @Override - public void run() { - if (asyncContext.isDispatched()) { - //this is no longer an async request - //we just return - //TODO: what do we do here? Revert back to blocking mode? - return; - } - if (anyAreSet(state, FLAG_FINISHED)) { - return; - } + if (asyncContext.isDispatched()) { + //this is no longer an async request + //we just return + //TODO: what do we do here? Revert back to blocking mode? + channel.suspendReads(); + return; + } + if (anyAreSet(state, FLAG_FINISHED)) { + channel.suspendReads(); + return; + } + state |= FLAG_READY; + try { + readIntoBufferNonBlocking(); + if (pooled != null) { state |= FLAG_READY; - try { - readIntoBufferNonBlocking(); + if (!anyAreSet(state, FLAG_FINISHED)) { + CompositeThreadSetupAction action = request.getServletContext().getDeployment().getThreadSetupAction(); + ThreadSetupAction.Handle handle = action.setup(request.getExchange()); + try { + listener.onDataAvailable(); + } finally { + handle.tearDown(); + } if(pooled != null) { - state |= FLAG_READY; - if (!anyAreSet(state, FLAG_FINISHED)) { - CompositeThreadSetupAction action = request.getServletContext().getDeployment().getThreadSetupAction(); - ThreadSetupAction.Handle handle = action.setup(request.getExchange()); - try { - listener.onDataAvailable(); - } finally { - handle.tearDown(); - } - } + //they did not consume all the data + channel.suspendReads(); } - } catch (Exception e) { + } + } + } catch (Exception e) { + CompositeThreadSetupAction action = request.getServletContext().getDeployment().getThreadSetupAction(); + ThreadSetupAction.Handle handle = action.setup(request.getExchange()); + try { + listener.onError(e); + } finally { + handle.tearDown(); + } + IoUtils.safeClose(channel); + } + if (anyAreSet(state, FLAG_FINISHED)) { + if (anyAreClear(state, FLAG_ON_DATA_READ_CALLED)) { + try { + state |= FLAG_ON_DATA_READ_CALLED; + channel.shutdownReads(); CompositeThreadSetupAction action = request.getServletContext().getDeployment().getThreadSetupAction(); ThreadSetupAction.Handle handle = action.setup(request.getExchange()); try { - listener.onError(e); + listener.onAllDataRead(); } finally { handle.tearDown(); } + } catch (IOException e) { + listener.onError(e); IoUtils.safeClose(channel); } - if (anyAreSet(state, FLAG_FINISHED)) { - if (anyAreClear(state, FLAG_ON_DATA_READ_CALLED)) { - try { - state |= FLAG_ON_DATA_READ_CALLED; - channel.shutdownReads(); - CompositeThreadSetupAction action = request.getServletContext().getDeployment().getThreadSetupAction(); - ThreadSetupAction.Handle handle = action.setup(request.getExchange()); - try { - listener.onAllDataRead(); - } finally { - handle.tearDown(); - } - } catch (IOException e) { - listener.onError(e); - IoUtils.safeClose(channel); - } - } - } } - }); + } } } Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletOutputStreamImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/ServletOutputStreamImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletOutputStreamImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletOutputStreamImpl.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -26,7 +26,6 @@ import io.undertow.util.Headers; import org.xnio.Buffers; import org.xnio.ChannelListener; -import org.xnio.ChannelListeners; import org.xnio.IoUtils; import org.xnio.Pool; import org.xnio.Pooled; @@ -133,7 +132,7 @@ * {@inheritDoc} */ public void write(final byte[] b, final int off, final int len) throws IOException { - if (anyAreSet(state, FLAG_CLOSED)) { + if (anyAreSet(state, FLAG_CLOSED) || servletRequestContext.getOriginalResponse().isTreatAsCommitted()) { throw UndertowServletMessages.MESSAGES.streamIsClosed(); } if (len < 1) { @@ -252,7 +251,7 @@ this.buffersToWrite = new ByteBuffer[]{buffer, copy}; state &= ~FLAG_READY; - resumeWrites(); + channel.resumeWrites(); return; } } while (written < toWrite); @@ -267,7 +266,7 @@ @Override public void write(ByteBuffer[] buffers) throws IOException { - if (anyAreSet(state, FLAG_CLOSED)) { + if (anyAreSet(state, FLAG_CLOSED) || servletRequestContext.getOriginalResponse().isTreatAsCommitted()) { throw UndertowServletMessages.MESSAGES.streamIsClosed(); } int len = 0; @@ -341,7 +340,7 @@ copy.flip(); this.buffersToWrite = new ByteBuffer[]{buffer, copy}; state &= ~FLAG_READY; - resumeWrites(); + channel.resumeWrites(); return; } } while (written < toWrite); @@ -377,35 +376,19 @@ if (flushBufferAsync(true)) { channel.shutdownWrites(); state |= FLAG_DELEGATE_SHUTDOWN; - if (!channel.flush()) { - resumeWrites(); + channel.flush(); + if(pooledBuffer != null) { + pooledBuffer.free(); + buffer = null; + pooledBuffer = null; } - } else { - resumeWrites(); } } } } - private void resumeWrites() { - if (anyAreSet(state, FLAG_IN_CALLBACK)) { - //writes will be resumed at the end of the callback - return; - } - if (channel != null) { - channel.getWriteSetter().set(internalListener); - channel.resumeWrites(); - } else { - servletRequestContext.getExchange().getIoThread().execute(new Runnable() { - @Override - public void run() { - ChannelListeners.invokeChannelListener(null, internalListener); - } - }); - } - } - private boolean flushBufferAsync(final boolean writeFinal) throws IOException { + ByteBuffer[] bufs = buffersToWrite; if (bufs == null) { ByteBuffer buffer = this.buffer; @@ -426,7 +409,7 @@ long res; long written = 0; do { - if(writeFinal) { + if (writeFinal) { res = channel.writeFinal(bufs); } else { res = channel.write(bufs); @@ -436,6 +419,7 @@ //write it out with a listener state = state & ~FLAG_READY; buffersToWrite = bufs; + channel.resumeWrites(); return false; } } while (written < toWrite); @@ -469,10 +453,11 @@ */ public void flush() throws IOException { //according to the servlet spec we ignore a flush from within an include - if (servletRequestContext.getOriginalRequest().getDispatcherType() == DispatcherType.INCLUDE) { + if (servletRequestContext.getOriginalRequest().getDispatcherType() == DispatcherType.INCLUDE || + servletRequestContext.getOriginalResponse().isTreatAsCommitted()) { return; } - if(servletRequestContext.getDeployment().getDeploymentInfo().isIgnoreFlush() && + if (servletRequestContext.getDeployment().getDeploymentInfo().isIgnoreFlush() && servletRequestContext.getExchange().isRequestComplete() && servletRequestContext.getOriginalResponse().getHeader(Headers.TRANSFER_ENCODING_STRING) == null) { //we mark the stream as flushed, but don't actually flush @@ -518,7 +503,6 @@ long res; do { res = channel.write(buffer); - written += res; } while (buffer.hasRemaining() && res != 0); if (!buffer.hasRemaining()) { channel.flush(); @@ -529,11 +513,10 @@ @Override public void transferFrom(FileChannel source) throws IOException { + if (anyAreSet(state, FLAG_CLOSED) || servletRequestContext.getOriginalResponse().isTreatAsCommitted()) { + throw UndertowServletMessages.MESSAGES.streamIsClosed(); + } if (listener == null) { - if (anyAreSet(state, FLAG_CLOSED)) { - //just return - return; - } if (buffer != null && buffer.position() != 0) { writeBufferBlocking(false); } @@ -559,7 +542,7 @@ state &= ~FLAG_READY; pendingFile = source; source.position(pos); - resumeWrites(); + channel.resumeWrites(); return; } pos += ret; @@ -578,12 +561,12 @@ } buffer.flip(); while (buffer.hasRemaining()) { - if(writeFinal) { + if (writeFinal) { channel.writeFinal(buffer); } else { channel.write(buffer); } - if(buffer.hasRemaining()) { + if (buffer.hasRemaining()) { channel.awaitWritable(); } } @@ -595,15 +578,16 @@ * {@inheritDoc} */ public void close() throws IOException { - if (servletRequestContext.getOriginalRequest().getDispatcherType() == DispatcherType.INCLUDE) { + if (servletRequestContext.getOriginalRequest().getDispatcherType() == DispatcherType.INCLUDE || + servletRequestContext.getOriginalResponse().isTreatAsCommitted()) { return; } if (listener == null) { if (anyAreSet(state, FLAG_CLOSED)) return; state |= FLAG_CLOSED; state &= ~FLAG_READY; if (allAreClear(state, FLAG_WRITE_STARTED) && channel == null && servletRequestContext.getOriginalResponse().getHeader(Headers.CONTENT_LENGTH_STRING) == null) { - if(servletRequestContext.getOriginalResponse().getHeader(Headers.TRANSFER_ENCODING_STRING) == null) { + if (servletRequestContext.getOriginalResponse().getHeader(Headers.TRANSFER_ENCODING_STRING) == null) { if (buffer == null) { servletRequestContext.getExchange().getResponseHeaders().put(Headers.CONTENT_LENGTH, "0"); } else { @@ -620,7 +604,7 @@ } state |= FLAG_DELEGATE_SHUTDOWN; StreamSinkChannel channel = this.channel; - if(channel != null) { //mock requests + if (channel != null) { //mock requests channel.shutdownWrites(); Channels.flushBlocking(channel); } @@ -647,13 +631,15 @@ * @throws IOException */ public void closeAsync() throws IOException { - if (anyAreSet(state, FLAG_CLOSED)) return; + if (anyAreSet(state, FLAG_CLOSED) || servletRequestContext.getOriginalResponse().isTreatAsCommitted()) { + return; + } state |= FLAG_CLOSED; state &= ~FLAG_READY; if (allAreClear(state, FLAG_WRITE_STARTED) && channel == null) { - if(servletRequestContext.getOriginalResponse().getHeader(Headers.TRANSFER_ENCODING_STRING) == null) { + if (servletRequestContext.getOriginalResponse().getHeader(Headers.TRANSFER_ENCODING_STRING) == null) { if (buffer == null) { servletRequestContext.getOriginalResponse().setHeader(Headers.CONTENT_LENGTH, "0"); } else { @@ -664,7 +650,6 @@ createChannel(); if (buffer != null) { if (!flushBufferAsync(true)) { - resumeWrites(); return; } @@ -677,15 +662,18 @@ } channel.shutdownWrites(); state |= FLAG_DELEGATE_SHUTDOWN; - if (!channel.flush()) { - resumeWrites(); + if(!channel.flush()) { + channel.resumeWrites(); } } private void createChannel() { if (channel == null) { channel = servletRequestContext.getExchange().getResponseChannel(); channel.getWriteSetter().set(internalListener); + if(internalListener != null) { + channel.resumeWrites(); + } } } @@ -718,7 +706,7 @@ } public void setBufferSize(final int size) { - if (buffer != null) { + if (buffer != null || servletRequestContext.getOriginalResponse().isTreatAsCommitted()) { throw UndertowServletMessages.MESSAGES.contentHasBeenWritten(); } this.bufferSize = size; @@ -756,7 +744,17 @@ //under normal circumstances this will break write listener delegation this.internalListener = new WriteChannelListener(); //we resume from an async task, after the request has been dispatched - internalListener.handleEvent(null); + asyncContext.addAsyncTask(new Runnable() { + @Override + public void run() { + servletRequestContext.getExchange().getIoThread().execute(new Runnable() { + @Override + public void run() { + internalListener.handleEvent(null); + } + }); + } + }); } ServletRequestContext getServletRequestContext() { @@ -768,120 +766,108 @@ @Override public void handleEvent(final StreamSinkChannel aChannel) { - if (channel != null) { - channel.suspendWrites(); + //flush the channel if it is closed + if (anyAreSet(state, FLAG_DELEGATE_SHUTDOWN)) { + try { + //either it will work, and the channel is closed + //or it won't, and we continue with writes resumed + channel.flush(); + return; + } catch (IOException e) { + handleError(e); + return; + } } - //we run this whole thing as a async task, to avoid threading issues - asyncContext.addAsyncTask(new Runnable() { - @Override - public void run() { - //flush the channel if it is closed - if (anyAreSet(state, FLAG_DELEGATE_SHUTDOWN)) { - try { - //either it will work, and the channel is closed - //or it won't, and we continue with writes resumed - if (!channel.flush()) { - resumeWrites(); - } + //if there is data still to write + if (buffersToWrite != null) { + long toWrite = Buffers.remaining(buffersToWrite); + long written = 0; + long res; + do { + try { + res = channel.write(buffersToWrite); + written += res; + if (res == 0) { return; - } catch (IOException e) { - handleError(e); - return; } + } catch (IOException e) { + handleError(e); + return; } - //if there is data still to write - if (buffersToWrite != null) { - long toWrite = Buffers.remaining(buffersToWrite); - long written = 0; - long res; - do { - try { - res = channel.write(buffersToWrite); - written += res; - if (res == 0) { - resumeWrites(); - return; - } - } catch (IOException e) { - handleError(e); - return; - } - } while (written < toWrite); - buffersToWrite = null; - } - if (pendingFile != null) { - try { - long size = pendingFile.size(); - long pos = pendingFile.position(); + } while (written < toWrite); + buffersToWrite = null; + buffer.clear(); + } + if (pendingFile != null) { + try { + long size = pendingFile.size(); + long pos = pendingFile.position(); - while (size - pos > 0) { - long ret = channel.transferFrom(pendingFile, pos, size - pos); - if (ret <= 0) { - pendingFile.position(pos); - resumeWrites(); - return; - } - pos += ret; - } - pendingFile = null; - } catch (IOException e) { - handleError(e); + while (size - pos > 0) { + long ret = channel.transferFrom(pendingFile, pos, size - pos); + if (ret <= 0) { + pendingFile.position(pos); return; } + pos += ret; } - if (anyAreSet(state, FLAG_CLOSED)) { - try { + pendingFile = null; + } catch (IOException e) { + handleError(e); + return; + } + } + if (anyAreSet(state, FLAG_CLOSED)) { + try { - if (pooledBuffer != null) { - pooledBuffer.free(); - buffer = null; - } else { - buffer = null; - } - channel.shutdownWrites(); - state |= FLAG_DELEGATE_SHUTDOWN; - if (!channel.flush()) { - resumeWrites(); - } - } catch (IOException e) { - handleError(e); - return; - } + if (pooledBuffer != null) { + pooledBuffer.free(); + buffer = null; } else { + buffer = null; + } + channel.shutdownWrites(); + state |= FLAG_DELEGATE_SHUTDOWN; + channel.flush(); + } catch (IOException e) { + handleError(e); + return; + } + } else { - if (asyncContext.isDispatched()) { - //this is no longer an async request - //we just return for now - //TODO: what do we do here? Revert back to blocking mode? - return; - } + if (asyncContext.isDispatched()) { + //this is no longer an async request + //we just return for now + //TODO: what do we do here? Revert back to blocking mode? + return; + } - state |= FLAG_READY; - try { - state |= FLAG_IN_CALLBACK; + state |= FLAG_READY; + try { + state |= FLAG_IN_CALLBACK; - ThreadSetupAction.Handle handle = threadSetupAction.setup(servletRequestContext.getExchange()); - try { - listener.onWritePossible(); - } finally { - handle.tearDown(); - } - if (!isReady()) { - //if the stream is still ready then we do not resume writes - //this is per spec, we only call the listener once for each time - //isReady returns true - state &= ~FLAG_IN_CALLBACK; - resumeWrites(); - } - } catch (Throwable e) { - IoUtils.safeClose(channel); - } finally { - state &= ~FLAG_IN_CALLBACK; + ThreadSetupAction.Handle handle = threadSetupAction.setup(servletRequestContext.getExchange()); + try { + listener.onWritePossible(); + } finally { + handle.tearDown(); + } + if (isReady()) { + //if the stream is still ready then we do not resume writes + //this is per spec, we only call the listener once for each time + //isReady returns true + if(channel != null) { + channel.suspendWrites(); } } + } catch (Throwable e) { + IoUtils.safeClose(channel); + } finally { + state &= ~FLAG_IN_CALLBACK; } - }); + } + } private void handleError(final IOException e) { Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletPrintWriter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/ServletPrintWriter.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletPrintWriter.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletPrintWriter.java 25 Nov 2014 10:46:46 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.spec; import javax.servlet.DispatcherType; @@ -123,26 +141,6 @@ } if (charsetEncoder == null) { - //fast path, basically we are hoping this is ascii only - int remaining = buffer.remaining(); - boolean ok = true; - //so we have a pure ascii buffer, just write it out and skip all the encoder cost - while (input.hasRemaining()) { - if (!buffer.hasRemaining()) { - outputStream.flushInternal(); - } - char c = input.get(); - if (c > 127) { - ok = false; - input.position(input.position() - 1); //push the character back - break; - } - buffer.put((byte) c); - } - outputStream.updateWritten(remaining - buffer.remaining()); - if (ok) { - return; - } createEncoder(); } final CharBuffer cb; @@ -194,73 +192,148 @@ } public void write(final int c) { - final CharBuffer cb = CharBuffer.wrap(Character.toString((char) c)); - write(cb); + write(Character.toString((char)c)); } public void write(final char[] buf, final int off, final int len) { + if(charsetEncoder == null) { + try { + ByteBuffer buffer = outputStream.underlyingBuffer(); + if(buffer == null) { + //already closed + error = true; + return; + } + //fast path, basically we are hoping this is ascii only + int remaining = buffer.remaining(); + boolean ok = true; + //so we have a pure ascii buffer, just write it out and skip all the encoder cost + + int end = off + len; + int i = off; + int flushPos = i + remaining; + while (ok && i < end) { + int realEnd = Math.min(end, flushPos); + for (; i < realEnd; ++i) { + char c = buf[i]; + if (c > 127) { + ok = false; + break; + } else { + buffer.put((byte) c); + } + } + if (i == flushPos) { + outputStream.flushInternal(); + flushPos = i + buffer.remaining(); + } + } + outputStream.updateWritten(remaining - buffer.remaining()); + if (ok) { + return; + } + final CharBuffer cb = CharBuffer.wrap(buf, i, len - (i - off)); + write(cb); + return; + } catch (IOException e) { + error = false; + return; + } + + } final CharBuffer cb = CharBuffer.wrap(buf, off, len); write(cb); } public void write(final char[] buf) { - final CharBuffer cb = CharBuffer.wrap(buf); - write(cb); + write(buf,0, buf.length); } public void write(final String s, final int off, final int len) { + if(charsetEncoder == null) { + try { + ByteBuffer buffer = outputStream.underlyingBuffer(); + if(buffer == null) { + //already closed + error = true; + return; + } + //fast path, basically we are hoping this is ascii only + int remaining = buffer.remaining(); + boolean ok = true; + //so we have a pure ascii buffer, just write it out and skip all the encoder cost + + int end = off + len; + int i = off; + int fpos = i + remaining; + for (; i < end; ++i) { + if (i == fpos) { + outputStream.flushInternal(); + fpos = i + buffer.remaining(); + } + char c = s.charAt(i); + if (c > 127) { + ok = false; + break; + } + buffer.put((byte) c); + } + outputStream.updateWritten(remaining - buffer.remaining()); + if (ok) { + return; + } + //wrap(String, off, len) acts wrong in the presence of multi byte characters + final CharBuffer cb = CharBuffer.wrap(s.toCharArray(), i, len - (i - off)); + write(cb); + return; + } catch (IOException e) { + error = false; + return; + } + + } final CharBuffer cb = CharBuffer.wrap(s, off, off + len); write(cb); } public void write(final String s) { - final CharBuffer cb = CharBuffer.wrap(s); - write(cb); + write(s, 0, s.length()); } public void print(final boolean b) { - final CharBuffer cb = CharBuffer.wrap(Boolean.toString(b)); - write(cb); + write(Boolean.toString(b)); } public void print(final char c) { - final CharBuffer cb = CharBuffer.wrap(Character.toString(c)); - write(cb); + write(Character.toString(c)); } public void print(final int i) { - final CharBuffer cb = CharBuffer.wrap(Integer.toString(i)); - write(cb); + write(Integer.toString(i)); } public void print(final long l) { - final CharBuffer cb = CharBuffer.wrap(Long.toString(l)); - write(cb); + write(Long.toString(l)); } public void print(final float f) { - final CharBuffer cb = CharBuffer.wrap(Float.toString(f)); - write(cb); + write(Float.toString(f)); } public void print(final double d) { - final CharBuffer cb = CharBuffer.wrap(Double.toString(d)); - write(cb); + write(Double.toString(d)); } public void print(final char[] s) { - final CharBuffer cb = CharBuffer.wrap(s); - write(cb); + write(CharBuffer.wrap(s)); } public void print(final String s) { - final CharBuffer cb = CharBuffer.wrap(s == null ? "null" : s); - write(cb); + write(s == null ? "null" : s); } public void print(final Object obj) { - final CharBuffer cb = CharBuffer.wrap(obj == null ? "null" : obj.toString()); - write(cb); + write(obj == null ? "null" : obj.toString()); } public void println() { @@ -330,10 +403,11 @@ } public void append(final CharSequence csq) { - if (csq == null) + if (csq == null) { write("null"); - else + } else { write(csq.toString()); + } } public void append(final CharSequence csq, final int start, final int end) { Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletPrintWriterDelegate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/ServletPrintWriterDelegate.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletPrintWriterDelegate.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletPrintWriterDelegate.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.spec; import java.io.OutputStream; Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletRegistrationImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/ServletRegistrationImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletRegistrationImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/ServletRegistrationImpl.java 25 Nov 2014 10:46:46 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; @@ -40,6 +40,7 @@ import io.undertow.servlet.api.ServletSecurityInfo; import io.undertow.servlet.api.TransportGuaranteeType; import io.undertow.servlet.api.WebResourceCollection; +import io.undertow.servlet.core.ManagedServlet; import static javax.servlet.annotation.ServletSecurity.TransportGuarantee.CONFIDENTIAL; @@ -49,10 +50,12 @@ public class ServletRegistrationImpl implements ServletRegistration, ServletRegistration.Dynamic { private final ServletInfo servletInfo; + private final ManagedServlet managedServlet; private final Deployment deployment; - public ServletRegistrationImpl(final ServletInfo servletInfo, final Deployment deployment) { + public ServletRegistrationImpl(final ServletInfo servletInfo, ManagedServlet managedServlet, final Deployment deployment) { this.servletInfo = servletInfo; + this.managedServlet = managedServlet; this.deployment = deployment; } @@ -69,13 +72,13 @@ DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); //this is not super efficient, but it does not really matter - final Set urlPatterns = new HashSet(); + final Set urlPatterns = new HashSet<>(); for (SecurityConstraint sc : deploymentInfo.getSecurityConstraints()) { for (WebResourceCollection webResources : sc.getWebResourceCollections()) { urlPatterns.addAll(webResources.getUrlPatterns()); } } - final Set ret = new HashSet(); + final Set ret = new HashSet<>(); for (String url : servletInfo.getMappings()) { if (urlPatterns.contains(url)) { ret.add(url); @@ -111,6 +114,7 @@ @Override public void setMultipartConfig(final MultipartConfigElement multipartConfig) { servletInfo.setMultipartConfig(multipartConfig); + managedServlet.setupMultipart(deployment.getServletContext()); } @Override @@ -126,8 +130,8 @@ @Override public Set addMapping(final String... urlPatterns) { DeploymentInfo deploymentInfo = deployment.getDeploymentInfo(); - final Set ret = new HashSet(); - final Set existing = new HashSet(); + final Set ret = new HashSet<>(); + final Set existing = new HashSet<>(); for (ServletInfo s : deploymentInfo.getServlets().values()) { if (!s.getName().equals(servletInfo.getName())) { existing.addAll(s.getMappings()); @@ -187,7 +191,7 @@ @Override public Set setInitParameters(final Map initParameters) { - final Set ret = new HashSet(); + final Set ret = new HashSet<>(); for (Map.Entry entry : initParameters.entrySet()) { if (!setInitParameter(entry.getKey(), entry.getValue())) { ret.add(entry.getKey()); Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/SessionCookieConfigImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/SessionCookieConfigImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/SessionCookieConfigImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/SessionCookieConfigImpl.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.spec; Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/UpgradeServletInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/UpgradeServletInputStream.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/UpgradeServletInputStream.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/UpgradeServletInputStream.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.spec; import io.undertow.servlet.UndertowServletMessages; @@ -15,7 +33,6 @@ import java.nio.ByteBuffer; import java.util.concurrent.Executor; -import static org.xnio.Bits.allAreClear; import static org.xnio.Bits.anyAreClear; import static org.xnio.Bits.anyAreSet; @@ -141,7 +158,7 @@ } private void readIntoBufferNonBlocking() throws IOException { - if (pooled == null && !anyAreSet(state, FLAG_FINISHED)) { + if (pooled == null && !anyAreSet(state, FLAG_FINISHED | FLAG_CLOSED)) { pooled = bufferPool.allocate(); if (listener == null) { int res = channel.read(pooled.getResource()); @@ -205,19 +222,13 @@ if (anyAreSet(state, FLAG_CLOSED)) { return; } - while (allAreClear(state, FLAG_FINISHED)) { - readIntoBuffer(); - if (pooled != null) { - pooled.free(); - pooled = null; - } - } + state |= FLAG_FINISHED | FLAG_CLOSED; if (pooled != null) { pooled.free(); pooled = null; } + channel.suspendReads(); channel.shutdownReads(); - state |= FLAG_FINISHED | FLAG_CLOSED; } private class ServletInputStreamChannelListener implements ChannelListener { @@ -236,6 +247,10 @@ } } } catch (Exception e) { + if(pooled != null) { + pooled.free(); + pooled = null; + } listener.onError(e); IoUtils.safeClose(channel); } @@ -246,6 +261,10 @@ channel.shutdownReads(); listener.onAllDataRead(); } catch (IOException e) { + if(pooled != null) { + pooled.free(); + pooled = null; + } listener.onError(e); IoUtils.safeClose(channel); } Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/UpgradeServletOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/UpgradeServletOutputStream.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/UpgradeServletOutputStream.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/UpgradeServletOutputStream.java 25 Nov 2014 10:46:47 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.spec; import io.undertow.servlet.UndertowServletMessages; Index: 3rdParty_sources/undertow/io/undertow/servlet/spec/WebConnectionImpl.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/spec/Attic/WebConnectionImpl.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/spec/WebConnectionImpl.java 9 Sep 2014 14:33:14 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/spec/WebConnectionImpl.java 25 Nov 2014 10:46:46 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.spec; import java.io.IOException; @@ -8,6 +26,8 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.WebConnection; +import org.xnio.ChannelListener; +import org.xnio.IoUtils; import org.xnio.Pool; import org.xnio.StreamConnection; @@ -16,14 +36,26 @@ */ public class WebConnectionImpl implements WebConnection { + private final StreamConnection channel; private final UpgradeServletOutputStream outputStream; private final UpgradeServletInputStream inputStream; private final Executor ioExecutor; public WebConnectionImpl(final StreamConnection channel, Pool bufferPool, Executor ioExecutor) { + this.channel = channel; this.ioExecutor = ioExecutor; this.outputStream = new UpgradeServletOutputStream(channel.getSinkChannel(), ioExecutor); this.inputStream = new UpgradeServletInputStream(channel.getSourceChannel(), bufferPool, ioExecutor); + channel.getCloseSetter().set(new ChannelListener() { + @Override + public void handleEvent(StreamConnection channel) { + try { + close(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }); } @Override @@ -38,6 +70,10 @@ @Override public void close() throws Exception { - outputStream.closeBlocking(); + try { + outputStream.closeBlocking(); + } finally { + IoUtils.safeClose(inputStream, channel); + } } } Index: 3rdParty_sources/undertow/io/undertow/servlet/util/ConstructorInstanceFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/util/Attic/ConstructorInstanceFactory.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/util/ConstructorInstanceFactory.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/util/ConstructorInstanceFactory.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.util; @@ -40,7 +40,7 @@ public InstanceHandle createInstance() throws InstantiationException { try { final T instance = constructor.newInstance(); - return new ImmediateInstanceHandle(instance); + return new ImmediateInstanceHandle<>(instance); } catch (IllegalAccessException e) { InstantiationException ite = new InstantiationException(); ite.initCause(e); Index: 3rdParty_sources/undertow/io/undertow/servlet/util/DefaultClassIntrospector.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/util/Attic/DefaultClassIntrospector.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/util/DefaultClassIntrospector.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/util/DefaultClassIntrospector.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.util; @@ -33,6 +33,6 @@ @Override public InstanceFactory createInstanceFactory(final Class clazz) throws NoSuchMethodException { - return new ConstructorInstanceFactory(clazz.getDeclaredConstructor()); + return new ConstructorInstanceFactory<>(clazz.getDeclaredConstructor()); } } Index: 3rdParty_sources/undertow/io/undertow/servlet/util/EmptyEnumeration.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/util/Attic/EmptyEnumeration.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/util/EmptyEnumeration.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/util/EmptyEnumeration.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.util; Index: 3rdParty_sources/undertow/io/undertow/servlet/util/ImmediateInstanceFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/util/Attic/ImmediateInstanceFactory.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/util/ImmediateInstanceFactory.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/util/ImmediateInstanceFactory.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.util; @@ -34,6 +34,6 @@ @Override public InstanceHandle createInstance() throws InstantiationException { - return new ImmediateInstanceHandle(instance); + return new ImmediateInstanceHandle<>(instance); } } Index: 3rdParty_sources/undertow/io/undertow/servlet/util/ImmediateInstanceHandle.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/util/Attic/ImmediateInstanceHandle.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/util/ImmediateInstanceHandle.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/util/ImmediateInstanceHandle.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.util; Index: 3rdParty_sources/undertow/io/undertow/servlet/util/InMemorySessionPersistence.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/util/Attic/InMemorySessionPersistence.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/util/InMemorySessionPersistence.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/util/InMemorySessionPersistence.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.util; import io.undertow.servlet.UndertowServletLogger; @@ -19,14 +37,14 @@ */ public class InMemorySessionPersistence implements SessionPersistenceManager { - private static final Map> data = new ConcurrentHashMap>(); + private static final Map> data = new ConcurrentHashMap<>(); @Override public void persistSessions(String deploymentName, Map sessionData) { try { - final Map serializedData = new HashMap(); + final Map serializedData = new HashMap<>(); for (Map.Entry sessionEntry : sessionData.entrySet()) { - Map data = new HashMap(); + Map data = new HashMap<>(); for (Map.Entry sessionAttribute : sessionEntry.getValue().getSessionData().entrySet()) { try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -53,10 +71,10 @@ long time = System.currentTimeMillis(); Map data = this.data.remove(deploymentName); if (data != null) { - Map ret = new HashMap(); + Map ret = new HashMap<>(); for (Map.Entry sessionEntry : data.entrySet()) { if (sessionEntry.getValue().expiry.getTime() > time) { - Map session = new HashMap(); + Map session = new HashMap<>(); for (Map.Entry sessionAttribute : sessionEntry.getValue().data.entrySet()) { final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(sessionAttribute.getValue())); session.put(sessionAttribute.getKey(), in.readObject()); Index: 3rdParty_sources/undertow/io/undertow/servlet/util/IteratorEnumeration.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/util/Attic/IteratorEnumeration.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/util/IteratorEnumeration.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/util/IteratorEnumeration.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.util; Index: 3rdParty_sources/undertow/io/undertow/servlet/util/SavedRequest.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/util/Attic/SavedRequest.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/util/SavedRequest.java 9 Sep 2014 14:33:12 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/util/SavedRequest.java 25 Nov 2014 10:47:01 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.util; import io.undertow.UndertowLogger; @@ -108,7 +126,7 @@ if(request.requestUri.equals(exchange.getRequestURI()) && exchange.isRequestComplete()) { UndertowLogger.REQUEST_LOGGER.debugf("restoring request body for request to %s", request.requestUri); exchange.setRequestMethod(request.method); - Connectors.ungetRequestBytes(exchange, new ImmediatePooled(ByteBuffer.wrap(request.data, 0, request.dataLength))); + Connectors.ungetRequestBytes(exchange, new ImmediatePooled<>(ByteBuffer.wrap(request.data, 0, request.dataLength))); underlyingSession.removeAttribute(SESSION_KEY); //clear the existing header map of everything except the connection header //TODO: are there other headers we should preserve? Index: 3rdParty_sources/undertow/io/undertow/servlet/websockets/SecurityActions.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/websockets/Attic/SecurityActions.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/websockets/SecurityActions.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/websockets/SecurityActions.java 25 Nov 2014 10:47:02 -0000 1.1.2.2 @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.websockets; Index: 3rdParty_sources/undertow/io/undertow/servlet/websockets/ServletWebSocketHttpExchange.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/websockets/Attic/ServletWebSocketHttpExchange.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/websockets/ServletWebSocketHttpExchange.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/websockets/ServletWebSocketHttpExchange.java 25 Nov 2014 10:47:02 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,18 +9,19 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.servlet.websockets; import io.undertow.server.HttpServerExchange; import io.undertow.server.HttpUpgradeListener; import io.undertow.util.AttachmentKey; +import io.undertow.websockets.core.WebSocketChannel; import io.undertow.websockets.spi.WebSocketHttpExchange; import org.xnio.FinishedIoFuture; import org.xnio.FutureResult; @@ -44,6 +45,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.TreeMap; /** * @author Stuart Douglas @@ -53,10 +56,12 @@ private final HttpServletRequest request; private final HttpServletResponse response; private final HttpServerExchange exchange; + private final Set peerConnections; - public ServletWebSocketHttpExchange(final HttpServletRequest request, final HttpServletResponse response) { + public ServletWebSocketHttpExchange(final HttpServletRequest request, final HttpServletResponse response, Set peerConnections) { this.request = request; this.response = response; + this.peerConnections = peerConnections; this.exchange = SecurityActions.requireCurrentServletRequestContext().getOriginalRequest().getExchange(); } @@ -78,12 +83,12 @@ @Override public Map> getRequestHeaders() { - Map> headers = new HashMap>(); + Map> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); final Enumeration headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String header = headerNames.nextElement(); final Enumeration theHeaders = request.getHeaders(header); - final List vals = new ArrayList(); + final List vals = new ArrayList<>(); headers.put(header, vals); while (theHeaders.hasMoreElements()) { vals.add(theHeaders.nextElement()); @@ -100,10 +105,10 @@ @Override public Map> getResponseHeaders() { - Map> headers = new HashMap>(); + Map> headers = new HashMap<>(); final Collection headerNames = response.getHeaderNames(); for (String header : headerNames) { - headers.put(header, new ArrayList(response.getHeaders(header))); + headers.put(header, new ArrayList<>(response.getHeaders(header))); } return Collections.unmodifiableMap(headers); } @@ -138,9 +143,9 @@ while (data.hasRemaining()) { outputStream.write(data.get()); } - return new FinishedIoFuture(null); + return new FinishedIoFuture<>(null); } catch (IOException e) { - final FutureResult ioFuture = new FutureResult(); + final FutureResult ioFuture = new FutureResult<>(); ioFuture.setException(e); return ioFuture.getIoFuture(); } @@ -156,9 +161,9 @@ while ((r = in.read(buf)) != -1) { data.write(buf, 0, r); } - return new FinishedIoFuture(data.toByteArray()); + return new FinishedIoFuture<>(data.toByteArray()); } catch (IOException e) { - final FutureResult ioFuture = new FutureResult(); + final FutureResult ioFuture = new FutureResult<>(); ioFuture.setException(e); return ioFuture.getIoFuture(); } @@ -202,9 +207,9 @@ @Override public Map> getRequestParameters() { - Map> params = new HashMap>(); + Map> params = new HashMap<>(); for(Map.Entry param : request.getParameterMap().entrySet()) { - params.put(param.getKey(), new ArrayList(Arrays.asList(param.getValue()))); + params.put(param.getKey(), new ArrayList<>(Arrays.asList(param.getValue()))); } return params; } @@ -218,4 +223,9 @@ public boolean isUserInRole(String role) { return request.isUserInRole(role); } + + @Override + public Set getPeerConnections() { + return peerConnections; + } } Index: 3rdParty_sources/undertow/io/undertow/servlet/websockets/WebSocketServlet.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/servlet/websockets/Attic/WebSocketServlet.java,v diff -u -r1.1.2.1 -r1.1.2.2 --- 3rdParty_sources/undertow/io/undertow/servlet/websockets/WebSocketServlet.java 9 Sep 2014 14:33:16 -0000 1.1.2.1 +++ 3rdParty_sources/undertow/io/undertow/servlet/websockets/WebSocketServlet.java 25 Nov 2014 10:47:02 -0000 1.1.2.2 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.servlet.websockets; import io.undertow.UndertowLogger; @@ -19,7 +37,10 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; /** * @author Stuart Douglas @@ -32,6 +53,8 @@ private WebSocketConnectionCallback callback; + private Set peerConnections; + public WebSocketServlet() { this.handshakes = handshakes(); } @@ -45,6 +68,7 @@ @Override public void init(final ServletConfig config) throws ServletException { super.init(config); + peerConnections = Collections.newSetFromMap(new ConcurrentHashMap()); try { final String sessionHandler = config.getInitParameter(SESSION_HANDLER); if (sessionHandler != null) { @@ -69,7 +93,7 @@ @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { - final ServletWebSocketHttpExchange facade = new ServletWebSocketHttpExchange(req, resp); + final ServletWebSocketHttpExchange facade = new ServletWebSocketHttpExchange(req, resp, peerConnections); Handshake handshaker = null; for (Handshake method : handshakes) { if (method.matches(facade)) { @@ -88,14 +112,15 @@ @Override public void handleUpgrade(StreamConnection streamConnection, HttpServerExchange exchange) { WebSocketChannel channel = selected.createChannel(facade, streamConnection, facade.getBufferPool()); + peerConnections.add(channel); callback.onConnect(facade, channel); } }); handshaker.handshake(facade); } protected List handshakes() { - List handshakes = new ArrayList(); + List handshakes = new ArrayList<>(); handshakes.add(new Hybi13Handshake()); handshakes.add(new Hybi08Handshake()); handshakes.add(new Hybi07Handshake()); Index: 3rdParty_sources/undertow/io/undertow/util/AbstractAttachable.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/AbstractAttachable.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/AbstractAttachable.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/AbstractAttachable.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -42,7 +42,7 @@ if (key == null || attachments == null) { return null; } - return key.cast(attachments.get(key)); + return (T) attachments.get(key); } /** @@ -53,7 +53,7 @@ if (key == null || attachments == null) { return Collections.emptyList(); } - List list = key.cast(attachments.get(key)); + List list = (List) attachments.get(key); if (list == null) { return Collections.emptyList(); } @@ -69,11 +69,15 @@ throw UndertowMessages.MESSAGES.argumentCannotBeNull("key"); } if(attachments == null) { - attachments = new IdentityHashMap, Object>(5); + attachments = createAttachmentMap(); } - return key.cast(attachments.put(key, key.cast(value))); + return (T) attachments.put(key, value); } + protected Map, Object> createAttachmentMap() { + return new IdentityHashMap<>(5); + } + /** * {@inheritDoc} */ @@ -82,7 +86,7 @@ if (key == null || attachments == null) { return null; } - return key.cast(attachments.remove(key)); + return (T) attachments.remove(key); } /** @@ -92,12 +96,12 @@ public void addToAttachmentList(final AttachmentKey> key, final T value) { if (key != null) { if(attachments == null) { - attachments = new IdentityHashMap, Object>(5); + attachments = createAttachmentMap(); } final Map, Object> attachments = this.attachments; - final AttachmentList list = key.cast(attachments.get(key)); + final AttachmentList list = (AttachmentList) attachments.get(key); if (list == null) { - final AttachmentList newList = new AttachmentList(((ListAttachmentKey) key).getValueClass()); + final AttachmentList newList = new AttachmentList<>(((ListAttachmentKey) key).getValueClass()); attachments.put(key, newList); newList.add(value); } else { Index: 3rdParty_sources/undertow/io/undertow/util/Attachable.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/Attachable.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/Attachable.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/Attachable.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/AttachmentKey.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/AttachmentKey.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/AttachmentKey.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/AttachmentKey.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/AttachmentList.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/AttachmentList.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/AttachmentList.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/AttachmentList.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/CanonicalPathUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/CanonicalPathUtils.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/CanonicalPathUtils.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/CanonicalPathUtils.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -70,7 +70,7 @@ int state = initialState; int eatCount = 0; int tokenEnd = path.length(); - final List parts = new ArrayList(); + final List parts = new ArrayList<>(); for (int i = lastDot - 1; i >= 0; --i) { final char c = path.charAt(i); switch (state) { Index: 3rdParty_sources/undertow/io/undertow/util/Certificates.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/Certificates.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/Certificates.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/Certificates.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import javax.security.cert.CertificateEncodingException; Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/util/ChaninedHandlerWrapper.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/util/ClosingChannelExceptionHandler.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/util/ConcurrentDirectDeque.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/ConcurrentDirectDeque.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/ConcurrentDirectDeque.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/ConcurrentDirectDeque.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/ConduitFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/ConduitFactory.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/ConduitFactory.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/ConduitFactory.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import org.xnio.conduits.Conduit; Index: 3rdParty_sources/undertow/io/undertow/util/Cookies.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/Cookies.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/Cookies.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/Cookies.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import io.undertow.UndertowMessages; @@ -173,9 +191,9 @@ public static Map parseRequestCookies(int maxCookies, boolean allowEqualInValue, List cookies) { if (cookies == null) { - return new TreeMap(); + return new TreeMap<>(); } - final Map parsedCookies = new TreeMap(); + final Map parsedCookies = new TreeMap<>(); for (String cookie : cookies) { parseCookie(cookie, parsedCookies, maxCookies, allowEqualInValue); @@ -188,8 +206,8 @@ String name = null; int start = 0; int cookieCount = parsedCookies.size(); - final Map cookies = new HashMap(); - final Map additional = new HashMap(); + final Map cookies = new HashMap<>(); + final Map additional = new HashMap<>(); for (int i = 0; i < cookie.length(); ++i) { char c = cookie.charAt(i); switch (state) { @@ -221,7 +239,7 @@ cookieCount = createCookie(name, cookie.substring(start, i), maxCookies, cookieCount, cookies, additional); state = 0; start = i + 1; - } else if (c == '"') { + } else if (c == '"' && start == i) { //only process the " if it is the first character state = 3; start = i + 1; } else if (!allowEqualInValue && c == '=') { @@ -274,7 +292,7 @@ private static int createCookie(final String name, final String value, int maxCookies, int cookieCount, final Map cookies, final Map additional) { - if (name.charAt(0) == '$') { + if (!name.isEmpty() && name.charAt(0) == '$') { if(additional.containsKey(name)) { return cookieCount; } Index: 3rdParty_sources/undertow/io/undertow/util/CopyOnWriteMap.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/CopyOnWriteMap.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/CopyOnWriteMap.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/CopyOnWriteMap.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import java.util.Collection; @@ -24,7 +42,7 @@ } public CopyOnWriteMap(Map existing) { - this.delegate = new HashMap(existing); + this.delegate = new HashMap<>(existing); } @Override @@ -108,7 +126,7 @@ @Override public synchronized void putAll(Map m) { - final Map delegate = new HashMap(this.delegate); + final Map delegate = new HashMap<>(this.delegate); for(Entry e : m.entrySet()) { delegate.put(e.getKey(), e.getValue()); } @@ -137,14 +155,14 @@ //must be called under lock private V putInternal(final K key, final V value) { - final Map delegate = new HashMap(this.delegate); + final Map delegate = new HashMap<>(this.delegate); V existing = delegate.put(key, value); this.delegate = delegate; return existing; } public V removeInternal(final Object key) { - final Map delegate = new HashMap(this.delegate); + final Map delegate = new HashMap<>(this.delegate); V existing = delegate.remove(key); this.delegate = delegate; return existing; Index: 3rdParty_sources/undertow/io/undertow/util/DateUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/DateUtils.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/DateUtils.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/DateUtils.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,24 +9,26 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; +import io.undertow.UndertowOptions; +import io.undertow.server.HttpServerExchange; + import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; -import io.undertow.UndertowOptions; -import io.undertow.server.HttpServerExchange; - /** * Utility for parsing and generating dates * @@ -40,24 +42,33 @@ private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; - private static volatile String cachedDateString; - private static volatile long nextUpdateTime = -1; + private static final AtomicReference cachedDateString = new AtomicReference<>(); /** * Thread local cache of this date format. This is technically a small memory leak, however * in practice it is fine, as it will only be used by server threads. - * + *

    * This is the most common date format, which is why we cache it. */ private static final ThreadLocal RFC1123_PATTERN_FORMAT = new ThreadLocal() { @Override protected SimpleDateFormat initialValue() { - SimpleDateFormat df = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); + SimpleDateFormat df = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); df.setTimeZone(GMT_ZONE); return df; } }; + /** + * Invalidates the current date + */ + private static final Runnable INVALIDATE_TASK = new Runnable() { + @Override + public void run() { + cachedDateString.set(null); + } + }; + private static final String RFC1036_PATTERN = "EEEEEEEEE, dd-MMM-yy HH:mm:ss z"; private static final String ASCITIME_PATTERN = "EEE MMM d HH:mm:ss yyyyy"; @@ -71,7 +82,7 @@ private static final ThreadLocal COMMON_LOG_PATTERN_FORMAT = new ThreadLocal() { @Override protected SimpleDateFormat initialValue() { - SimpleDateFormat df = new SimpleDateFormat(COMMON_LOG_PATTERN, LOCALE_US); + SimpleDateFormat df = new SimpleDateFormat(COMMON_LOG_PATTERN, LOCALE_US); return df; } }; @@ -113,7 +124,7 @@ */ final int semicolonIndex = date.indexOf(';'); - final String trimmedDate = semicolonIndex >=0 ? date.substring(0, semicolonIndex) : date; + final String trimmedDate = semicolonIndex >= 0 ? date.substring(0, semicolonIndex) : date; ParsePosition pp = new ParsePosition(0); SimpleDateFormat dateFormat = RFC1123_PATTERN_FORMAT.get(); @@ -157,18 +168,7 @@ * @return */ public static boolean handleIfModifiedSince(final HttpServerExchange exchange, final Date lastModified) { - if (lastModified == null) { - return true; - } - String modifiedSince = exchange.getRequestHeaders().getFirst(Headers.IF_MODIFIED_SINCE); - if (modifiedSince == null) { - return true; - } - Date modDate = parseDate(modifiedSince); - if (modDate == null) { - return true; - } - return lastModified.after(modDate); + return handleIfModifiedSince(exchange.getRequestHeaders().getFirst(Headers.IF_MODIFIED_SINCE), lastModified); } /** @@ -189,7 +189,7 @@ if (modDate == null) { return true; } - return lastModified.after(modDate); + return lastModified.getTime() > (modDate.getTime() + 999); //UNDERTOW-341 +999 as there is no millisecond part in the if-modified-since } /** @@ -200,18 +200,7 @@ * @return */ public static boolean handleIfUnmodifiedSince(final HttpServerExchange exchange, final Date lastModified) { - if (lastModified == null) { - return true; - } - String modifiedSince = exchange.getRequestHeaders().getFirst(Headers.IF_UNMODIFIED_SINCE); - if (modifiedSince == null) { - return true; - } - Date modDate = parseDate(modifiedSince); - if (modDate == null) { - return true; - } - return lastModified.before(modDate); + return handleIfModifiedSince(exchange.getRequestHeaders().getFirst(Headers.IF_UNMODIFIED_SINCE), lastModified); } /** @@ -232,20 +221,26 @@ if (modDate == null) { return true; } - return lastModified.after(modDate); + return lastModified.getTime() < (modDate.getTime() + 999); //UNDERTOW-341 +999 as there is no millisecond part in the if-unmodified-since } public static void addDateHeaderIfRequired(HttpServerExchange exchange) { HeaderMap responseHeaders = exchange.getResponseHeaders(); - if(exchange.getConnection().getUndertowOptions().get(UndertowOptions.ALWAYS_SET_DATE, true) && !responseHeaders.contains(Headers.DATE)) { - long time = System.nanoTime(); - if(time < nextUpdateTime) { - responseHeaders.put(Headers.DATE, cachedDateString); + if (exchange.getConnection().getUndertowOptions().get(UndertowOptions.ALWAYS_SET_DATE, true) && !responseHeaders.contains(Headers.DATE)) { + String dateString = cachedDateString.get(); + if (dateString != null) { + responseHeaders.put(Headers.DATE, dateString); } else { + //set the time and register a timer to invalidate it + //note that this is racey, it does not matter if multiple threads do this + //the perf cost of synchronizing would be more than the perf cost of multiple threads running it long realTime = System.currentTimeMillis(); - String dateString = DateUtils.toDateString(new Date(realTime)); - cachedDateString = dateString; - nextUpdateTime = time + 1000000000; + long mod = realTime % 1000; + long toGo = 1000 - mod; + dateString = DateUtils.toDateString(new Date(realTime)); + if (cachedDateString.compareAndSet(null, dateString)) { + exchange.getConnection().getIoThread().executeAfter(INVALIDATE_TASK, toGo, TimeUnit.MILLISECONDS); + } responseHeaders.put(Headers.DATE, dateString); } } @@ -254,4 +249,5 @@ private DateUtils() { } + } Index: 3rdParty_sources/undertow/io/undertow/util/ETag.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/ETag.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/ETag.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/ETag.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; /** Index: 3rdParty_sources/undertow/io/undertow/util/ETagUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/ETagUtils.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/ETagUtils.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/ETagUtils.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import java.util.ArrayList; @@ -153,7 +171,7 @@ char[] headerChars = header.toCharArray(); // The LinkedHashMap is used so that the parameter order can also be retained. - List response = new ArrayList(); + List response = new ArrayList<>(); SearchingFor searchingFor = SearchingFor.START_OF_VALUE; String currentToken = null; @@ -164,7 +182,7 @@ for (int i = 0; i < headerChars.length; i++) { switch (searchingFor) { case START_OF_VALUE: - if (headerChars[i] != COMMA && Character.isWhitespace(headerChars[i]) == false) { + if (headerChars[i] != COMMA && !Character.isWhitespace(headerChars[i])) { if (headerChars[i] == QUOTE) { valueStart = i + 1; searchingFor = SearchingFor.LAST_QUOTE; @@ -233,7 +251,7 @@ for (int i = 0; i < headerChars.length; i++) { switch (searchingFor) { case START_OF_VALUE: - if (headerChars[i] != COMMA && Character.isWhitespace(headerChars[i]) == false) { + if (headerChars[i] != COMMA && !Character.isWhitespace(headerChars[i])) { if (headerChars[i] == QUOTE) { valueStart = i + 1; searchingFor = SearchingFor.LAST_QUOTE; Index: 3rdParty_sources/undertow/io/undertow/util/FastConcurrentDirectDeque.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/FastConcurrentDirectDeque.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/FastConcurrentDirectDeque.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/FastConcurrentDirectDeque.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /* @@ -348,7 +348,7 @@ */ private Node linkFirst(E e) { checkNotNull(e); - final Node newNode = new Node(e); + final Node newNode = new Node<>(e); restartFromHead: for (;;) @@ -381,7 +381,7 @@ */ private Node linkLast(E e) { checkNotNull(e); - final Node newNode = new Node(e); + final Node newNode = new Node<>(e); restartFromTail: for (;;) @@ -815,7 +815,7 @@ * @return the arrayList */ private ArrayList toArrayList() { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); for (Node p = first(); p != null; p = succ(p)) { E item = p.item; if (item != null) @@ -828,7 +828,7 @@ * Constructs an empty deque. */ public FastConcurrentDirectDeque() { - head = tail = new Node(null); + head = tail = new Node<>(null); } /** @@ -845,7 +845,7 @@ Node h = null, t = null; for (E e : c) { checkNotNull(e); - Node newNode = new Node(e); + Node newNode = new Node<>(e); if (h == null) h = t = newNode; else { @@ -863,10 +863,10 @@ private void initHeadTail(Node h, Node t) { if (h == t) { if (h == null) - h = t = new Node(null); + h = t = new Node<>(null); else { // Avoid edge case of a single Node with non-null item. - Node newNode = new Node(null); + Node newNode = new Node<>(null); t.lazySetNext(newNode); newNode.lazySetPrev(t); t = newNode; @@ -1172,7 +1172,7 @@ Node beginningOfTheEnd = null, last = null; for (E e : c) { checkNotNull(e); - Node newNode = new Node(e); + Node newNode = new Node<>(e); if (beginningOfTheEnd == null) beginningOfTheEnd = last = newNode; else { @@ -1433,7 +1433,7 @@ Object item; while ((item = s.readObject()) != null) { @SuppressWarnings("unchecked") - Node newNode = new Node((E) item); + Node newNode = new Node<>((E) item); if (h == null) h = t = newNode; else { @@ -1459,9 +1459,9 @@ private static final long headOffset; private static final long tailOffset; static { - PREV_TERMINATOR = new Node(); + PREV_TERMINATOR = new Node<>(); PREV_TERMINATOR.next = PREV_TERMINATOR; - NEXT_TERMINATOR = new Node(); + NEXT_TERMINATOR = new Node<>(); NEXT_TERMINATOR.prev = NEXT_TERMINATOR; try { UNSAFE = getUnsafe(); Index: 3rdParty_sources/undertow/io/undertow/util/FileUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/FileUtils.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/FileUtils.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/FileUtils.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/FlexBase64.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/FlexBase64.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/FlexBase64.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/FlexBase64.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/HeaderMap.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/HeaderMap.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/HeaderMap.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/HeaderMap.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/HeaderToken.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/HeaderToken.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/HeaderToken.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/HeaderToken.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/HeaderTokenParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/HeaderTokenParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/HeaderTokenParser.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/HeaderTokenParser.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -43,18 +43,19 @@ char[] headerChars = header.toCharArray(); // The LinkedHashMap is used so that the parameter order can also be retained. - Map response = new LinkedHashMap(); + Map response = new LinkedHashMap<>(); SearchingFor searchingFor = SearchingFor.START_OF_NAME; int nameStart = 0; E currentToken = null; int valueStart = 0; + boolean containsEscapes = false; for (int i = 0; i < headerChars.length; i++) { switch (searchingFor) { case START_OF_NAME: // Eliminate any white space before the name of the parameter. - if (headerChars[i] != COMMA && Character.isWhitespace(headerChars[i]) == false) { + if (headerChars[i] != COMMA && !Character.isWhitespace(headerChars[i])) { nameStart = i; searchingFor = SearchingFor.EQUALS_SIGN; } @@ -70,7 +71,7 @@ } break; case START_OF_VALUE: - if (Character.isWhitespace(headerChars[i]) == false) { + if (!Character.isWhitespace(headerChars[i])) { if (headerChars[i] == QUOTE && currentToken.isAllowQuoted()) { valueStart = i + 1; searchingFor = SearchingFor.LAST_QUOTE; @@ -81,11 +82,28 @@ } break; case LAST_QUOTE: - if (headerChars[i] == QUOTE) { + boolean backslash = headerChars[i - 1] != '\\'; + if (headerChars[i] == QUOTE && backslash) { String value = String.valueOf(headerChars, valueStart, i - valueStart); + if(containsEscapes) { + StringBuilder sb = new StringBuilder(); + boolean lastEscape = false; + for(int j = 0; j < value.length(); ++j) { + char c = value.charAt(j); + if(c == '\\' && !lastEscape) { + lastEscape = true; + } else { + lastEscape = false; + sb.append(c); + } + } + value = sb.toString(); + } response.put(currentToken, value); searchingFor = SearchingFor.START_OF_NAME; + } else if(backslash) { + containsEscapes = true; } break; case END_OF_VALUE: Index: 3rdParty_sources/undertow/io/undertow/util/HeaderValues.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/HeaderValues.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/HeaderValues.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/HeaderValues.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -37,7 +37,7 @@ private static final String[] NO_STRINGS = new String[0]; final HttpString key; - byte head, size; + byte size; Object value; HeaderValues(final HttpString key) { @@ -63,28 +63,20 @@ } private void clearInternal(byte size) { - final byte head = this.head; final Object value = this.value; if (value instanceof String[]) { final String[] strings = (String[]) value; final int len = strings.length; - final int tail = head + size; - if (tail > len) { - Arrays.fill(strings, head, len, null); - Arrays.fill(strings, 0, tail - len, null); - } else { - Arrays.fill(strings, head, tail, null); - } + Arrays.fill(strings, 0, len, null); } else { this.value = null; } - this.head = this.size = 0; + this.size = 0; } private int index(int idx) { assert idx >= 0; assert idx < size; - idx += head; final int len = ((String[]) value).length; if (idx > len) { idx -= len; @@ -203,19 +195,14 @@ if (value instanceof String[]) { final String[] strings = (String[]) value; final int len = strings.length; - final byte head = this.head; if (size == len) { - final String[] newStrings = Arrays.copyOfRange(strings, head, head + len + (len << 1)); - final int end = head + size; - if (end > len) { - System.arraycopy(strings, 0, newStrings, len - head, end - len); - } - newStrings[this.head = (byte) (head - 1)] = headerValue; + final String[] newStrings = new String[len + 2]; + System.arraycopy(strings, 0, newStrings, 1, len); + newStrings[0] = headerValue; this.value = newStrings; - } else if (head == 0) { - strings[this.head = (byte) (len - 1)] = headerValue; } else { - strings[this.head = (byte) (head - 1)] = headerValue; + System.arraycopy(strings, 0, strings, 1, strings.length - 1); + strings[0] = headerValue; } this.size = (byte) (size + 1); } else { @@ -226,7 +213,6 @@ this.value = new String[] { headerValue, (String) value, null, null }; this.size = (byte) 2; } - this.head = 0; } return true; } @@ -245,27 +231,20 @@ this.value = new String[] { (String) value, headerValue, null, null }; this.size = (byte) 2; } - this.head = 0; } return true; } private void offerLastMultiValue(String headerValue, int size, String[] value) { - final String[] strings = (String[]) value; + final String[] strings = value; final int len = strings.length; - final byte head = this.head; - final int end = head + size; if (size == len) { - final String[] newStrings = Arrays.copyOfRange(strings, head, head + len + (len << 1)); - if (end > len) { - System.arraycopy(strings, 0, newStrings, len - head, end - len); - } + final String[] newStrings = new String[len + 2]; + System.arraycopy(strings, 0, newStrings, 0, len); newStrings[len] = headerValue; this.value = newStrings; - } else if (end >= len) { - strings[end - len] = headerValue; } else { - strings[end] = headerValue; + strings[size] = headerValue; } this.size = (byte) (size + 1); } @@ -280,59 +259,22 @@ assert value instanceof String[]; final String[] strings = (String[]) value; final int len = strings.length; - final byte head = this.head; - final int end = head + size; - final int headIdx = head + idx; // This stuff is all algebraically derived. if (size == len) { // Grow the list, copy each segment into new spots so that head = 0 - final int newLen = (len << 1) + len; + final int newLen = len + 2; final String[] newStrings = new String[newLen]; - if (head == 0) { - assert headIdx == len; - assert end == len; - System.arraycopy(value, 0, newStrings, 0, idx); - System.arraycopy(value, idx, newStrings, idx + 1, len - idx); - } else if (headIdx < len) { - System.arraycopy(value, head, newStrings, 0, idx); - System.arraycopy(value, headIdx, newStrings, idx + 1, len - headIdx); - System.arraycopy(value, 0, newStrings, len - head + 1, head); - } else if (headIdx > len) { - System.arraycopy(value, 0, newStrings, len - head, headIdx - len); - System.arraycopy(value, headIdx - len, newStrings, idx + 1, len - idx + 1); - System.arraycopy(value, head, newStrings, 0, len - head); - } + System.arraycopy(value, 0, newStrings, 0, idx); + System.arraycopy(value, idx, newStrings, idx + 1, len - idx); + // finally fill in the new value newStrings[idx] = headerValue; this.value = newStrings; - this.head = 0; - } else if (end > len) { - if (headIdx < len) { - System.arraycopy(value, head, value, head - 1, idx); - strings[headIdx - 1] = headerValue; - this.head = (byte) (head - 1); - } else if (headIdx > len) { - System.arraycopy(value, headIdx - len, value, headIdx - len + 1, size - idx); - strings[headIdx - len] = headerValue; - } else { - assert headIdx == len; - System.arraycopy(value, 0, value, 1, end - len); - strings[0] = headerValue; - } + } else{ + System.arraycopy(value, idx, value, idx + 1, len - idx); + + // finally fill in the new value strings[idx] = headerValue; - } else { - assert size < len && end <= len; - if (head == 0 || idx >= size >> 1) { - assert end < len; - System.arraycopy(value, headIdx, value, headIdx + 1, size - idx); - strings[headIdx] = headerValue; - } else { - assert end <= len || idx < size << 1; - assert head > 0; - System.arraycopy(value, headIdx, value, headIdx - 1, size - idx); - strings[headIdx - 1] = headerValue; - this.head = (byte) (head - 1); - } } this.size = (byte) (size + 1); return true; @@ -349,15 +291,10 @@ return (String) value; } else { final String[] strings = (String[]) value; - int idx = head++; + String ret = strings[0]; + System.arraycopy(strings, 1, strings, 0, strings.length - 1); this.size = (byte) (size - 1); - final int len = strings.length; - if (idx > len) idx -= len; - try { - return strings[idx]; - } finally { - strings[idx] = null; - } + return ret; } } @@ -372,7 +309,7 @@ return (String) value; } else { final String[] strings = (String[]) value; - int idx = head + (this.size = (byte) (size - 1)); + int idx = (this.size = (byte) (size - 1)); final int len = strings.length; if (idx > len) idx -= len; try { @@ -392,33 +329,11 @@ // value must be an array since size > 2 final String[] value = (String[]) this.value; final int len = value.length; - final byte head = this.head; - final int headIdx = idx + head; - final int end = head + size; - if (end > len) { - if (headIdx > len) { - try { - return value[headIdx - len]; - } finally { - System.arraycopy(value, headIdx + 1 - len, value, headIdx - len, size - idx - 1); - this.size = (byte) (size - 1); - } - } else { - try { - return value[headIdx]; - } finally { - System.arraycopy(value, head, value, head + 1, idx); - this.size = (byte) (size - 1); - } - } - } else { - try { - return value[headIdx]; - } finally { - System.arraycopy(value, headIdx + 1, value, headIdx, size - idx - 1); - this.size = (byte) (size - 1); - } - } + String ret = value[idx]; + System.arraycopy(value, idx + 1, value, idx, len - idx - 1); + value[len - 1] = null; + this.size = (byte) (size - 1); + return ret; } public String get(int idx) { @@ -440,10 +355,8 @@ if (value instanceof String[]) { final String[] list = (String[]) value; final int len = list.length; - int idx; for (int i = 0; i < size; i ++) { - idx = i + head; - if ((idx > len ? list[idx - len] : list[idx]).equals(o)) { + if ((i > len ? list[i - len] : list[i]).equals(o)) { return i; } } @@ -460,7 +373,7 @@ final int len = list.length; int idx; for (int i = size - 1; i >= 0; i --) { - idx = i + head; + idx = i; if ((idx > len ? list[idx - len] : list[idx]).equals(o)) { return i; } @@ -519,14 +432,13 @@ final Object v = this.value; if (v instanceof String) return new String[] { (String) v }; final String[] list = (String[]) v; - final int head = this.head; final int len = list.length; - final int copyEnd = head + size; + final int copyEnd = size; if (copyEnd < len) { - return Arrays.copyOfRange(list, head, copyEnd); + return Arrays.copyOfRange(list, 0, copyEnd); } else { - String[] ret = Arrays.copyOfRange(list, head, copyEnd); - System.arraycopy(list, 0, ret, len - head, copyEnd - len); + String[] ret = Arrays.copyOfRange(list, 0, copyEnd); + System.arraycopy(list, 0, ret, len, copyEnd - len); return ret; } } @@ -540,17 +452,7 @@ if (v instanceof String) { target[0] = (T)v; } else { - final String[] list = (String[]) v; - final int head = this.head; - final int len = list.length; - final int copyEnd = head + size; - if (copyEnd < len) { - System.arraycopy(list, head, target, 0, size); - } else { - final int wrapEnd = len - head; - System.arraycopy(list, head, target, 0, wrapEnd); - System.arraycopy(list, 0, target, wrapEnd, copyEnd - len); - } + System.arraycopy(v, 0, target, 0, size); } return (T[]) target; } @@ -668,6 +570,10 @@ } public boolean addAll(final Collection c) { - return addAll(0, c); + Iterator it = c.iterator(); + while (it.hasNext()) { + add(it.next()); + } + return !c.isEmpty(); } } Index: 3rdParty_sources/undertow/io/undertow/util/Headers.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/Headers.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/Headers.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/Headers.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -103,6 +103,8 @@ public static final String WWW_AUTHENTICATE_STRING = "WWW-Authenticate"; public static final String X_FORWARDED_FOR_STRING = "X-Forwarded-For"; public static final String X_FORWARDED_PROTO_STRING = "X-Forwarded-Proto"; + public static final String X_FORWARDED_HOST_STRING = "X-Forwarded-Host"; + public static final String X_FORWARDED_PORT_STRING = "X-Forwarded-Port"; // Header names @@ -122,7 +124,7 @@ public static final HttpString CONTENT_LANGUAGE = new HttpString(CONTENT_LANGUAGE_STRING, 14); public static final HttpString CONTENT_LENGTH = new HttpString(CONTENT_LENGTH_STRING, 15); public static final HttpString CONTENT_LOCATION = new HttpString(CONTENT_LOCATION_STRING, 16); - public static final HttpString CONTENT_MD5 = new HttpString(CONTENT_MD5_STRING,17); + public static final HttpString CONTENT_MD5 = new HttpString(CONTENT_MD5_STRING, 17); public static final HttpString CONTENT_RANGE = new HttpString(CONTENT_RANGE_STRING, 18); public static final HttpString CONTENT_TYPE = new HttpString(CONTENT_TYPE_STRING, 19); public static final HttpString COOKIE = new HttpString(COOKIE_STRING, 20); @@ -178,7 +180,9 @@ public static final HttpString WARNING = new HttpString(WARNING_STRING, 65); public static final HttpString WWW_AUTHENTICATE = new HttpString(WWW_AUTHENTICATE_STRING, 66); public static final HttpString X_FORWARDED_FOR = new HttpString(X_FORWARDED_FOR_STRING, 67); - public static final HttpString X_FORWARDED_PROTO = new HttpString(X_FORWARDED_PROTO_STRING, 68); + public static final HttpString X_FORWARDED_HOST = new HttpString(X_FORWARDED_HOST_STRING, 68); + public static final HttpString X_FORWARDED_PORT = new HttpString(X_FORWARDED_PORT_STRING, 69); + public static final HttpString X_FORWARDED_PROTO = new HttpString(X_FORWARDED_PROTO_STRING, 70); // Content codings @@ -228,7 +232,6 @@ public static final HttpString USERNAME = new HttpString("username"); - /** * Extracts a token from a header that has a given key. For instance if the header is *

    @@ -266,13 +269,43 @@ * @return The token, or null if it was not found */ public static String extractQuotedValueFromHeader(final String header, final String key) { - int pos = header.indexOf(key + '='); + + int keypos = 0; + int pos = -1; + boolean inQuotes = false; + for (int i = 0; i < header.length() - 1; ++i) { //-1 because we need room for the = at the end + //TODO: a more efficient matching algorithm + char c = header.charAt(i); + if (inQuotes) { + if (c == '"') { + inQuotes = false; + } + } else { + if (key.charAt(keypos) == c) { + keypos++; + } else if (c == '"') { + keypos = 0; + inQuotes = true; + } else { + keypos = 0; + } + if (keypos == key.length()) { + if (header.charAt(i + 1) == '=') { + pos = i + 2; + break; + } else { + keypos = 0; + } + } + } + + } if (pos == -1) { return null; } int end; - int start = pos + key.length() + 1; + int start = pos; if (header.charAt(start) == '"') { start++; for (end = start; end < header.length(); ++end) { Index: 3rdParty_sources/undertow/io/undertow/util/HexConverter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/HexConverter.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/HexConverter.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/HexConverter.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2011 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -135,7 +135,7 @@ byte[] convertedBack = convertFromHex(hexValue); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (byte current : convertedBack) { sb.append((int)current).append(" "); } Index: 3rdParty_sources/undertow/io/undertow/util/HttpString.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/HttpString.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/HttpString.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/HttpString.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -79,7 +79,7 @@ * @param length the number of bytes to copy */ public HttpString(final byte[] bytes, int offset, int length) { - this(copyOfRange(bytes, offset, length), null); + this(copyOfRange(bytes, offset, offset + length), null); } /** Index: 3rdParty_sources/undertow/io/undertow/util/ImmediateAuthenticationMechanismFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/ImmediateAuthenticationMechanismFactory.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/ImmediateAuthenticationMechanismFactory.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/ImmediateAuthenticationMechanismFactory.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import io.undertow.security.api.AuthenticationMechanism; Index: 3rdParty_sources/undertow/io/undertow/util/ImmediateConduitFactory.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/ImmediateConduitFactory.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/ImmediateConduitFactory.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/ImmediateConduitFactory.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import org.xnio.conduits.Conduit; Index: 3rdParty_sources/undertow/io/undertow/util/ImmediatePooled.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/ImmediatePooled.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/ImmediatePooled.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/ImmediatePooled.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import org.xnio.Pooled; @@ -27,4 +45,8 @@ public T getResource() throws IllegalStateException { return value; } + + @Override + public void close() { + } } Index: 3rdParty_sources/undertow/io/undertow/util/LocaleUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/LocaleUtils.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/LocaleUtils.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/LocaleUtils.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -24,6 +24,8 @@ import java.util.Locale; /** + * Utility methods for getting the locale from a request. + * * @author Stuart Douglas */ public class LocaleUtils { @@ -42,15 +44,34 @@ } } + /** + * Parse a header string and return the list of locales that were found. + * + * If the header is empty or null then an empty list will be returned. + * + * @param acceptLanguage The Accept-Language header + * @return The list of locales, in order of preference + */ public static List getLocalesFromHeader(final String acceptLanguage) { + if(acceptLanguage == null) { + return Collections.emptyList(); + } return getLocalesFromHeader(Collections.singletonList(acceptLanguage)); } + /** + * Parse a header string and return the list of locales that were found. + * + * If the header is empty or null then an empty list will be returned. + * + * @param acceptLanguage The Accept-Language header + * @return The list of locales, in order of preference + */ public static List getLocalesFromHeader(final List acceptLanguage) { if (acceptLanguage == null || acceptLanguage.isEmpty()) { - return Collections.singletonList(Locale.getDefault()); + return Collections.emptyList(); } - final List ret = new ArrayList(); + final List ret = new ArrayList<>(); final List> parsedResults = QValueParser.parse(acceptLanguage); for (List qvalueResult : parsedResults) { for (QValueParser.QValueResult res : qvalueResult) { Index: 3rdParty_sources/undertow/io/undertow/util/MalformedMessageException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/MalformedMessageException.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/MalformedMessageException.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/MalformedMessageException.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/util/Methods.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/Methods.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/Methods.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/Methods.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/MimeMappings.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/MimeMappings.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/MimeMappings.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/MimeMappings.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -34,7 +34,7 @@ public static final Map DEFAULT_MIME_MAPPINGS; static { - Map defaultMappings = new HashMap(101); + Map defaultMappings = new HashMap<>(101); defaultMappings.put("txt", "text/plain"); defaultMappings.put("css", "text/css"); defaultMappings.put("html", "text/html"); @@ -50,6 +50,7 @@ defaultMappings.put("rtx", "text/richtext"); defaultMappings.put("tsv", "text/tab-separated-values"); defaultMappings.put("etx", "text/x-setext"); + defaultMappings.put("json", "application/json"); defaultMappings.put("ps", "application/x-postscript"); defaultMappings.put("class", "application/java"); defaultMappings.put("csh", "application/x-csh"); @@ -111,6 +112,7 @@ defaultMappings.put("aiff", "audio/x-aiff"); defaultMappings.put("aifc", "audio/x-aiff"); defaultMappings.put("wav", "audio/x-wav"); + defaultMappings.put("mp3", "audio/mpeg"); defaultMappings.put("mpeg", "video/mpeg"); defaultMappings.put("mpg", "video/mpeg"); defaultMappings.put("mpe", "video/mpeg"); @@ -153,7 +155,7 @@ } public static class Builder { - private final Map mappings = new HashMap(); + private final Map mappings = new HashMap<>(); private Builder(boolean includeDefault) { Index: 3rdParty_sources/undertow/io/undertow/util/MultipartParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/MultipartParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/MultipartParser.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/MultipartParser.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/NetworkUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/NetworkUtils.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/NetworkUtils.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/NetworkUtils.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; /** Index: 3rdParty_sources/undertow/io/undertow/util/PathMatcher.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/PathMatcher.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/PathMatcher.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/PathMatcher.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -43,8 +43,8 @@ private static final String STRING_PATH_SEPARATOR = "/"; private volatile T defaultHandler; - private final ConcurrentMap paths = new CopyOnWriteMap(); - private final ConcurrentMap exactPathMatches = new CopyOnWriteMap(); + private final ConcurrentMap paths = new CopyOnWriteMap<>(); + private final ConcurrentMap exactPathMatches = new CopyOnWriteMap<>(); /** * lengths of all registered paths @@ -67,7 +67,7 @@ if (!exactPathMatches.isEmpty()) { T match = getExactPath(path); if (match != null) { - return new PathMatch("", match); + return new PathMatch<>("", match); } } @@ -78,20 +78,20 @@ if (pathLength == length) { T next = paths.get(path); if (next != null) { - return new PathMatch(path.substring(pathLength), next); + return new PathMatch<>(path.substring(pathLength), next); } } else if (pathLength < length) { char c = path.charAt(pathLength); if (c == '/') { String part = path.substring(0, pathLength); T next = paths.get(part); if (next != null) { - return new PathMatch(path.substring(pathLength), next); + return new PathMatch<>(path.substring(pathLength), next); } } } } - return new PathMatch(path, defaultHandler); + return new PathMatch<>(path, defaultHandler); } /** @@ -151,7 +151,7 @@ } private void buildLengths() { - final Set lengths = new TreeSet(new Comparator() { + final Set lengths = new TreeSet<>(new Comparator() { @Override public int compare(Integer o1, Integer o2) { return -o1.compareTo(o2); Index: 3rdParty_sources/undertow/io/undertow/util/PathTemplate.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/PathTemplate.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/PathTemplate.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/PathTemplate.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -78,7 +78,7 @@ int state = 0; String base = ""; - List parts = new ArrayList(); + List parts = new ArrayList<>(); int stringStart = 0; //0 parsing base //1 parsing base, last char was / @@ -162,7 +162,7 @@ break; } } - final Set templates = new HashSet(); + final Set templates = new HashSet<>(); for(Part part : parts) { if(part.template) { templates.add(part.part); Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/util/PathTemplateMatch.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/util/PathTemplateMatcher.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/PathTemplateMatcher.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/PathTemplateMatcher.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/PathTemplateMatcher.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,11 +1,31 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import io.undertow.UndertowMessages; import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.TreeSet; @@ -22,15 +42,15 @@ /** * Map of path template stem to the path templates that share the same base. */ - private Map> pathTemplateMap = new CopyOnWriteMap>(); + private Map> pathTemplateMap = new CopyOnWriteMap<>(); /** * lengths of all registered paths */ private volatile int[] lengths = {}; public PathMatchResult match(final String path) { - final Map params = new HashMap(); + final Map params = new HashMap<>(); int length = path.length(); final int[] lengths = this.lengths; for (int i = 0; i < lengths.length; ++i) { @@ -63,7 +83,7 @@ private PathMatchResult handleStemMatch(Set entry, final String path, final Map params) { for (PathTemplateHolder val : entry) { if (val.template.matches(path, params)) { - return new PathMatchResult(params, val.template.getTemplateString(), val.value); + return new PathMatchResult<>(params, val.template.getTemplateString(), val.value); } else { params.clear(); } @@ -76,9 +96,9 @@ Set values = pathTemplateMap.get(trimBase(template)); Set newValues; if (values == null) { - newValues = new TreeSet(); + newValues = new TreeSet<>(); } else { - newValues = new TreeSet(values); + newValues = new TreeSet<>(values); } PathTemplateHolder holder = new PathTemplateHolder(value, template); if (newValues.contains(holder)) { @@ -105,7 +125,7 @@ } private void buildLengths() { - final Set lengths = new TreeSet(new Comparator() { + final Set lengths = new TreeSet<>(new Comparator() { @Override public int compare(Integer o1, Integer o2) { return -o1.compareTo(o2); @@ -128,6 +148,29 @@ return add(template, value); } + public synchronized PathTemplateMatcher addAll(PathTemplateMatcher pathTemplateMatcher) { + for (Entry> entry : pathTemplateMatcher.getPathTemplateMap().entrySet()) { + for (PathTemplateHolder pathTemplateHolder : entry.getValue()) { + add(pathTemplateHolder.template, pathTemplateHolder.value); + } + } + return this; + } + + Map> getPathTemplateMap() { + return pathTemplateMap; + } + + public Set getPathTemplates() { + Set templates = new HashSet<>(); + for (Set holders : pathTemplateMap.values()) { + for (PathTemplateHolder holder: holders) { + templates.add(holder.template); + } + } + return templates; + } + public synchronized PathTemplateMatcher remove(final String pathTemplate) { final PathTemplate template = PathTemplate.create(pathTemplate); return remove(template); @@ -137,9 +180,9 @@ Set values = pathTemplateMap.get(trimBase(template)); Set newValues; if (values == null) { - newValues = new TreeSet(); + return this; } else { - newValues = new TreeSet(values); + newValues = new TreeSet<>(values); } Iterator it = newValues.iterator(); while (it.hasNext()) { @@ -158,25 +201,29 @@ return this; } - public static class PathMatchResult { - private final Map parameters; - private final String matchedTemplate; + + public synchronized T get(String template) { + PathTemplate pathTemplate = PathTemplate.create(template); + Set values = pathTemplateMap.get(trimBase(pathTemplate)); + if(values == null) { + return null; + } + for (PathTemplateHolder next : values) { + if (next.template.getTemplateString().equals(template)) { + return next.value; + } + } + return null; + } + + public static class PathMatchResult extends PathTemplateMatch { private final T value; public PathMatchResult(Map parameters, String matchedTemplate, T value) { - this.parameters = parameters; - this.matchedTemplate = matchedTemplate; + super(matchedTemplate, parameters); this.value = value; } - public Map getParameters() { - return parameters; - } - - public String getMatchedTemplate() { - return matchedTemplate; - } - public T getValue() { return value; } Index: 3rdParty_sources/undertow/io/undertow/util/PipeliningExecutor.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/PipeliningExecutor.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/PipeliningExecutor.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/PipeliningExecutor.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import io.undertow.UndertowLogger; @@ -15,7 +33,7 @@ private final Executor executor; - private static final ThreadLocal> THREAD_QUEUE = new ThreadLocal>(); + private static final ThreadLocal> THREAD_QUEUE = new ThreadLocal<>(); public PipeliningExecutor(Executor executor) { this.executor = executor; @@ -32,7 +50,7 @@ public void run() { LinkedList queue = THREAD_QUEUE.get(); if (queue == null) { - THREAD_QUEUE.set(queue = new LinkedList()); + THREAD_QUEUE.set(queue = new LinkedList<>()); } try { command.run(); Index: 3rdParty_sources/undertow/io/undertow/util/PortableConcurrentDirectDeque.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/PortableConcurrentDirectDeque.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/PortableConcurrentDirectDeque.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/PortableConcurrentDirectDeque.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ /* @@ -331,7 +331,7 @@ */ private Node linkFirst(E e) { checkNotNull(e); - final Node newNode = new Node(e); + final Node newNode = new Node<>(e); restartFromHead: for (;;) @@ -364,7 +364,7 @@ */ private Node linkLast(E e) { checkNotNull(e); - final Node newNode = new Node(e); + final Node newNode = new Node<>(e); restartFromTail: for (;;) @@ -798,7 +798,7 @@ * @return the arrayList */ private ArrayList toArrayList() { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); for (Node p = first(); p != null; p = succ(p)) { E item = p.item; if (item != null) @@ -811,7 +811,7 @@ * Constructs an empty deque. */ public PortableConcurrentDirectDeque() { - head = tail = new Node(null); + head = tail = new Node<>(null); } /** @@ -828,7 +828,7 @@ Node h = null, t = null; for (E e : c) { checkNotNull(e); - Node newNode = new Node(e); + Node newNode = new Node<>(e); if (h == null) h = t = newNode; else { @@ -846,10 +846,10 @@ private void initHeadTail(Node h, Node t) { if (h == t) { if (h == null) - h = t = new Node(null); + h = t = new Node<>(null); else { // Avoid edge case of a single Node with non-null item. - Node newNode = new Node(null); + Node newNode = new Node<>(null); t.lazySetNext(newNode); newNode.lazySetPrev(t); t = newNode; @@ -1155,7 +1155,7 @@ Node beginningOfTheEnd = null, last = null; for (E e : c) { checkNotNull(e); - Node newNode = new Node(e); + Node newNode = new Node<>(e); if (beginningOfTheEnd == null) beginningOfTheEnd = last = newNode; else { @@ -1416,7 +1416,7 @@ Object item; while ((item = s.readObject()) != null) { @SuppressWarnings("unchecked") - Node newNode = new Node((E) item); + Node newNode = new Node<>((E) item); if (h == null) h = t = newNode; else { @@ -1439,9 +1439,9 @@ // Unsafe mechanics static { - PREV_TERMINATOR = new Node(); + PREV_TERMINATOR = new Node<>(); PREV_TERMINATOR.next = PREV_TERMINATOR; - NEXT_TERMINATOR = new Node(); + NEXT_TERMINATOR = new Node<>(); NEXT_TERMINATOR.prev = NEXT_TERMINATOR; } } Index: 3rdParty_sources/undertow/io/undertow/util/Protocols.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/Protocols.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/Protocols.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/Protocols.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/QValueParser.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/QValueParser.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/QValueParser.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/QValueParser.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -45,7 +45,7 @@ * @return The q value results */ public static List> parse(List headers) { - final List found = new ArrayList(); + final List found = new ArrayList<>(); QValueResult current = null; for (final String header : headers) { final int l = header.length(); @@ -104,13 +104,13 @@ } Collections.sort(found, Collections.reverseOrder()); String currentQValue = null; - List> values = new ArrayList>(); + List> values = new ArrayList<>(); List currentSet = null; for(QValueResult val : found) { if(!val.qvalue.equals(currentQValue)) { currentQValue = val.qvalue; - currentSet = new ArrayList(); + currentSet = new ArrayList<>(); values.add(currentSet); } currentSet.add(val); Index: 3rdParty_sources/undertow/io/undertow/util/QueryParameterUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/QueryParameterUtils.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/QueryParameterUtils.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/QueryParameterUtils.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,10 +1,34 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; import java.util.ArrayDeque; import java.util.Deque; import java.util.LinkedHashMap; import java.util.Map; +import org.xnio.OptionMap; +import io.undertow.UndertowOptions; +import io.undertow.server.HttpServerExchange; + /** * Methods for dealing with the query string * @@ -49,57 +73,98 @@ * @param newQueryString The query string * @return The map of key value parameters */ + @Deprecated public static Map> parseQueryString(final String newQueryString) { - Map> newQueryParameters = new LinkedHashMap>(); + return parseQueryString(newQueryString, null); + } + + /** + * Parses a query string into a map + * @param newQueryString The query string + * @return The map of key value parameters + */ + public static Map> parseQueryString(final String newQueryString, final String encoding) { + Map> newQueryParameters = new LinkedHashMap<>(); int startPos = 0; int equalPos = -1; + boolean needsDecode = false; for(int i = 0; i < newQueryString.length(); ++i) { char c = newQueryString.charAt(i); if(c == '=' && equalPos == -1) { equalPos = i; } else if(c == '&') { - handleQueryParameter(newQueryString, newQueryParameters, startPos, equalPos, i); + handleQueryParameter(newQueryString, newQueryParameters, startPos, equalPos, i, encoding, needsDecode); + needsDecode = false; startPos = i + 1; equalPos = -1; + } else if((c == '%' || c == '+') && encoding != null) { + needsDecode = true; } } if(startPos != newQueryString.length()) { - handleQueryParameter(newQueryString, newQueryParameters, startPos, equalPos, newQueryString.length()); + handleQueryParameter(newQueryString, newQueryParameters, startPos, equalPos, newQueryString.length(), encoding, needsDecode); } return newQueryParameters; } - private static void handleQueryParameter(String newQueryString, Map> newQueryParameters, int startPos, int equalPos, int i) { + private static void handleQueryParameter(String newQueryString, Map> newQueryParameters, int startPos, int equalPos, int i, final String encoding, boolean needsDecode) { String key; String value = ""; if(equalPos == -1) { - key = newQueryString.substring(startPos, i); + key = decodeParam(newQueryString, startPos, i, encoding, needsDecode); } else { - key = newQueryString.substring(startPos, equalPos); - value = newQueryString.substring(equalPos + 1, i); + key = decodeParam(newQueryString, startPos, equalPos, encoding, needsDecode); + value = decodeParam(newQueryString, equalPos + 1, i, encoding, needsDecode); } Deque queue = newQueryParameters.get(key); if (queue == null) { - newQueryParameters.put(key, queue = new ArrayDeque(1)); + newQueryParameters.put(key, queue = new ArrayDeque<>(1)); } if(value != null) { queue.add(value); } } + private static String decodeParam(String newQueryString, int startPos, int equalPos, String encoding, boolean needsDecode) { + String key; + if (needsDecode) { + try { + key = URLDecoder.decode(newQueryString.substring(startPos, equalPos), encoding); + } catch (UnsupportedEncodingException e) { + key = newQueryString.substring(startPos, equalPos); + } + } else { + key = newQueryString.substring(startPos, equalPos); + } + return key; + } + @Deprecated public static Map> mergeQueryParametersWithNewQueryString(final Map> queryParameters, final String newQueryString) { + return mergeQueryParametersWithNewQueryString(queryParameters, newQueryString, "UTF-8"); + } - Map> newQueryParameters = parseQueryString(newQueryString); + public static Map> mergeQueryParametersWithNewQueryString(final Map> queryParameters, final String newQueryString, final String encoding) { + + Map> newQueryParameters = parseQueryString(newQueryString, encoding); //according to the spec the new query parameters have to 'take precedence' for (Map.Entry> entry : queryParameters.entrySet()) { if (!newQueryParameters.containsKey(entry.getKey())) { - newQueryParameters.put(entry.getKey(), new ArrayDeque(entry.getValue())); + newQueryParameters.put(entry.getKey(), new ArrayDeque<>(entry.getValue())); } else { newQueryParameters.get(entry.getKey()).addAll(entry.getValue()); } } return newQueryParameters; } + + public static String getQueryParamEncoding(HttpServerExchange exchange) { + String encoding = null; + OptionMap undertowOptions = exchange.getConnection().getUndertowOptions(); + if(undertowOptions.get(UndertowOptions.DECODE_URL, true)) { + encoding = undertowOptions.get(UndertowOptions.URL_CHARSET, "UTF-8"); + } + return encoding; + } } Index: 3rdParty_sources/undertow/io/undertow/util/RedirectBuilder.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/RedirectBuilder.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/RedirectBuilder.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/RedirectBuilder.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import io.undertow.server.HttpServerExchange; @@ -99,7 +117,7 @@ break; } else if (c == '/') { if (pos != i) { - String original = part.substring(pos, i - 1); + String original = part.substring(pos, i); String encoded = URLEncoder.encode(original, UTF_8); if (!encoded.equals(original)) { return realEncode(part, pos); @@ -123,7 +141,7 @@ break; } else if (c == '/') { if (pos != i) { - String original = part.substring(pos, i - 1); + String original = part.substring(pos, i); String encoded = URLEncoder.encode(original, UTF_8); sb.append(encoded); sb.append('/'); Index: 3rdParty_sources/undertow/io/undertow/util/ReferenceCountedPooled.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/ReferenceCountedPooled.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/ReferenceCountedPooled.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/ReferenceCountedPooled.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import io.undertow.UndertowMessages; @@ -14,6 +32,7 @@ @SuppressWarnings("unused") private volatile int referenceCount; private volatile boolean discard = false; + boolean mainFreed = false; private static final AtomicIntegerFieldUpdater referenceCountUpdater = AtomicIntegerFieldUpdater.newUpdater(ReferenceCountedPooled.class, "referenceCount"); @@ -33,6 +52,13 @@ @Override public void free() { + if(mainFreed) { + throw UndertowMessages.MESSAGES.bufferAlreadyFreed(); + } + mainFreed = true; + freeInternal(); + } + public void freeInternal() { if(referenceCountUpdater.decrementAndGet(this) == 0) { if(discard) { underlying.discard(); @@ -47,6 +73,11 @@ return underlying.getResource(); } + @Override + public void close() { + free(); + } + public Pooled createView(final T newValue) { increaseReferenceCount(); return new Pooled() { @@ -57,7 +88,7 @@ public void discard() { if(!free) { free = true; - ReferenceCountedPooled.this.discard(); + ReferenceCountedPooled.this.freeInternal(); } } @@ -66,7 +97,7 @@ //make sure that a given view can only be freed once if(!free) { free = true; - ReferenceCountedPooled.this.free(); + ReferenceCountedPooled.this.freeInternal(); } } @@ -77,6 +108,11 @@ } return newValue; } + + @Override + public void close() { + free(); + } }; } Index: 3rdParty_sources/undertow/io/undertow/util/SameThreadExecutor.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/SameThreadExecutor.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/SameThreadExecutor.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/SameThreadExecutor.java 25 Nov 2014 10:46:51 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import java.util.concurrent.Executor; Index: 3rdParty_sources/undertow/io/undertow/util/SecureHashMap.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/SecureHashMap.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/SecureHashMap.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/SecureHashMap.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -95,7 +95,7 @@ this.loadFactor = loadFactor; this.initialCapacity = capacity; - final Table table = new Table(capacity, loadFactor); + final Table table = new Table<>(capacity, loadFactor); tableUpdater.set(this, table); } @@ -203,7 +203,7 @@ } // Row doesn't exist, or row exists but item doesn't; try and add a new item to the row. - final Item newItem = new Item(key, hashCode, value); + final Item newItem = new Item<>(key, hashCode, value); final Item[] newRow = addItem(oldRow, newItem); if (! array.compareAndSet(idx, oldRow, newRow)) { // Nope, row changed; retry. @@ -229,7 +229,7 @@ private void resize(Table origTable) { final AtomicReferenceArray[]> origArray = origTable.array; final int origCapacity = origArray.length(); - final Table newTable = new Table(origCapacity << 1, loadFactor); + final Table newTable = new Table<>(origCapacity << 1, loadFactor); // Prevent resize until we're done... newTable.size = 0x80000000; origTable.resizeView = newTable; @@ -633,7 +633,7 @@ } public void clear() { - table = new Table(initialCapacity, loadFactor); + table = new Table<>(initialCapacity, loadFactor); } public Set> entrySet() { @@ -668,13 +668,13 @@ } public Object[] toArray() { - ArrayList list = new ArrayList(size()); + ArrayList list = new ArrayList<>(size()); list.addAll(this); return list.toArray(); } public T[] toArray(final T[] a) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.addAll((Collection) this); return list.toArray(a); } @@ -703,13 +703,13 @@ } public Object[] toArray() { - ArrayList list = new ArrayList(size()); + ArrayList list = new ArrayList<>(size()); list.addAll(this); return list.toArray(); } public T[] toArray(final T[] a) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.addAll((Collection) this); return list.toArray(a); } @@ -743,13 +743,13 @@ } public Object[] toArray() { - ArrayList list = new ArrayList(size()); + ArrayList list = new ArrayList<>(size()); list.addAll(this); return list.toArray(); } public T[] toArray(final T[] a) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.addAll((Set) this); return list.toArray(a); } @@ -1061,7 +1061,7 @@ volatile Table resizeView; private Table(int capacity, float loadFactor) { - array = new AtomicReferenceArray[]>(capacity); + array = new AtomicReferenceArray<>(capacity); threshold = capacity == MAXIMUM_CAPACITY ? Integer.MAX_VALUE : (int)(capacity * loadFactor); } } Index: 3rdParty_sources/undertow/io/undertow/util/Sessions.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/Sessions.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/Sessions.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/Sessions.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import io.undertow.UndertowMessages; Index: 3rdParty_sources/undertow/io/undertow/util/SimpleAttachmentKey.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/SimpleAttachmentKey.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/SimpleAttachmentKey.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/SimpleAttachmentKey.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/StatusCodes.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/StatusCodes.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/StatusCodes.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/StatusCodes.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; @@ -25,25 +25,30 @@ //chosen simply because it gives no collisions //if more codes are added this will need to be re-evaluated - private static final int SIZE = 0x3f; + private static final int SIZE = 0x2df; private static final Entry[] TABLE = new Entry[SIZE]; public static final int CONTINUE = 100; public static final int SWITCHING_PROTOCOLS = 101; + public static final int PROCESSING = 102; public static final int OK = 200; public static final int CREATED = 201; public static final int ACCEPTED = 202; public static final int NON_AUTHORITATIVE_INFORMATION = 203; public static final int NO_CONTENT = 204; public static final int RESET_CONTENT = 205; public static final int PARTIAL_CONTENT = 206; + public static final int MULTI_STATUS = 207; + public static final int ALREADY_REPORTED = 208; + public static final int IM_USED = 226; public static final int MULTIPLE_CHOICES = 300; public static final int MOVED_PERMENANTLY = 301; public static final int FOUND = 302; public static final int SEE_OTHER = 303; public static final int NOT_MODIFIED = 304; public static final int USE_PROXY = 305; public static final int TEMPORARY_REDIRECT = 307; + public static final int PERMANENT_REDIRECT = 308; public static final int BAD_REQUEST = 400; public static final int UNAUTHORIZED = 401; public static final int PAYMENT_REQUIRED = 402; @@ -62,29 +67,45 @@ public static final int UNSUPPORTED_MEDIA_TYPE = 415; public static final int REQUEST_RANGE_NOT_SATISFIABLE = 416; public static final int EXPECTATION_FAILED = 417; + public static final int UNPROCESSABLE_ENTITY = 422; + public static final int LOCKED = 423; + public static final int FAILED_DEPENDENCY = 424; + public static final int UPGRADE_REQUIRED = 426; + public static final int PRECONDITION_REQUIRED = 428; + public static final int TOO_MANY_REQUESTS = 429; + public static final int REQUEST_HEADER_FIELDS_TOO_LARGE = 431; public static final int INTERNAL_SERVER_ERROR = 500; public static final int NOT_IMPLEMENTED = 501; public static final int BAD_GATEWAY = 502; public static final int SERVICE_UNAVAILABLE = 503; public static final int GATEWAY_TIME_OUT = 504; public static final int HTTP_VERSION_NOT_SUPPORTED = 505; + public static final int INSUFFICIENT_STORAGE = 507; + public static final int LOOP_DETECTED = 508; + public static final int NOT_EXTENDED = 510; + public static final int NETWORK_AUTHENTICATION_REQUIRED = 511; public static final String CONTINUE_STRING = "Continue"; public static final String SWITCHING_PROTOCOLS_STRING = "Switching Protocols"; + public static final String PROCESSING_STRING = "Processing"; public static final String OK_STRING = "OK"; public static final String CREATED_STRING = "Created"; public static final String ACCEPTED_STRING = "Accepted"; public static final String NON_AUTHORITATIVE_INFORMATION_STRING = "Non-Authoritative Information"; public static final String NO_CONTENT_STRING = "No Content"; public static final String RESET_CONTENT_STRING = "Reset Content"; public static final String PARTIAL_CONTENT_STRING = "Partial Content"; + public static final String MULTI_STATUS_STRING = "Multi-Status"; + public static final String ALREADY_REPORTED_STRING = "Already Reported"; + public static final String IM_USED_STRING = "IM Used"; public static final String MULTIPLE_CHOICES_STRING = "Multiple Choices"; public static final String MOVED_PERMANENTLY_STRING = "Moved Permanently"; public static final String FOUND_STRING = "Found"; public static final String SEE_OTHER_STRING = "See Other"; public static final String NOT_MODIFIED_STRING = "Not Modified"; public static final String USE_PROXY_STRING = "Use Proxy"; public static final String TEMPORARY_REDIRECT_STRING = "Temporary Redirect"; + public static final String PERMANENT_REDIRECT_STRING = "Permanent Redirect"; public static final String BAD_REQUEST_STRING = "Bad Request"; public static final String UNAUTHORIZED_STRING = "Unauthorized"; public static final String PAYMENT_REQUIRED_STRING = "Payment Required"; @@ -103,30 +124,46 @@ public static final String UNSUPPORTED_MEDIA_TYPE_STRING = "Unsupported Media Type"; public static final String REQUEST_RANGE_NOT_SATISFIABLE_STRING = "Requested range not satisfiable"; public static final String EXPECTATION_FAILED_STRING = "Expectation Failed"; + public static final String UNPROCESSABLE_ENTITY_STRING = "Unprocessable Entity"; + public static final String LOCKED_STRING = "Locked"; + public static final String FAILED_DEPENDENCY_STRING = "Failed Dependency"; + public static final String UPGRADE_REQUIRED_STRING = "Upgrade Required"; + public static final String PRECONDITION_REQUIRED_STRING = "Precondition Required"; + public static final String TOO_MANY_REQUESTS_STRING = "Too Many Requests"; + public static final String REQUEST_HEADER_FIELDS_TOO_LARGE_STRING = "Request Header Fields Too Large"; public static final String INTERNAL_SERVER_ERROR_STRING = "Internal Server Error"; public static final String NOT_IMPLEMENTED_STRING = "Not Implemented"; public static final String BAD_GATEWAY_STRING = "Bad Gateway"; public static final String SERVICE_UNAVAILABLE_STRING = "Service Unavailable"; public static final String GATEWAY_TIME_OUT_STRING = "Gateway Time-out"; public static final String HTTP_VERSION_NOT_SUPPORTED_STRING = "HTTP Version not supported"; + public static final String INSUFFICIENT_STORAGE_STRING = "Insufficient Storage"; + public static final String LOOP_DETECTED_STRING = "Loop Detected"; + public static final String NOT_EXTENDED_STRING = "Not Extended"; + public static final String NETWORK_AUTHENTICATION_REQUIRED_STRING = "Network Authentication Required"; static { putCode(CONTINUE, CONTINUE_STRING); putCode(SWITCHING_PROTOCOLS, SWITCHING_PROTOCOLS_STRING); + putCode(PROCESSING, PROCESSING_STRING); putCode(OK, OK_STRING); putCode(CREATED, CREATED_STRING); putCode(ACCEPTED, ACCEPTED_STRING); putCode(NON_AUTHORITATIVE_INFORMATION, NON_AUTHORITATIVE_INFORMATION_STRING); putCode(NO_CONTENT, NO_CONTENT_STRING); putCode(RESET_CONTENT, RESET_CONTENT_STRING); putCode(PARTIAL_CONTENT, PARTIAL_CONTENT_STRING); + putCode(MULTI_STATUS, MULTI_STATUS_STRING); + putCode(ALREADY_REPORTED, ALREADY_REPORTED_STRING); + putCode(IM_USED, IM_USED_STRING); putCode(MULTIPLE_CHOICES, MULTIPLE_CHOICES_STRING); putCode(MOVED_PERMENANTLY, MOVED_PERMANENTLY_STRING); putCode(FOUND, FOUND_STRING); putCode(SEE_OTHER, SEE_OTHER_STRING); putCode(NOT_MODIFIED, NOT_MODIFIED_STRING); putCode(USE_PROXY, USE_PROXY_STRING); putCode(TEMPORARY_REDIRECT, TEMPORARY_REDIRECT_STRING); + putCode(PERMANENT_REDIRECT, PERMANENT_REDIRECT_STRING); putCode(BAD_REQUEST, BAD_REQUEST_STRING); putCode(UNAUTHORIZED, UNAUTHORIZED_STRING); putCode(PAYMENT_REQUIRED, PAYMENT_REQUIRED_STRING); @@ -145,12 +182,23 @@ putCode(UNSUPPORTED_MEDIA_TYPE, UNSUPPORTED_MEDIA_TYPE_STRING); putCode(REQUEST_RANGE_NOT_SATISFIABLE, REQUEST_RANGE_NOT_SATISFIABLE_STRING); putCode(EXPECTATION_FAILED, EXPECTATION_FAILED_STRING); + putCode(UNPROCESSABLE_ENTITY, UNPROCESSABLE_ENTITY_STRING); + putCode(LOCKED, LOCKED_STRING); + putCode(FAILED_DEPENDENCY, FAILED_DEPENDENCY_STRING); + putCode(UPGRADE_REQUIRED, UPGRADE_REQUIRED_STRING); + putCode(PRECONDITION_REQUIRED, PRECONDITION_REQUIRED_STRING); + putCode(TOO_MANY_REQUESTS, TOO_MANY_REQUESTS_STRING); + putCode(REQUEST_HEADER_FIELDS_TOO_LARGE, REQUEST_HEADER_FIELDS_TOO_LARGE_STRING); putCode(INTERNAL_SERVER_ERROR, INTERNAL_SERVER_ERROR_STRING); putCode(NOT_IMPLEMENTED, NOT_IMPLEMENTED_STRING); putCode(BAD_GATEWAY, BAD_GATEWAY_STRING); putCode(SERVICE_UNAVAILABLE, SERVICE_UNAVAILABLE_STRING); putCode(GATEWAY_TIME_OUT, GATEWAY_TIME_OUT_STRING); putCode(HTTP_VERSION_NOT_SUPPORTED, HTTP_VERSION_NOT_SUPPORTED_STRING); + putCode(INSUFFICIENT_STORAGE, INSUFFICIENT_STORAGE_STRING); + putCode(LOOP_DETECTED, LOOP_DETECTED_STRING); + putCode(NOT_EXTENDED, NOT_EXTENDED_STRING); + putCode(NETWORK_AUTHENTICATION_REQUIRED, NETWORK_AUTHENTICATION_REQUIRED_STRING); } Index: 3rdParty_sources/undertow/io/undertow/util/StringReadChannelListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/StringReadChannelListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/StringReadChannelListener.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/StringReadChannelListener.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import java.io.IOException; Index: 3rdParty_sources/undertow/io/undertow/util/StringWriteChannelListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/StringWriteChannelListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/StringWriteChannelListener.java 8 Sep 2014 10:52:05 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/StringWriteChannelListener.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.util; Index: 3rdParty_sources/undertow/io/undertow/util/URLUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/util/Attic/URLUtils.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/util/URLUtils.java 8 Sep 2014 10:52:04 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/util/URLUtils.java 25 Nov 2014 10:46:50 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.util; import io.undertow.UndertowMessages; @@ -152,6 +170,21 @@ default: buffer.append(c); i++; + if(c > 127 && !needToChange) { + //we have non-ascii data in our URL, which sucks + //its hard to know exactly what to do with this, but we assume that because this data + //has not been properly encoded none of the other data is either + try { + char[] carray = s.toCharArray(); + byte[] buf = new byte[carray.length]; + for(int l = 0;l < buf.length; ++l) { + buf[l] = (byte) carray[l]; + } + return new String(buf, enc); + } catch (UnsupportedEncodingException e) { + throw UndertowMessages.MESSAGES.failedToDecodeURL(s, enc); + } + } break; } } Index: 3rdParty_sources/undertow/io/undertow/websockets/WebSocketConnectionCallback.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/Attic/WebSocketConnectionCallback.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/WebSocketConnectionCallback.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/WebSocketConnectionCallback.java 25 Nov 2014 10:47:02 -0000 1.1.2.3 @@ -1,17 +1,19 @@ /* - * Copyright 2012 JBoss, by Red Hat, Inc + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets; Index: 3rdParty_sources/undertow/io/undertow/websockets/WebSocketExtension.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/Attic/WebSocketExtension.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/WebSocketExtension.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/WebSocketExtension.java 25 Nov 2014 10:47:02 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets; import java.util.ArrayList; @@ -14,7 +32,7 @@ public WebSocketExtension(String name, List parameters) { this.name = name; - this.parameters = Collections.unmodifiableList(new ArrayList(parameters)); + this.parameters = Collections.unmodifiableList(new ArrayList<>(parameters)); } public String getName() { @@ -59,18 +77,21 @@ } public static List parse(final String extensionHeader) { - List extensions = new ArrayList(); + if(extensionHeader == null || extensionHeader.isEmpty()) { + return Collections.emptyList(); + } + List extensions = new ArrayList<>(); //TODO: more efficient parsing algorithm String[] parts = extensionHeader.split(","); for (String part : parts) { String[] items = part.split(";"); if (items.length > 0) { - final List params = new ArrayList(items.length - 1); - String name = items[0]; + final List params = new ArrayList<>(items.length - 1); + String name = items[0].trim(); for (int i = 1; i < items.length; ++i) { String[] param = items[i].split("="); if (param.length == 2) { - params.add(new Parameter(param[0], param[1])); + params.add(new Parameter(param[0].trim(), param[1].trim())); } } extensions.add(new WebSocketExtension(name, params)); Index: 3rdParty_sources/undertow/io/undertow/websockets/WebSocketProtocolHandshakeHandler.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/Attic/WebSocketProtocolHandshakeHandler.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/WebSocketProtocolHandshakeHandler.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/WebSocketProtocolHandshakeHandler.java 25 Nov 2014 10:47:02 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets; @@ -33,8 +33,10 @@ import org.xnio.StreamConnection; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; /** * {@link HttpHandler} which will process the {@link HttpServerExchange} and do the actual handshake/upgrade @@ -52,6 +54,8 @@ private final WebSocketConnectionCallback callback; + private final Set peerConnections = Collections.newSetFromMap(new ConcurrentHashMap()); + /** * The handler that is invoked if there are no web socket headers */ @@ -75,7 +79,7 @@ */ public WebSocketProtocolHandshakeHandler(final WebSocketConnectionCallback callback, final HttpHandler next) { this.callback = callback; - Set handshakes = new HashSet(); + Set handshakes = new HashSet<>(); handshakes.add(new Hybi13Handshake()); handshakes.add(new Hybi08Handshake()); handshakes.add(new Hybi07Handshake()); @@ -104,7 +108,7 @@ */ public WebSocketProtocolHandshakeHandler(Collection handshakes, final WebSocketConnectionCallback callback, final HttpHandler next) { this.callback = callback; - this.handshakes = new HashSet(handshakes); + this.handshakes = new HashSet<>(handshakes); this.next = next; this.upgradeListener = null; } @@ -127,7 +131,7 @@ */ public WebSocketProtocolHandshakeHandler(final HttpUpgradeListener callback, final HttpHandler next) { this.callback = null; - Set handshakes = new HashSet(); + Set handshakes = new HashSet<>(); handshakes.add(new Hybi13Handshake()); handshakes.add(new Hybi08Handshake()); handshakes.add(new Hybi07Handshake()); @@ -157,7 +161,7 @@ */ public WebSocketProtocolHandshakeHandler(Collection handshakes, final HttpUpgradeListener callback, final HttpHandler next) { this.callback = null; - this.handshakes = new HashSet(handshakes); + this.handshakes = new HashSet<>(handshakes); this.next = next; this.upgradeListener = callback; } @@ -169,7 +173,7 @@ next.handleRequest(exchange); return; } - final AsyncWebSocketHttpServerExchange facade = new AsyncWebSocketHttpServerExchange(exchange); + final AsyncWebSocketHttpServerExchange facade = new AsyncWebSocketHttpServerExchange(exchange, peerConnections); Handshake handshaker = null; for (Handshake method : handshakes) { if (method.matches(facade)) { @@ -187,6 +191,7 @@ @Override public void handleUpgrade(StreamConnection streamConnection, HttpServerExchange exchange) { WebSocketChannel channel = selected.createChannel(facade, streamConnection, facade.getBufferPool()); + peerConnections.add(channel); callback.onConnect(facade, channel); } }); @@ -196,4 +201,8 @@ handshaker.handshake(facade); } } + + public Set getPeerConnections() { + return peerConnections; + } } Index: 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocket13ClientHandshake.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/client/Attic/WebSocket13ClientHandshake.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocket13ClientHandshake.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocket13ClientHandshake.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.client; import io.undertow.util.FlexBase64; @@ -10,7 +28,7 @@ import io.undertow.websockets.core.protocol.version13.WebSocket13Channel; import org.xnio.Pool; import org.xnio.StreamConnection; -import org.xnio.http.HandshakeChecker; +import org.xnio.http.ExtendedHandshakeChecker; import java.io.IOException; import java.net.URI; @@ -20,6 +38,7 @@ import java.security.SecureRandom; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -45,12 +64,12 @@ @Override public WebSocketChannel createChannel(final StreamConnection channel, final String wsUri, final Pool bufferPool) { - return new WebSocket13Channel(channel, bufferPool, wsUri, negotiation != null ? negotiation.getSelectedSubProtocol() : "", true, false); + return new WebSocket13Channel(channel, bufferPool, wsUri, negotiation != null ? negotiation.getSelectedSubProtocol() : "", true, false, new HashSet()); } public Map createHeaders() { - Map headers = new HashMap(); + Map headers = new HashMap<>(); headers.put(Headers.UPGRADE_STRING, "websocket"); headers.put(Headers.CONNECTION_STRING, "upgrade"); String key = createSecKey(); @@ -75,7 +94,7 @@ Iterator it = extensions.iterator(); while (it.hasNext()) { WebSocketExtension next = it.next(); - sb.append(next); + sb.append(next.getName()); for (WebSocketExtension.Parameter param : next.getParameters()) { sb.append("; "); sb.append(param.getName()); @@ -107,43 +126,58 @@ } @Override - public HandshakeChecker handshakeChecker(final URI uri, final Map requestHeaders) { - final String sentKey = requestHeaders.get(Headers.SEC_WEB_SOCKET_KEY_STRING); - return new HandshakeChecker() { + public ExtendedHandshakeChecker handshakeChecker(final URI uri, final Map> requestHeaders) { + final String sentKey = requestHeaders.containsKey(Headers.SEC_WEB_SOCKET_KEY_STRING) ? requestHeaders.get(Headers.SEC_WEB_SOCKET_KEY_STRING).get(0) : null; + return new ExtendedHandshakeChecker() { + @Override - public void checkHandshake(Map headers) throws IOException { - if(negotiation != null) { - negotiation.afterRequest(headers); - } - String upgrade = headers.get(Headers.UPGRADE_STRING.toLowerCase(Locale.ENGLISH)); - if (upgrade == null || !upgrade.trim().equalsIgnoreCase("websocket")) { - throw WebSocketMessages.MESSAGES.noWebSocketUpgradeHeader(); - } - String connHeader = headers.get(Headers.CONNECTION_STRING.toLowerCase(Locale.ENGLISH)); - if (connHeader == null || !connHeader.trim().equalsIgnoreCase("upgrade")) { - throw WebSocketMessages.MESSAGES.noWebSocketConnectionHeader(); - } - String acceptKey = headers.get(Headers.SEC_WEB_SOCKET_ACCEPT_STRING.toLowerCase(Locale.ENGLISH)); - final String dKey = solve(sentKey); - if (!dKey.equals(acceptKey)) { - throw WebSocketMessages.MESSAGES.webSocketAcceptKeyMismatch(dKey, acceptKey); - } - if (negotiation != null) { - String subProto = headers.get(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING.toLowerCase(Locale.ENGLISH)); - if (subProto != null && !subProto.isEmpty() && !negotiation.getSupportedSubProtocols().contains(subProto)) { - throw WebSocketMessages.MESSAGES.unsupportedProtocol(subProto, negotiation.getSupportedSubProtocols()); + public void checkHandshakeExtended(Map> headers) throws IOException { + try { + if (negotiation != null) { + negotiation.afterRequest(headers); } - List extensions = Collections.emptyList(); - String extHeader = headers.get(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING.toLowerCase(Locale.ENGLISH)); - if (extHeader != null) { - extensions = WebSocketExtension.parse(extHeader); + String upgrade = getFirst(Headers.UPGRADE_STRING, headers); + if (upgrade == null || !upgrade.trim().equalsIgnoreCase("websocket")) { + throw WebSocketMessages.MESSAGES.noWebSocketUpgradeHeader(); } - negotiation.handshakeComplete(subProto, extensions); + String connHeader = getFirst(Headers.CONNECTION_STRING, headers); + if (connHeader == null || !connHeader.trim().equalsIgnoreCase("upgrade")) { + throw WebSocketMessages.MESSAGES.noWebSocketConnectionHeader(); + } + String acceptKey = getFirst(Headers.SEC_WEB_SOCKET_ACCEPT_STRING, headers); + final String dKey = solve(sentKey); + if (!dKey.equals(acceptKey)) { + throw WebSocketMessages.MESSAGES.webSocketAcceptKeyMismatch(dKey, acceptKey); + } + if (negotiation != null) { + String subProto = getFirst(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING, headers); + if (subProto != null && !subProto.isEmpty() && !negotiation.getSupportedSubProtocols().contains(subProto)) { + throw WebSocketMessages.MESSAGES.unsupportedProtocol(subProto, negotiation.getSupportedSubProtocols()); + } + List extensions = Collections.emptyList(); + String extHeader = getFirst(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING, headers); + if (extHeader != null) { + extensions = WebSocketExtension.parse(extHeader); + } + negotiation.handshakeComplete(subProto, extensions); + } + } catch (IOException e) { + throw e; + } catch (Exception e) { + throw new IOException(e); } } }; } + private String getFirst(String key, Map> map) { + List list = map.get(key.toLowerCase(Locale.ENGLISH)); + if(list == null || list.isEmpty()) { + return null; + } + return list.get(0); + } + protected final String solve(final String nonceBase64) { try { final String concat = nonceBase64 + MAGIC_NUMBER; Index: 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocketClient.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/client/Attic/WebSocketClient.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocketClient.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocketClient.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,7 +1,28 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.client; +import io.undertow.util.Headers; import io.undertow.websockets.core.WebSocketChannel; import io.undertow.websockets.core.WebSocketVersion; + +import org.xnio.Cancellable; import org.xnio.ChannelListener; import org.xnio.FutureResult; import org.xnio.IoFuture; @@ -15,6 +36,9 @@ import java.net.URI; import java.net.URISyntaxException; import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -39,19 +63,26 @@ public static IoFuture connect(XnioWorker worker, XnioSsl ssl, final Pool bufferPool, final OptionMap optionMap, final URI uri, WebSocketVersion version, WebSocketClientNegotiation clientNegotiation) { - final FutureResult ioFuture = new FutureResult(); + final FutureResult ioFuture = new FutureResult<>(); final URI newUri; try { newUri = new URI(uri.getScheme().equals("wss") ? "https" : "http", uri.getUserInfo(), uri.getHost(), uri.getPort() == -1 ? (uri.getScheme().equals("wss") ? 443 : 80) : uri.getPort(), uri.getPath().isEmpty() ? "/" : uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (URISyntaxException e) { throw new RuntimeException(e); } final WebSocketClientHandshake handshake = WebSocketClientHandshake.create(version, newUri, clientNegotiation); - final Map headers = handshake.createHeaders(); + final Map originalHeaders = handshake.createHeaders(); + originalHeaders.put(Headers.ORIGIN_STRING, uri.getHost()); + final Map> headers = new HashMap<>(); + for(Map.Entry entry : originalHeaders.entrySet()) { + List list = new ArrayList<>(); + list.add(entry.getValue()); + headers.put(entry.getKey(), list); + } if (clientNegotiation != null) { clientNegotiation.beforeRequest(headers); } - IoFuture result; + final IoFuture result; if (ssl != null) { result = HttpUpgrade.performUpgrade(worker, ssl, null, newUri, headers, new ChannelListener() { @Override @@ -77,6 +108,13 @@ } } }, null); + ioFuture.addCancelHandler(new Cancellable() { + @Override + public Cancellable cancel() { + result.cancel(); + return null; + } + }); return ioFuture.getIoFuture(); } Index: 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocketClientHandshake.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/client/Attic/WebSocketClientHandshake.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocketClientHandshake.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocketClientHandshake.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,13 +1,32 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.client; import io.undertow.websockets.core.WebSocketChannel; import io.undertow.websockets.core.WebSocketVersion; import org.xnio.Pool; import org.xnio.StreamConnection; -import org.xnio.http.HandshakeChecker; +import org.xnio.http.ExtendedHandshakeChecker; import java.net.URI; import java.nio.ByteBuffer; +import java.util.List; import java.util.Map; /** @@ -37,7 +56,7 @@ public abstract Map createHeaders(); - public abstract HandshakeChecker handshakeChecker(final URI uri, final Map requestHeaders); + public abstract ExtendedHandshakeChecker handshakeChecker(final URI uri, final Map> requestHeaders); } Index: 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocketClientNegotiation.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/client/Attic/WebSocketClientNegotiation.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocketClientNegotiation.java 8 Sep 2014 10:52:20 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/client/WebSocketClientNegotiation.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.client; import io.undertow.websockets.WebSocketExtension; @@ -36,10 +54,10 @@ return selectedExtensions; } - public void beforeRequest(final Map headers) { + public void beforeRequest(final Map> headers) { } - public void afterRequest(final Map headers) { + public void afterRequest(final Map> headers) { } Index: 3rdParty_sources/undertow/io/undertow/websockets/core/AbstractReceiveListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/AbstractReceiveListener.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/AbstractReceiveListener.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/AbstractReceiveListener.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.core; import org.xnio.ChannelListener; @@ -170,7 +188,7 @@ CloseMessage cm = new CloseMessage(data.getResource()); onCloseMessage(cm, channel); if (!channel.isCloseFrameSent()) { - WebSockets.sendClose(cm.toByteBuffer(), channel, null); + WebSockets.sendClose(cm, channel, null); } } finally { data.free(); Index: 3rdParty_sources/undertow/io/undertow/websockets/core/BinaryOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/BinaryOutputStream.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/BinaryOutputStream.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/BinaryOutputStream.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,17 +1,19 @@ /* - * Copyright 2013 JBoss, by Red Hat, Inc + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/BufferedBinaryMessage.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/BufferedBinaryMessage.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/BufferedBinaryMessage.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/BufferedBinaryMessage.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.core; import io.undertow.util.ImmediatePooled; @@ -18,7 +36,7 @@ public class BufferedBinaryMessage { private final boolean bufferFullMessage; - private List> data = new ArrayList>(1); + private List> data = new ArrayList<>(1); private Pooled current; private final long maxMessageSize; private long currentSize; @@ -79,6 +97,9 @@ channel.getReadSetter().set(new ChannelListener() { @Override public void handleEvent(StreamSourceFrameChannel channel) { + if(complete ) { + return; + } try { for (; ; ) { if (current == null) { @@ -142,14 +163,14 @@ private void checkMaxSize(StreamSourceFrameChannel channel, int res) throws IOException { currentSize += res; if (maxMessageSize > 0 && currentSize > maxMessageSize) { - WebSockets.sendClose(new CloseMessage(CloseMessage.MSG_TOO_BIG, WebSocketMessages.MESSAGES.messageToBig(maxMessageSize)).toByteBuffer(), channel.getWebSocketChannel(), null); + WebSockets.sendClose(new CloseMessage(CloseMessage.MSG_TOO_BIG, WebSocketMessages.MESSAGES.messageToBig(maxMessageSize)), channel.getWebSocketChannel(), null); throw new IOException(WebSocketMessages.MESSAGES.messageToBig(maxMessageSize)); } } public Pooled getData() { if (current == null) { - return new ImmediatePooled(new ByteBuffer[0]); + return new ImmediatePooled<>(new ByteBuffer[0]); } if (data.isEmpty()) { final Pooled current = this.current; @@ -166,7 +187,7 @@ ret[i] = data.get(i).getResource(); } List> data = this.data; - this.data = new ArrayList>(); + this.data = new ArrayList<>(); return new PooledByteBufferArray(data, ret); } @@ -203,5 +224,10 @@ public ByteBuffer[] getResource() throws IllegalStateException { return data; } + + @Override + public void close() { + free(); + } } } Index: 3rdParty_sources/undertow/io/undertow/websockets/core/BufferedTextMessage.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/BufferedTextMessage.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/BufferedTextMessage.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/BufferedTextMessage.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.core; import org.xnio.ChannelListener; @@ -38,7 +56,7 @@ currentSize += res; } if (maxMessageSize > 0 && currentSize > maxMessageSize) { - WebSockets.sendClose(new CloseMessage(CloseMessage.MSG_TOO_BIG, WebSocketMessages.MESSAGES.messageToBig(maxMessageSize)).toByteBuffer(), channel.getWebSocketChannel(), null); + WebSockets.sendClose(new CloseMessage(CloseMessage.MSG_TOO_BIG, WebSocketMessages.MESSAGES.messageToBig(maxMessageSize)), channel.getWebSocketChannel(), null); throw new IOException(WebSocketMessages.MESSAGES.messageToBig(maxMessageSize)); } } @@ -97,6 +115,9 @@ channel.getReadSetter().set(new ChannelListener() { @Override public void handleEvent(StreamSourceFrameChannel channel) { + if(complete ) { + return; + } Pooled pooled = channel.getWebSocketChannel().getBufferPool().allocate(); final ByteBuffer buffer = pooled.getResource(); try { Index: 3rdParty_sources/undertow/io/undertow/websockets/core/CloseMessage.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/CloseMessage.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/CloseMessage.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/CloseMessage.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.core; import java.nio.ByteBuffer; @@ -12,8 +30,8 @@ private static final Charset utf8 = Charset.forName("UTF-8"); - private final int reason; - private final String string; + private final int code; + private final String reason; /* * For the exact meaning of the codes refer to the WebSocket * RFC Section 7.4. @@ -30,35 +48,35 @@ public CloseMessage(final ByteBuffer buffer) { if(buffer.remaining() >= 2) { - reason = (buffer.get() & 0XFF) << 8 | (buffer.get() & 0xFF); - string = new UTF8Output(buffer).extract(); + code = (buffer.get() & 0XFF) << 8 | (buffer.get() & 0xFF); + reason = new UTF8Output(buffer).extract(); } else { - reason = GOING_AWAY; - string = ""; + code = GOING_AWAY; + reason = ""; } } - public CloseMessage(int reason, String string) { - this.reason = reason; - this.string = string; + public CloseMessage(int code, String reason) { + this.code = code; + this.reason = reason == null ? "" : reason; } public CloseMessage(final ByteBuffer[] buffers) { this(WebSockets.mergeBuffers(buffers)); } - public int getReason() { + public String getReason() { return reason; } - public String getString() { - return string; + public int getCode() { + return code; } public ByteBuffer toByteBuffer() { - byte[] data = string.getBytes(utf8); + byte[] data = reason.getBytes(utf8); ByteBuffer buffer = ByteBuffer.allocate(data.length + 2); - buffer.putShort((short)reason); + buffer.putShort((short) code); buffer.put(data); buffer.flip(); return buffer; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/FixedPayloadFrameSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/FixedPayloadFrameSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/FixedPayloadFrameSourceChannel.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/FixedPayloadFrameSourceChannel.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/InvalidOpCodeException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/InvalidOpCodeException.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/InvalidOpCodeException.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/InvalidOpCodeException.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.core; /** Index: 3rdParty_sources/undertow/io/undertow/websockets/core/SendChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/SendChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/SendChannel.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/SendChannel.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2013 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/StreamSinkFrameChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/StreamSinkFrameChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/StreamSinkFrameChannel.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/StreamSinkFrameChannel.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; @@ -51,9 +51,6 @@ if (!areExtensionsSupported() && rsv != 0) { throw WebSocketMessages.MESSAGES.extensionsNotSupported(); } - if (isActivated()) { - throw WebSocketMessages.MESSAGES.writeInProgress(); - } this.rsv = rsv; } Index: 3rdParty_sources/undertow/io/undertow/websockets/core/StreamSourceFrameChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/StreamSourceFrameChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/StreamSourceFrameChannel.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/StreamSourceFrameChannel.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,25 +9,26 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; -import io.undertow.server.protocol.framed.AbstractFramedStreamSourceChannel; +import java.io.IOException; +import java.nio.ByteBuffer; import org.xnio.ChannelExceptionHandler; import org.xnio.ChannelListener; import org.xnio.ChannelListeners; import org.xnio.IoUtils; import org.xnio.Pooled; import org.xnio.channels.StreamSourceChannel; -import java.io.IOException; -import java.nio.ByteBuffer; +import io.undertow.server.protocol.framed.AbstractFramedStreamSourceChannel; +import io.undertow.server.protocol.framed.FrameHeaderData; /** * Base class for processes Frame bases StreamSourceChannels. @@ -121,5 +122,11 @@ this.finalFragment = true; } - + @Override + protected void handleHeaderData(FrameHeaderData headerData) { + super.handleHeaderData(headerData); + if (((WebSocketFrame) headerData).isFinalFragment()) { + finalFrame(); + } + } } Index: 3rdParty_sources/undertow/io/undertow/websockets/core/UTF8Output.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/UTF8Output.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/UTF8Output.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/UTF8Output.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketCallback.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketCallback.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketCallback.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketCallback.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.core; /** Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketChannel.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketChannel.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,17 +9,19 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; +import io.undertow.conduits.IdleTimeoutConduit; import io.undertow.server.protocol.framed.AbstractFramedChannel; import io.undertow.server.protocol.framed.FrameHeaderData; import org.xnio.ChannelExceptionHandler; +import org.xnio.ChannelListener; import org.xnio.ChannelListeners; import org.xnio.IoUtils; import org.xnio.Pool; @@ -49,8 +51,14 @@ private final WebSocketVersion version; private final String wsUrl; - private boolean closeFrameReceived; - private boolean closeFrameSent; + private volatile boolean closeFrameReceived; + private volatile boolean closeFrameSent; + /** + * If this is true then the web socket close was initiated by the remote peer + */ + private volatile boolean closeInitiatedByRemotePeer; + private volatile int closeCode = -1; + private volatile String closeReason; private final String subProtocol; private final boolean extensionsSupported; /** @@ -63,26 +71,49 @@ protected StreamSourceFrameChannel fragmentedChannel; /** + * Represents all web socket channels that are attached to the same endpoint. + */ + private final Set peerConnections; + + /** * Create a new {@link WebSocketChannel} * 8 * * @param connectedStreamChannel The {@link org.xnio.channels.ConnectedStreamChannel} over which the WebSocket Frames should get send and received. * Be aware that it already must be "upgraded". * @param bufferPool The {@link org.xnio.Pool} which will be used to acquire {@link java.nio.ByteBuffer}'s from. - * @param version The {@link io.undertow.websockets.core.WebSocketVersion} of the {@link io.undertow.websockets.core.WebSocketChannel} + * @param version The {@link WebSocketVersion} of the {@link WebSocketChannel} * @param wsUrl The url for which the channel was created. * @param client + * @param peerConnections The concurrent set that is used to track open connections associtated with an endpoint */ - protected WebSocketChannel(final StreamConnection connectedStreamChannel, Pool bufferPool, WebSocketVersion version, String wsUrl, String subProtocol, final boolean client, boolean extensionsSupported) { - super(connectedStreamChannel, bufferPool, new WebSocketFramePriority()); + protected WebSocketChannel(final StreamConnection connectedStreamChannel, Pool bufferPool, WebSocketVersion version, String wsUrl, String subProtocol, final boolean client, boolean extensionsSupported, Set peerConnections) { + super(connectedStreamChannel, bufferPool, new WebSocketFramePriority(), null); this.client = client; this.version = version; this.wsUrl = wsUrl; this.extensionsSupported = extensionsSupported; this.subProtocol = subProtocol; + this.peerConnections = peerConnections; + addCloseTask(new ChannelListener() { + @Override + public void handleEvent(WebSocketChannel channel) { + WebSocketChannel.this.peerConnections.remove(WebSocketChannel.this); + } + }); } @Override + protected IdleTimeoutConduit createIdleTimeoutChannel(final StreamConnection connectedStreamChannel) { + return new IdleTimeoutConduit(connectedStreamChannel.getSinkChannel().getConduit(), connectedStreamChannel.getSourceChannel().getConduit()) { + @Override + protected void doClose() { + WebSockets.sendClose(CloseMessage.GOING_AWAY, null, WebSocketChannel.this, null); + } + }; + } + + @Override protected boolean isLastFrameSent() { return closeFrameSent; } @@ -97,8 +128,21 @@ super.markReadsBroken(cause); } + @Override + protected void lastDataRead() { + if(!closeFrameReceived && !closeFrameSent) { + //the peer has likely already gone away, but try and send a close frame anyway + //this will likely just result in the write() failing an immediate connection termination + //which is what we want + closeFrameReceived = true; //not strictly true, but the read side is gone + try { + sendClose(); + } catch (IOException e) { + IoUtils.safeClose(this); + } + } + } - protected boolean isReadsBroken() { return super.isReadsBroken(); } @@ -144,6 +188,9 @@ PartialFrame partialFrame = (PartialFrame) frameHeaderData; StreamSourceFrameChannel channel = partialFrame.getChannel(frameData); if (channel.getType() == WebSocketFrameType.CLOSE) { + if(!closeFrameSent) { + closeInitiatedByRemotePeer = true; + } closeFrameReceived = true; } return channel; @@ -276,6 +323,9 @@ * to transmit no payload at all. */ public final StreamSinkFrameChannel send(WebSocketFrameType type, long payloadSize) throws IOException { + if(closeFrameSent || (closeFrameReceived && type != WebSocketFrameType.CLOSE)) { + throw WebSocketMessages.MESSAGES.channelClosed(); + } if (payloadSize < 0) { throw WebSocketMessages.MESSAGES.negativePayloadLength(); } @@ -315,6 +365,8 @@ * Send a Close frame without a payload */ public void sendClose() throws IOException { + closeReason = ""; + closeCode = CloseMessage.NORMAL_CLOSURE; StreamSinkFrameChannel closeChannel = send(WebSocketFrameType.CLOSE, 0); closeChannel.shutdownWrites(); if (!closeChannel.flush()) { @@ -326,6 +378,7 @@ } } )); + closeChannel.resumeWrites(); } } @@ -343,8 +396,25 @@ return (WebSocketFramePriority) super.getFramePriority(); } + /** + * Returns all 'peer' web socket connections that were created from the same endpoint. + * + * + * @return all 'peer' web socket connections + */ + public Set getPeerConnections() { + return Collections.unmodifiableSet(peerConnections); + } /** + * If this is true the session is being closed because the remote peer sent a close frame + * @return true if the remote peer closed the connection + */ + public boolean isCloseInitiatedByRemotePeer() { + return closeInitiatedByRemotePeer; + } + + /** * Interface that represents a frame channel that is in the process of being created */ public interface PartialFrame extends FrameHeaderData { @@ -364,4 +434,28 @@ */ boolean isDone(); } + + /** + * + * @return The close reason + */ + public String getCloseReason() { + return closeReason; + } + + public void setCloseReason(String closeReason) { + this.closeReason = closeReason; + } + + /** + * + * @return The close code + */ + public int getCloseCode() { + return closeCode; + } + + public void setCloseCode(int closeCode) { + this.closeCode = closeCode; + } } Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketException.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketException.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketException.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; Fisheye: Tag 1.1.2.2 refers to a dead (removed) revision in file `3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketFrame.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketFrameCorruptedException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketFrameCorruptedException.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketFrameCorruptedException.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketFrameCorruptedException.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketFramePriority.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketFramePriority.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketFramePriority.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketFramePriority.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.core; import io.undertow.server.protocol.framed.FramePriority; @@ -21,7 +39,7 @@ *

    * TODO: provide a way to disable this. */ - private final Queue strictOrderQueue = new ConcurrentLinkedDeque(); + private final Queue strictOrderQueue = new ConcurrentLinkedDeque<>(); private StreamSinkFrameChannel currentFragmentedSender; boolean closed = false; boolean immediateCloseFrame = false; @@ -97,6 +115,21 @@ @Override public void frameAdded(StreamSinkFrameChannel addedFrame, List pendingFrames, Deque holdFrames) { if (addedFrame.isFinalFragment()) { + while (true) { + StreamSinkFrameChannel frame = strictOrderQueue.peek(); + if(frame == null) { + break; + } + if(holdFrames.contains(frame)) { + if(insertFrame(frame, pendingFrames)) { + holdFrames.remove(frame); + } else { + break; + } + } else { + break; + } + } while (!holdFrames.isEmpty()) { StreamSinkFrameChannel frame = holdFrames.peek(); if (insertFrame(frame, pendingFrames)) { Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketFrameType.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketFrameType.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketFrameType.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketFrameType.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketHandshakeException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketHandshakeException.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketHandshakeException.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketHandshakeException.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketInvalidCloseCodeException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketInvalidCloseCodeException.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketInvalidCloseCodeException.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketInvalidCloseCodeException.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketLogger.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketLogger.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketLogger.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketLogger.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; @@ -61,4 +61,8 @@ @LogMessage(level = Logger.Level.ERROR) @Message(id = 25006, value = "Failed to get idle timeout") void getIdleTimeFailed(@Cause Throwable cause); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 25007, value = "Unhandled exception for annotated endpoint %s") + void unhandledErrorInAnnotatedEndpoint(Object instance, @Cause Throwable thr); } Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketMessages.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketMessages.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketMessages.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketMessages.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketUtils.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketUtils.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketUtils.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,14 +9,15 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; +import io.undertow.UndertowLogger; import org.xnio.Buffers; import org.xnio.ChannelExceptionHandler; import org.xnio.ChannelListener; @@ -180,7 +181,7 @@ try { streamSinkFrameChannel.shutdownWrites(); } catch (IOException e) { - e.printStackTrace(); + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); IoUtils.safeClose(streamSinkFrameChannel, channel); return; } @@ -199,7 +200,8 @@ }, new ChannelExceptionHandler() { @Override public void handleException(StreamSinkFrameChannel streamSinkFrameChannel, IOException e) { - e.printStackTrace(); + + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); IoUtils.safeClose(streamSinkFrameChannel, channel); } @@ -214,22 +216,21 @@ IoUtils.safeClose(streamSinkFrameChannel); } } catch (IOException e) { - e.printStackTrace(); + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); IoUtils.safeClose(streamSinkFrameChannel, channel); } } }, new ChannelExceptionHandler() { @Override public void handleException(StreamSourceFrameChannel streamSourceFrameChannel, IOException e) { - e.printStackTrace(); + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); IoUtils.safeClose(streamSourceFrameChannel, channel); } }, new ChannelExceptionHandler() { @Override public void handleException(StreamSinkFrameChannel streamSinkFrameChannel, IOException e) { - e.printStackTrace(); - + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); IoUtils.safeClose(streamSinkFrameChannel, channel); } }, channel.getBufferPool() @@ -283,7 +284,7 @@ } if (res == 0) { // write first listener - final TransferListener listener = new TransferListener(allocated, source, sink, sourceListener, sinkListener, writeExceptionHandler, readExceptionHandler, 1); + final TransferListener listener = new TransferListener<>(allocated, source, sink, sourceListener, sinkListener, writeExceptionHandler, readExceptionHandler, 1); source.suspendReads(); source.getReadSetter().set(listener); sink.getWriteSetter().set(listener); @@ -299,7 +300,7 @@ } } } while (transferred > 0L); - final TransferListener listener = new TransferListener(allocated, source, sink, sourceListener, sinkListener, writeExceptionHandler, readExceptionHandler, 0); + final TransferListener listener = new TransferListener<>(allocated, source, sink, sourceListener, sinkListener, writeExceptionHandler, readExceptionHandler, 0); sink.suspendWrites(); sink.getWriteSetter().set(listener); source.getReadSetter().set(listener); Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketVersion.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSocketVersion.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketVersion.java 8 Sep 2014 10:52:06 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSocketVersion.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/WebSockets.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/Attic/WebSockets.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/WebSockets.java 8 Sep 2014 10:52:07 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/WebSockets.java 25 Nov 2014 10:46:49 -0000 1.1.2.3 @@ -1,13 +1,33 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.core; import org.xnio.Buffers; import org.xnio.ChannelExceptionHandler; import org.xnio.ChannelListener; import org.xnio.IoUtils; +import org.xnio.XnioExecutor; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.Charset; +import java.util.concurrent.TimeUnit; import static org.xnio.ChannelListeners.flushingChannelListener; @@ -27,29 +47,75 @@ */ public static void sendText(final String message, final WebSocketChannel wsChannel, final WebSocketCallback callback) { final ByteBuffer data = ByteBuffer.wrap(message.getBytes(utf8)); - sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.TEXT, wsChannel, callback); + sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.TEXT, wsChannel, callback, -1); } /** * Sends a complete text message, invoking the callback when complete * * @param message * @param wsChannel + * @param callback + * @param timeoutmillis the timeout in milliseconds */ + public static void sendText(final String message, final WebSocketChannel wsChannel, final WebSocketCallback callback, long timeoutmillis) { + final ByteBuffer data = ByteBuffer.wrap(message.getBytes(utf8)); + sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.TEXT, wsChannel, callback, timeoutmillis); + } + + /** + * Sends a complete text message, invoking the callback when complete + * + * @param message + * @param wsChannel + * @param callback + */ + public static void sendText(final ByteBuffer message, final WebSocketChannel wsChannel, final WebSocketCallback callback) { + sendInternal(new ByteBuffer[]{message}, WebSocketFrameType.TEXT, wsChannel, callback, -1); + } + + /** + * Sends a complete text message, invoking the callback when complete + * + * @param message + * @param wsChannel + * @param callback + */ + public static void sendText(final ByteBuffer message, final WebSocketChannel wsChannel, final WebSocketCallback callback, long timeoutmillis) { + sendInternal(new ByteBuffer[]{message}, WebSocketFrameType.TEXT, wsChannel, callback, timeoutmillis); + } + + + /** + * Sends a complete text message, invoking the callback when complete + * + * @param message + * @param wsChannel + */ public static void sendTextBlocking(final String message, final WebSocketChannel wsChannel) throws IOException { final ByteBuffer data = ByteBuffer.wrap(message.getBytes(utf8)); sendBlockingInternal(new ByteBuffer[]{data}, WebSocketFrameType.TEXT, wsChannel); } /** + * Sends a complete text message, invoking the callback when complete + * + * @param message + * @param wsChannel + */ + public static void sendTextBlocking(final ByteBuffer message, final WebSocketChannel wsChannel) throws IOException { + sendBlockingInternal(new ByteBuffer[]{message}, WebSocketFrameType.TEXT, wsChannel); + } + + /** * Sends a complete ping message, invoking the callback when complete * * @param data * @param wsChannel * @param callback */ public static void sendPing(final ByteBuffer data, final WebSocketChannel wsChannel, final WebSocketCallback callback) { - sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.PING, wsChannel, callback); + sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.PING, wsChannel, callback, -1); } /** @@ -59,11 +125,33 @@ * @param wsChannel * @param callback */ + public static void sendPing(final ByteBuffer data, final WebSocketChannel wsChannel, final WebSocketCallback callback, long timeoutmillis) { + sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.PING, wsChannel, callback, timeoutmillis); + } + + /** + * Sends a complete ping message, invoking the callback when complete + * + * @param data + * @param wsChannel + * @param callback + */ public static void sendPing(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback callback) { - sendInternal(data, WebSocketFrameType.PING, wsChannel, callback); + sendInternal(data, WebSocketFrameType.PING, wsChannel, callback, -1); } /** + * Sends a complete ping message, invoking the callback when complete + * + * @param data + * @param wsChannel + * @param callback + */ + public static void sendPing(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback callback, long timeoutmillis) { + sendInternal(data, WebSocketFrameType.PING, wsChannel, callback, timeoutmillis); + } + + /** * Sends a complete ping message using blocking IO * * @param data @@ -91,10 +179,21 @@ * @param callback */ public static void sendPong(final ByteBuffer data, final WebSocketChannel wsChannel, final WebSocketCallback callback) { - sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.PONG, wsChannel, callback); + sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.PONG, wsChannel, callback, -1); } + /** + * Sends a complete pong message, invoking the callback when complete + * + * @param data + * @param wsChannel + * @param callback + */ + public static void sendPong(final ByteBuffer data, final WebSocketChannel wsChannel, final WebSocketCallback callback, long timeoutmillis) { + sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.PONG, wsChannel, callback, timeoutmillis); + } + /** * Sends a complete pong message, invoking the callback when complete * @@ -103,10 +202,20 @@ * @param callback */ public static void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback callback) { - sendInternal(data, WebSocketFrameType.PONG, wsChannel, callback); + sendInternal(data, WebSocketFrameType.PONG, wsChannel, callback, -1); } /** + * Sends a complete pong message, invoking the callback when complete + * + * @param data + * @param wsChannel + * @param callback + */ + public static void sendPong(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback callback, long timeoutmillis) { + sendInternal(data, WebSocketFrameType.PONG, wsChannel, callback, timeoutmillis); + } + /** * Sends a complete pong message using blocking IO * * @param data @@ -134,7 +243,7 @@ * @param callback */ public static void sendBinary(final ByteBuffer data, final WebSocketChannel wsChannel, final WebSocketCallback callback) { - sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.BINARY, wsChannel, callback); + sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.BINARY, wsChannel, callback, -1); } /** @@ -144,22 +253,44 @@ * @param wsChannel * @param callback */ + public static void sendBinary(final ByteBuffer data, final WebSocketChannel wsChannel, final WebSocketCallback callback, long timeoutmillis) { + sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.BINARY, wsChannel, callback, timeoutmillis); + } + + /** + * Sends a complete text message, invoking the callback when complete + * + * @param data + * @param wsChannel + * @param callback + */ public static void sendBinary(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback callback) { - sendInternal(data, WebSocketFrameType.BINARY, wsChannel, callback); + sendInternal(data, WebSocketFrameType.BINARY, wsChannel, callback, -1); } /** * Sends a complete text message, invoking the callback when complete * * @param data * @param wsChannel + * @param callback */ + public static void sendBinary(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback callback, long timeoutmillis) { + sendInternal(data, WebSocketFrameType.BINARY, wsChannel, callback, timeoutmillis); + } + + /** + * Sends a complete binary message using blocking IO + * + * @param data + * @param wsChannel + */ public static void sendBinaryBlocking(final ByteBuffer data, final WebSocketChannel wsChannel) throws IOException { sendBlockingInternal(new ByteBuffer[]{data}, WebSocketFrameType.BINARY, wsChannel); } /** - * Sends a complete text message, invoking the callback when complete + * Sends a complete binary message using blocking IO * * @param data * @param wsChannel @@ -176,7 +307,8 @@ * @param callback */ public static void sendClose(final ByteBuffer data, final WebSocketChannel wsChannel, final WebSocketCallback callback) { - sendInternal(new ByteBuffer[]{data}, WebSocketFrameType.CLOSE, wsChannel, callback); + CloseMessage sm = new CloseMessage(data); + sendClose(sm, wsChannel, callback); } /** @@ -187,18 +319,63 @@ * @param callback */ public static void sendClose(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback callback) { - sendInternal(data, WebSocketFrameType.CLOSE, wsChannel, callback); + CloseMessage sm = new CloseMessage(data); + sendClose(sm, wsChannel, callback); } /** * Sends a complete close message, invoking the callback when complete * + * @param code The close code + * @param wsChannel + * @param callback + */ + public static void sendClose(final int code, String reason, final WebSocketChannel wsChannel, final WebSocketCallback callback) { + sendClose(new CloseMessage(code, reason), wsChannel, callback); + } + + /** + * Sends a complete close message, invoking the callback when complete + * + * @param closeMessage The close message + * @param wsChannel + * @param callback + */ + public static void sendClose(final CloseMessage closeMessage, final WebSocketChannel wsChannel, final WebSocketCallback callback) { + wsChannel.setCloseCode(closeMessage.getCode()); + wsChannel.setCloseReason(closeMessage.getReason()); + sendInternal(new ByteBuffer[]{closeMessage.toByteBuffer()}, WebSocketFrameType.CLOSE, wsChannel, callback, -1); + } + + /** + * Sends a complete close message, invoking the callback when complete + * + * @param closeMessage the close message + * @param wsChannel + */ + public static void sendCloseBlocking(final CloseMessage closeMessage, final WebSocketChannel wsChannel) throws IOException { + wsChannel.setCloseReason(closeMessage.getReason()); + wsChannel.setCloseCode(closeMessage.getCode()); + sendBlockingInternal(new ByteBuffer[]{closeMessage.toByteBuffer()}, WebSocketFrameType.CLOSE, wsChannel); + } + /** + * Sends a complete close message, invoking the callback when complete + * + * @param code + * @param wsChannel + */ + public static void sendCloseBlocking(final int code, String reason, final WebSocketChannel wsChannel) throws IOException { + sendCloseBlocking(new CloseMessage(code, reason), wsChannel); + } + /** + * Sends a complete close message, invoking the callback when complete + * * @param data * @param wsChannel */ public static void sendCloseBlocking(final ByteBuffer data, final WebSocketChannel wsChannel) throws IOException { - sendBlockingInternal(new ByteBuffer[]{data}, WebSocketFrameType.CLOSE, wsChannel); + sendCloseBlocking(new CloseMessage(data), wsChannel); } /** @@ -208,14 +385,14 @@ * @param wsChannel */ public static void sendCloseBlocking(final ByteBuffer[] data, final WebSocketChannel wsChannel) throws IOException { - sendBlockingInternal(data, WebSocketFrameType.CLOSE, wsChannel); + sendCloseBlocking(new CloseMessage(data), wsChannel); } - private static void sendInternal(final ByteBuffer[] data, WebSocketFrameType type, final WebSocketChannel wsChannel, final WebSocketCallback callback) { + private static void sendInternal(final ByteBuffer[] data, WebSocketFrameType type, final WebSocketChannel wsChannel, final WebSocketCallback callback, long timeoutmillis) { try { long totalData = Buffers.remaining(data); StreamSinkFrameChannel channel = wsChannel.send(type, totalData); - sendData(data, wsChannel, callback, channel, null); + sendData(data, wsChannel, callback, channel, null, timeoutmillis); } catch (IOException e) { if (callback != null) { callback.onError(wsChannel, null, e); @@ -225,7 +402,7 @@ } } - private static void sendData(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback callback, StreamSinkFrameChannel channel, final T context) throws IOException { + private static void sendData(final ByteBuffer[] data, final WebSocketChannel wsChannel, final WebSocketCallback callback, StreamSinkFrameChannel channel, final T context, long timeoutmillis) throws IOException { boolean hasRemaining = true; while (hasRemaining) { long res = channel.write(data); @@ -247,17 +424,20 @@ } while (Buffers.hasRemaining(data)); channel.suspendWrites(); try { - flushChannelAsync(wsChannel, callback, channel, context); + flushChannelAsync(wsChannel, callback, channel, context, -1);//timeout has already been setup } catch (IOException e) { handleIoException(channel, e, callback, context, wsChannel); } } }); channel.resumeWrites(); + if(timeoutmillis > 0) { + setupTimeout(channel, timeoutmillis); + } return; } } - flushChannelAsync(wsChannel, callback, channel, context); + flushChannelAsync(wsChannel, callback, channel, context, timeoutmillis); } private static void handleIoException(StreamSinkFrameChannel channel, IOException e, WebSocketCallback callback, T context, WebSocketChannel wsChannel) { @@ -268,7 +448,7 @@ channel.suspendWrites(); } - private static void flushChannelAsync(final WebSocketChannel wsChannel, final WebSocketCallback callback, StreamSinkFrameChannel channel, final T context) throws IOException { + private static void flushChannelAsync(final WebSocketChannel wsChannel, final WebSocketCallback callback, StreamSinkFrameChannel channel, final T context, long timeoutmillis) throws IOException { final WebSocketFrameType type = channel.getType(); channel.shutdownWrites(); if (!channel.flush()) { @@ -295,6 +475,9 @@ } } )); + if(timeoutmillis > 0) { + setupTimeout(channel, timeoutmillis); + } channel.resumeWrites(); return; } @@ -306,6 +489,23 @@ } } + private static void setupTimeout(final StreamSinkFrameChannel channel, long timeoutmillis) { + final XnioExecutor.Key key = channel.getIoThread().executeAfter(new Runnable() { + @Override + public void run() { + if (channel.isOpen()) { + IoUtils.safeClose(channel); + } + } + }, timeoutmillis, TimeUnit.MILLISECONDS); + channel.getCloseSetter().set(new ChannelListener() { + @Override + public void handleEvent(StreamSinkFrameChannel channel) { + key.remove(); + } + }); + } + private static void sendBlockingInternal(final ByteBuffer[] data, WebSocketFrameType type, final WebSocketChannel wsChannel) throws IOException { long totalData = Buffers.remaining(data); StreamSinkFrameChannel channel = wsChannel.send(type, totalData); Index: 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunction.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/function/Attic/ChannelFunction.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunction.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunction.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.function; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionFileChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/function/Attic/ChannelFunctionFileChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionFileChannel.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionFileChannel.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.function; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionReadableByteChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/function/Attic/ChannelFunctionReadableByteChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionReadableByteChannel.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionReadableByteChannel.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.function; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionStreamSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/function/Attic/ChannelFunctionStreamSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionStreamSourceChannel.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionStreamSourceChannel.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.function; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionWritableByteChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/function/Attic/ChannelFunctionWritableByteChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionWritableByteChannel.java 8 Sep 2014 10:52:21 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/function/ChannelFunctionWritableByteChannel.java 25 Nov 2014 10:46:59 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.function; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/Handshake.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/Attic/Handshake.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/Handshake.java 8 Sep 2014 10:52:22 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/Handshake.java 25 Nov 2014 10:47:02 -0000 1.1.2.3 @@ -1,22 +1,25 @@ /* - * Copyright 2012 JBoss, by Red Hat, Inc + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol; import io.undertow.util.Headers; +import io.undertow.websockets.WebSocketExtension; import io.undertow.websockets.core.WebSocketChannel; import io.undertow.websockets.core.WebSocketVersion; import io.undertow.websockets.spi.WebSocketHttpExchange; @@ -25,6 +28,9 @@ import org.xnio.StreamConnection; import java.nio.ByteBuffer; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; import java.util.Set; import java.util.regex.Pattern; @@ -39,7 +45,7 @@ private final String magicNumber; protected final Set subprotocols; private static final byte[] EMPTY = new byte[0]; - private static final Pattern PATTERN = Pattern.compile(","); + private static final Pattern PATTERN = Pattern.compile("\\s*,\\s*"); protected Handshake(WebSocketVersion version, String hashAlgorithm, String magicNumber, final Set subprotocols) { this.version = version; @@ -154,12 +160,37 @@ String[] requestedSubprotocolArray = PATTERN.split(requestedSubprotocols); String subProtocol = supportedSubprotols(requestedSubprotocolArray); - if (subProtocol != null) { + if (subProtocol != null && !subProtocol.isEmpty()) { exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING, subProtocol); } } + + protected final void selectExtensions(final WebSocketHttpExchange exchange) { + List requestedExtensions = WebSocketExtension.parse(exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING)); + List extensions = selectedExtension(requestedExtensions); + if (extensions != null && !extensions.isEmpty()) { + StringBuilder sb = new StringBuilder(); + Iterator it = extensions.iterator(); + while (it.hasNext()) { + WebSocketExtension next = it.next(); + sb.append(next.getName()); + for (WebSocketExtension.Parameter param : next.getParameters()) { + sb.append("; "); + sb.append(param.getName()); + sb.append("="); + sb.append(param.getValue()); + } + if (it.hasNext()) { + sb.append(", "); + } + } + exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING, sb.toString()); + } + + } + protected String supportedSubprotols(String[] requestedSubprotocolArray) { for (String p : requestedSubprotocolArray) { String requestedSubprotocol = p.trim(); @@ -172,4 +203,8 @@ } return null; } + + protected List selectedExtension(List extensionList) { + return Collections.emptyList(); + } } Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Base64.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/Base64.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Base64.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Base64.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,14 +9,16 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; +import io.undertow.UndertowLogger; + /** *

    * Encodes and decodes to and from Base64 notation. @@ -1174,7 +1176,7 @@ } // end try catch (java.io.IOException e) { - e.printStackTrace(); + UndertowLogger.REQUEST_IO_LOGGER.ioException(e); // Just return originally-decoded bytes } // end catch finally { Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Hybi07Handshake.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/Hybi07Handshake.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Hybi07Handshake.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Hybi07Handshake.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,17 +1,19 @@ /* - * Copyright 2012 JBoss, by Red Hat, Inc + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; @@ -74,6 +76,7 @@ exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_ORIGIN_STRING, origin); } selectSubprotocol(exchange); + selectExtensions(exchange); exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_LOCATION_STRING, getWebSocketLocation(exchange)); final String key = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_KEY_STRING); @@ -93,12 +96,11 @@ final String concat = nonceBase64.trim() + getMagicNumber(); final MessageDigest digest = MessageDigest.getInstance(getHashAlgorithm()); digest.update(concat.getBytes(WebSocketUtils.UTF_8)); - final String result = Base64.encodeBytes(digest.digest()).trim(); - return result; + return Base64.encodeBytes(digest.digest()).trim(); } @Override public WebSocketChannel createChannel(WebSocketHttpExchange exchange, final StreamConnection channel, final Pool pool) { - return new WebSocket07Channel(channel, pool, getWebSocketLocation(exchange), exchange.getResponseHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING), false, allowExtensions); + return new WebSocket07Channel(channel, pool, getWebSocketLocation(exchange), exchange.getResponseHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING), false, allowExtensions, exchange.getPeerConnections()); } } Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Masker.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/Masker.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Masker.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Masker.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/UTF8Checker.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/UTF8Checker.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/UTF8Checker.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/UTF8Checker.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07BinaryFrameSinkChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07BinaryFrameSinkChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07BinaryFrameSinkChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07BinaryFrameSinkChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07BinaryFrameSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07BinaryFrameSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07BinaryFrameSourceChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07BinaryFrameSourceChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07Channel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07Channel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07Channel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07Channel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; @@ -22,17 +22,21 @@ import io.undertow.websockets.core.StreamSourceFrameChannel; import io.undertow.websockets.core.WebSocketChannel; import io.undertow.websockets.core.WebSocketException; +import io.undertow.websockets.core.WebSocketFrame; import io.undertow.websockets.core.WebSocketFrameCorruptedException; import io.undertow.websockets.core.WebSocketFrameType; import io.undertow.websockets.core.WebSocketLogger; import io.undertow.websockets.core.WebSocketMessages; import io.undertow.websockets.core.WebSocketVersion; import io.undertow.websockets.core.function.ChannelFunction; + +import org.xnio.IoUtils; import org.xnio.Pool; import org.xnio.Pooled; import org.xnio.StreamConnection; import java.nio.ByteBuffer; +import java.util.Set; /** @@ -83,8 +87,8 @@ * @param wsUrl The url for which the {@link WebSocket07Channel} was created. */ public WebSocket07Channel(StreamConnection channel, Pool bufferPool, - String wsUrl, String subProtocol, final boolean client, boolean allowExtensions) { - super(channel, bufferPool, WebSocketVersion.V08, wsUrl, subProtocol, client, allowExtensions); + String wsUrl, String subProtocol, final boolean client, boolean allowExtensions, Set openConnections) { + super(channel, bufferPool, WebSocketVersion.V08, wsUrl, subProtocol, client, allowExtensions, openConnections); } @Override @@ -98,6 +102,11 @@ } @Override + protected void closeSubChannels() { + IoUtils.safeClose(fragmentedChannel); + } + + @Override protected StreamSinkFrameChannel createStreamSinkChannel(WebSocketFrameType type, long payloadSize) { switch (type) { case TEXT: @@ -115,7 +124,7 @@ } } - class WebSocketFrameHeader implements PartialFrame { + class WebSocketFrameHeader implements WebSocketFrame { private boolean frameFinalFlag; private int frameRsv; @@ -330,6 +339,7 @@ } b = buffer.get(); lengthBuffer.put(b); + state = State.READING_EXTENDED_SIZE8; case READING_EXTENDED_SIZE8: if (!buffer.hasRemaining()) { return; @@ -345,6 +355,7 @@ state = State.DONE; break; } + state = State.READING_MASK_1; case READING_MASK_1: if (!buffer.hasRemaining()) { return; @@ -456,11 +467,17 @@ StreamSourceFrameChannel ret = fragmentedChannel; if(frameFinalFlag) { fragmentedChannel = null; - ret.finalFrame(); //TODO: should be in handle header data, maybe } return ret; } return null; } + + @Override + public boolean isFinalFragment() { + return frameFinalFlag; + } } + + } Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07CloseFrameSinkChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07CloseFrameSinkChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07CloseFrameSinkChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07CloseFrameSinkChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07CloseFrameSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07CloseFrameSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07CloseFrameSourceChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07CloseFrameSourceChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07ContinuationFrameSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07ContinuationFrameSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07ContinuationFrameSourceChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07ContinuationFrameSourceChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07FrameSinkChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07FrameSinkChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07FrameSinkChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07FrameSinkChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,14 +9,15 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; +import io.undertow.server.protocol.framed.SendFrameHeader; import io.undertow.websockets.core.StreamSinkFrameChannel; import io.undertow.websockets.core.WebSocketFrameType; import io.undertow.websockets.core.WebSocketMessages; @@ -55,10 +56,22 @@ } @Override - protected void handleFlushComplete() { + protected void handleFlushComplete(boolean finalFrame) { dataWritten = true; + if(masker != null) { + masker.setMaskingKey(maskingKey); + } } + + /** + * If a stream sink channel is closed while in the middle of sending fragmented data we need to close the connection. + * @throws IOException + */ + protected void channelForciblyClosed() throws IOException { + getChannel().sendClose(); + } + private byte opCode() { if(dataWritten) { return WebSocket07Channel.OPCODE_CONT; @@ -82,7 +95,7 @@ } @Override - protected Pooled createFrameHeader() { + protected SendFrameHeader createFrameHeader() { if(payloadSize >= 0 && dataWritten) { //for fixed length we don't need more than one header return null; @@ -129,7 +142,7 @@ header.put((byte)((maskingKey & 0xFF))); } header.flip(); - return start; + return new SendFrameHeader(0, start); } @Override Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PingFrameSinkChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07PingFrameSinkChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PingFrameSinkChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PingFrameSinkChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PingFrameSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07PingFrameSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PingFrameSourceChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PingFrameSourceChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PongFrameSinkChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07PongFrameSinkChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PongFrameSinkChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PongFrameSinkChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PongFrameSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07PongFrameSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PongFrameSourceChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07PongFrameSourceChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07TextFrameSinkChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07TextFrameSinkChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07TextFrameSinkChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07TextFrameSinkChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07TextFrameSourceChannel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/Attic/WebSocket07TextFrameSourceChannel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07TextFrameSourceChannel.java 8 Sep 2014 10:52:14 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version07/WebSocket07TextFrameSourceChannel.java 25 Nov 2014 10:46:58 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,11 +9,11 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version07; Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version08/Hybi08Handshake.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version08/Attic/Hybi08Handshake.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version08/Hybi08Handshake.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version08/Hybi08Handshake.java 25 Nov 2014 10:47:02 -0000 1.1.2.3 @@ -1,17 +1,19 @@ /* - * Copyright 2012 JBoss, by Red Hat, Inc + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version08; @@ -45,7 +47,7 @@ @Override public WebSocketChannel createChannel(final WebSocketHttpExchange exchange, final StreamConnection channel, final Pool pool) { - return new WebSocket08Channel(channel, pool, getWebSocketLocation(exchange), exchange.getResponseHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING), false, allowExtensions); + return new WebSocket08Channel(channel, pool, getWebSocketLocation(exchange), exchange.getResponseHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING), false, allowExtensions, exchange.getPeerConnections()); } } Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version08/WebSocket08Channel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version08/Attic/WebSocket08Channel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version08/WebSocket08Channel.java 8 Sep 2014 10:52:19 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version08/WebSocket08Channel.java 25 Nov 2014 10:47:02 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,20 +9,22 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version08; +import io.undertow.websockets.core.WebSocketChannel; import io.undertow.websockets.core.WebSocketVersion; import io.undertow.websockets.core.protocol.version07.WebSocket07Channel; import org.xnio.Pool; import org.xnio.StreamConnection; import java.nio.ByteBuffer; +import java.util.Set; /** @@ -31,8 +33,8 @@ * @author Norman Maurer */ public class WebSocket08Channel extends WebSocket07Channel { - public WebSocket08Channel(StreamConnection channel, Pool bufferPool, String wsUrl, String subProtocols, final boolean client, boolean allowExtensions) { - super(channel, bufferPool, wsUrl, subProtocols, client, allowExtensions); + public WebSocket08Channel(StreamConnection channel, Pool bufferPool, String wsUrl, String subProtocols, final boolean client, boolean allowExtensions, Set openConnections) { + super(channel, bufferPool, wsUrl, subProtocols, client, allowExtensions, openConnections); } @Override Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version13/Hybi13Handshake.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version13/Attic/Hybi13Handshake.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version13/Hybi13Handshake.java 8 Sep 2014 10:52:22 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version13/Hybi13Handshake.java 25 Nov 2014 10:47:00 -0000 1.1.2.3 @@ -1,17 +1,19 @@ /* - * Copyright 2012 JBoss, by Red Hat, Inc + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version13; @@ -52,6 +54,7 @@ exchange.setResponseHeader(Headers.ORIGIN_STRING, origin); } selectSubprotocol(exchange); + selectExtensions(exchange); exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_LOCATION_STRING, getWebSocketLocation(exchange)); final String key = exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_KEY_STRING); @@ -68,6 +71,6 @@ @Override public WebSocketChannel createChannel(WebSocketHttpExchange exchange, final StreamConnection channel, final Pool pool) { - return new WebSocket13Channel(channel, pool, getWebSocketLocation(exchange), exchange.getResponseHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING), false, allowExtensions); + return new WebSocket13Channel(channel, pool, getWebSocketLocation(exchange), exchange.getResponseHeader(Headers.SEC_WEB_SOCKET_PROTOCOL_STRING), false, allowExtensions, exchange.getPeerConnections()); } } Index: 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version13/WebSocket13Channel.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version13/Attic/WebSocket13Channel.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version13/WebSocket13Channel.java 8 Sep 2014 10:52:22 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/core/protocol/version13/WebSocket13Channel.java 25 Nov 2014 10:47:01 -0000 1.1.2.3 @@ -1,6 +1,6 @@ /* * JBoss, Home of Professional Open Source. - * Copyright 2012 Red Hat, Inc., and individual contributors + * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -9,20 +9,22 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package io.undertow.websockets.core.protocol.version13; +import io.undertow.websockets.core.WebSocketChannel; import io.undertow.websockets.core.WebSocketVersion; import io.undertow.websockets.core.protocol.version07.WebSocket07Channel; import org.xnio.Pool; import org.xnio.StreamConnection; import java.nio.ByteBuffer; +import java.util.Set; /** * @@ -31,8 +33,8 @@ * @author Norman Maurer */ public class WebSocket13Channel extends WebSocket07Channel { - public WebSocket13Channel(StreamConnection channel, Pool bufferPool, String wsUrl, String subProtocols, final boolean client, boolean allowExtensions) { - super(channel, bufferPool, wsUrl, subProtocols, client, allowExtensions); + public WebSocket13Channel(StreamConnection channel, Pool bufferPool, String wsUrl, String subProtocols, final boolean client, boolean allowExtensions, Set openConnections) { + super(channel, bufferPool, wsUrl, subProtocols, client, allowExtensions, openConnections); } @Override Index: 3rdParty_sources/undertow/io/undertow/websockets/spi/AsyncWebSocketHttpServerExchange.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/spi/Attic/AsyncWebSocketHttpServerExchange.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/spi/AsyncWebSocketHttpServerExchange.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/spi/AsyncWebSocketHttpServerExchange.java 25 Nov 2014 10:47:02 -0000 1.1.2.3 @@ -1,3 +1,21 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.spi; import io.undertow.UndertowLogger; @@ -7,9 +25,12 @@ import io.undertow.security.idm.Account; import io.undertow.server.HttpServerExchange; import io.undertow.server.HttpUpgradeListener; +import io.undertow.server.session.SessionConfig; +import io.undertow.server.session.SessionManager; import io.undertow.util.AttachmentKey; import io.undertow.util.HeaderMap; import io.undertow.util.HttpString; +import io.undertow.websockets.core.WebSocketChannel; import org.xnio.ChannelListener; import org.xnio.FinishedIoFuture; import org.xnio.FutureResult; @@ -29,6 +50,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.TreeMap; /** * @author Stuart Douglas @@ -37,9 +60,11 @@ private final HttpServerExchange exchange; private Sender sender; + private final Set peerConnections; - public AsyncWebSocketHttpServerExchange(final HttpServerExchange exchange) { + public AsyncWebSocketHttpServerExchange(final HttpServerExchange exchange, Set peerConnections) { this.exchange = exchange; + this.peerConnections = peerConnections; } @@ -60,9 +85,9 @@ @Override public Map> getRequestHeaders() { - Map> headers = new HashMap>(); + Map> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); for (final HttpString header : exchange.getRequestHeaders().getHeaderNames()) { - headers.put(header.toString(), new ArrayList(exchange.getRequestHeaders().get(header))); + headers.put(header.toString(), new ArrayList<>(exchange.getRequestHeaders().get(header))); } return Collections.unmodifiableMap(headers); } @@ -74,9 +99,9 @@ @Override public Map> getResponseHeaders() { - Map> headers = new HashMap>(); + Map> headers = new HashMap<>(); for (final HttpString header : exchange.getResponseHeaders().getHeaderNames()) { - headers.put(header.toString(), new ArrayList(exchange.getResponseHeaders().get(header))); + headers.put(header.toString(), new ArrayList<>(exchange.getResponseHeaders().get(header))); } return Collections.unmodifiableMap(headers); } @@ -105,7 +130,7 @@ if (sender == null) { this.sender = exchange.getResponseSender(); } - final FutureResult future = new FutureResult(); + final FutureResult future = new FutureResult<>(); sender.send(data, new IoCallback() { @Override public void onComplete(final HttpServerExchange exchange, final Sender sender) { @@ -133,10 +158,10 @@ try { res = channel.read(buffer); if (res == -1) { - return new FinishedIoFuture(data.toByteArray()); + return new FinishedIoFuture<>(data.toByteArray()); } else if (res == 0) { //callback - final FutureResult future = new FutureResult(); + final FutureResult future = new FutureResult<>(); channel.getReadSetter().set(new ChannelListener() { @Override public void handleEvent(final StreamSourceChannel channel) { @@ -173,7 +198,7 @@ } } catch (IOException e) { - final FutureResult future = new FutureResult(); + final FutureResult future = new FutureResult<>(); future.setException(e); return future.getIoFuture(); } @@ -203,7 +228,12 @@ @Override public String getRequestURI() { - return exchange.getRequestURI() + exchange.getQueryString(); + String q = exchange.getQueryString(); + if (q == null || q.isEmpty()) { + return exchange.getRequestURI(); + } else { + return exchange.getRequestURI() + "?" + q; + } } @Override @@ -218,14 +248,19 @@ @Override public Object getSession() { + SessionManager sm = exchange.getAttachment(SessionManager.ATTACHMENT_KEY); + SessionConfig sessionCookieConfig = exchange.getAttachment(SessionConfig.ATTACHMENT_KEY); + if(sm != null && sessionCookieConfig != null) { + return sm.getSession(exchange, sessionCookieConfig); + } return null; } @Override public Map> getRequestParameters() { - Map> params = new HashMap>(); + Map> params = new HashMap<>(); for (Map.Entry> param : exchange.getQueryParameters().entrySet()) { - params.put(param.getKey(), new ArrayList(param.getValue())); + params.put(param.getKey(), new ArrayList<>(param.getValue())); } return params; } @@ -255,4 +290,9 @@ } return authenticatedAccount.getRoles().contains(role); } + + @Override + public Set getPeerConnections() { + return peerConnections; + } } Index: 3rdParty_sources/undertow/io/undertow/websockets/spi/BlockingWebSocketHttpServerExchange.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/spi/Attic/BlockingWebSocketHttpServerExchange.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/spi/BlockingWebSocketHttpServerExchange.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/spi/BlockingWebSocketHttpServerExchange.java 25 Nov 2014 10:47:02 -0000 1.1.2.3 @@ -1,6 +1,25 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.spi; import io.undertow.server.HttpServerExchange; +import io.undertow.websockets.core.WebSocketChannel; import org.xnio.FinishedIoFuture; import org.xnio.FutureResult; import org.xnio.IoFuture; @@ -10,6 +29,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; +import java.util.Set; /** * @author Stuart Douglas @@ -19,8 +39,8 @@ private final OutputStream out; private final InputStream in; - public BlockingWebSocketHttpServerExchange(final HttpServerExchange exchange) { - super(exchange); + public BlockingWebSocketHttpServerExchange(final HttpServerExchange exchange, Set peerConnections) { + super(exchange, peerConnections); out = exchange.getOutputStream(); in = exchange.getInputStream(); } @@ -31,9 +51,9 @@ while (data.hasRemaining()) { out.write(data.get()); } - return new FinishedIoFuture(null); + return new FinishedIoFuture<>(null); } catch (IOException e) { - final FutureResult ioFuture = new FutureResult(); + final FutureResult ioFuture = new FutureResult<>(); ioFuture.setException(e); return ioFuture.getIoFuture(); } @@ -48,9 +68,9 @@ while ((r = in.read(buf)) != -1) { data.write(buf, 0, r); } - return new FinishedIoFuture(data.toByteArray()); + return new FinishedIoFuture<>(data.toByteArray()); } catch (IOException e) { - final FutureResult ioFuture = new FutureResult(); + final FutureResult ioFuture = new FutureResult<>(); ioFuture.setException(e); return ioFuture.getIoFuture(); } Index: 3rdParty_sources/undertow/io/undertow/websockets/spi/WebSocketHttpExchange.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/undertow/io/undertow/websockets/spi/Attic/WebSocketHttpExchange.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- 3rdParty_sources/undertow/io/undertow/websockets/spi/WebSocketHttpExchange.java 8 Sep 2014 10:52:12 -0000 1.1.2.2 +++ 3rdParty_sources/undertow/io/undertow/websockets/spi/WebSocketHttpExchange.java 25 Nov 2014 10:47:02 -0000 1.1.2.3 @@ -1,7 +1,26 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2014 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.undertow.websockets.spi; import io.undertow.server.HttpUpgradeListener; import io.undertow.util.AttachmentKey; +import io.undertow.websockets.core.WebSocketChannel; import org.xnio.IoFuture; import org.xnio.Pool; @@ -10,6 +29,7 @@ import java.security.Principal; import java.util.List; import java.util.Map; +import java.util.Set; /** @@ -138,4 +158,6 @@ Principal getUserPrincipal(); boolean isUserInRole(String role); + + Set getPeerConnections(); } Index: lams_admin/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_admin/.classpath,v diff -u -r1.10.2.8 -r1.10.2.9 --- lams_admin/.classpath 18 Nov 2014 16:11:46 -0000 1.10.2.8 +++ lams_admin/.classpath 25 Nov 2014 10:47:34 -0000 1.10.2.9 @@ -10,8 +10,8 @@ - - + + Index: lams_build/unix.properties =================================================================== RCS file: /usr/local/cvsroot/lams_build/unix.properties,v diff -u -r1.19.2.4 -r1.19.2.5 --- lams_build/unix.properties 18 Nov 2014 16:12:07 -0000 1.19.2.4 +++ lams_build/unix.properties 25 Nov 2014 10:47:33 -0000 1.19.2.5 @@ -33,4 +33,4 @@ contentrepository.base=/var/opt/lams #JBoss deploy directory (Unix) -server.home=/usr/local/wildfly-9/ \ No newline at end of file +server.home=/usr/local/wildfly-8.2/ \ No newline at end of file Index: lams_build/windows.properties =================================================================== RCS file: /usr/local/cvsroot/lams_build/windows.properties,v diff -u -r1.20.2.4 -r1.20.2.5 --- lams_build/windows.properties 18 Nov 2014 16:12:07 -0000 1.20.2.4 +++ lams_build/windows.properties 25 Nov 2014 10:47:33 -0000 1.20.2.5 @@ -32,4 +32,4 @@ contentrepository.base=C:/lams #JBoss deploy directory (Windows) -server.home=C:/wildfly-9/ \ No newline at end of file +server.home=C:/wildfly-8.2/ \ No newline at end of file Index: lams_build/conf/standalone.xml =================================================================== RCS file: /usr/local/cvsroot/lams_build/conf/Attic/standalone.xml,v diff -u -r1.1.2.22 -r1.1.2.23 --- lams_build/conf/standalone.xml 19 Nov 2014 20:41:52 -0000 1.1.2.22 +++ lams_build/conf/standalone.xml 25 Nov 2014 10:47:33 -0000 1.1.2.23 @@ -1,6 +1,6 @@ - + - + @@ -16,9 +16,7 @@ - - @@ -71,239 +69,7 @@ - - - - - @db.url.run@ - MySQL - utf8 - true - convertToNull - - - @db.location@ - false - false - 128K - 4 - 256K - 256K - 1M - 16K - 64K - 2K - - TRANSACTION_READ_COMMITTED - - 0 - 0 - 64 - false - false - FailingConnectionOnly - - - @db.username@ - @db.password@ - - - - 5 - 0 - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${jboss.bind.address:127.0.0.1} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - + @@ -475,6 +241,232 @@ + + + + @db.url.run@ + MySQL + utf8 + true + convertToNull + + + @db.location@ + false + false + 128K + 4 + 256K + 256K + 1M + 16K + 64K + 2K + + TRANSACTION_READ_COMMITTED + + 0 + 0 + 64 + false + false + FailingConnectionOnly + + + @db.username@ + @db.password@ + + + + false + false + false + + + 5 + 0 + + + false + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${jboss.bind.address:127.0.0.1} + + + + + + + + + Index: lams_central/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_central/.classpath,v diff -u -r1.20.2.15 -r1.20.2.16 --- lams_central/.classpath 18 Nov 2014 16:11:39 -0000 1.20.2.15 +++ lams_central/.classpath 25 Nov 2014 10:46:34 -0000 1.20.2.16 @@ -17,14 +17,14 @@ - + - - + + @@ -34,7 +34,7 @@ - - + + Index: lams_common/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_common/.classpath,v diff -u -r1.25.2.22 -r1.25.2.23 --- lams_common/.classpath 18 Nov 2014 16:12:00 -0000 1.25.2.22 +++ lams_common/.classpath 25 Nov 2014 10:46:34 -0000 1.25.2.23 @@ -16,15 +16,15 @@ - - - + + + - + - - + + @@ -39,10 +39,10 @@ - + - - + + Index: lams_contentrepository/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_contentrepository/.classpath,v diff -u -r1.21.2.7 -r1.21.2.8 --- lams_contentrepository/.classpath 18 Nov 2014 16:11:47 -0000 1.21.2.7 +++ lams_contentrepository/.classpath 25 Nov 2014 10:47:16 -0000 1.21.2.8 @@ -14,7 +14,7 @@ - + Index: lams_gradebook/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_gradebook/.classpath,v diff -u -r1.4.2.4 -r1.4.2.5 --- lams_gradebook/.classpath 18 Nov 2014 16:12:05 -0000 1.4.2.4 +++ lams_gradebook/.classpath 25 Nov 2014 10:47:25 -0000 1.4.2.5 @@ -10,7 +10,7 @@ - + Index: lams_learning/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_learning/.classpath,v diff -u -r1.12.2.7 -r1.12.2.8 --- lams_learning/.classpath 18 Nov 2014 16:11:36 -0000 1.12.2.7 +++ lams_learning/.classpath 25 Nov 2014 10:47:04 -0000 1.12.2.8 @@ -10,7 +10,7 @@ - + Index: lams_monitoring/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/.classpath,v diff -u -r1.16.2.7 -r1.16.2.8 --- lams_monitoring/.classpath 18 Nov 2014 16:11:34 -0000 1.16.2.7 +++ lams_monitoring/.classpath 25 Nov 2014 10:47:09 -0000 1.16.2.8 @@ -11,7 +11,7 @@ - + Index: lams_tool_assessment/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_assessment/.classpath,v diff -u -r1.11.2.10 -r1.11.2.11 --- lams_tool_assessment/.classpath 18 Nov 2014 16:12:06 -0000 1.11.2.10 +++ lams_tool_assessment/.classpath 25 Nov 2014 10:47:04 -0000 1.11.2.11 @@ -12,7 +12,7 @@ - + @@ -25,7 +25,7 @@ - + Index: lams_tool_bbb/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_bbb/.classpath,v diff -u -r1.6.2.9 -r1.6.2.10 --- lams_tool_bbb/.classpath 18 Nov 2014 16:11:58 -0000 1.6.2.9 +++ lams_tool_bbb/.classpath 25 Nov 2014 10:47:38 -0000 1.6.2.10 @@ -19,7 +19,7 @@ - + Index: lams_tool_chat/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_chat/.classpath,v diff -u -r1.11.2.9 -r1.11.2.10 --- lams_tool_chat/.classpath 18 Nov 2014 16:11:35 -0000 1.11.2.9 +++ lams_tool_chat/.classpath 25 Nov 2014 10:47:26 -0000 1.11.2.10 @@ -18,12 +18,12 @@ - + - + Index: lams_tool_daco/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_daco/.classpath,v diff -u -r1.9.2.9 -r1.9.2.10 --- lams_tool_daco/.classpath 18 Nov 2014 16:11:55 -0000 1.9.2.9 +++ lams_tool_daco/.classpath 25 Nov 2014 10:47:05 -0000 1.9.2.10 @@ -18,12 +18,12 @@ - + - + Index: lams_tool_eadventure/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_eadventure/.classpath,v diff -u -r1.8.2.10 -r1.8.2.11 --- lams_tool_eadventure/.classpath 18 Nov 2014 16:12:08 -0000 1.8.2.10 +++ lams_tool_eadventure/.classpath 25 Nov 2014 10:47:17 -0000 1.8.2.11 @@ -9,7 +9,7 @@ - + @@ -26,6 +26,6 @@ - + Index: lams_tool_forum/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/.classpath,v diff -u -r1.20.2.10 -r1.20.2.11 --- lams_tool_forum/.classpath 18 Nov 2014 16:11:45 -0000 1.20.2.10 +++ lams_tool_forum/.classpath 25 Nov 2014 10:47:24 -0000 1.20.2.11 @@ -17,14 +17,14 @@ - + - + Index: lams_tool_gmap/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_gmap/.classpath,v diff -u -r1.8.2.7 -r1.8.2.8 --- lams_tool_gmap/.classpath 18 Nov 2014 16:12:11 -0000 1.8.2.7 +++ lams_tool_gmap/.classpath 25 Nov 2014 10:47:08 -0000 1.8.2.8 @@ -20,7 +20,7 @@ - + Index: lams_tool_images/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_images/.classpath,v diff -u -r1.6.2.9 -r1.6.2.10 --- lams_tool_images/.classpath 18 Nov 2014 16:12:13 -0000 1.6.2.9 +++ lams_tool_images/.classpath 25 Nov 2014 10:47:11 -0000 1.6.2.10 @@ -20,13 +20,13 @@ - + - + Index: lams_tool_imscc/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_imscc/.classpath,v diff -u -r1.7.2.10 -r1.7.2.11 --- lams_tool_imscc/.classpath 18 Nov 2014 16:12:09 -0000 1.7.2.10 +++ lams_tool_imscc/.classpath 25 Nov 2014 10:47:16 -0000 1.7.2.11 @@ -13,7 +13,7 @@ - + @@ -26,6 +26,6 @@ - + Index: lams_tool_kaltura/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_kaltura/.classpath,v diff -u -r1.2.2.8 -r1.2.2.9 --- lams_tool_kaltura/.classpath 18 Nov 2014 16:12:01 -0000 1.2.2.8 +++ lams_tool_kaltura/.classpath 25 Nov 2014 10:47:37 -0000 1.2.2.9 @@ -19,7 +19,7 @@ - + Index: lams_tool_lamc/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/.classpath,v diff -u -r1.12.2.8 -r1.12.2.9 --- lams_tool_lamc/.classpath 18 Nov 2014 16:11:51 -0000 1.12.2.8 +++ lams_tool_lamc/.classpath 25 Nov 2014 10:47:27 -0000 1.12.2.9 @@ -18,7 +18,7 @@ - + Index: lams_tool_laqa/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/.classpath,v diff -u -r1.16.2.8 -r1.16.2.9 --- lams_tool_laqa/.classpath 18 Nov 2014 16:11:44 -0000 1.16.2.8 +++ lams_tool_laqa/.classpath 25 Nov 2014 10:47:28 -0000 1.16.2.9 @@ -18,7 +18,7 @@ - + Index: lams_tool_larsrc/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/.classpath,v diff -u -r1.13.2.10 -r1.13.2.11 --- lams_tool_larsrc/.classpath 18 Nov 2014 16:12:03 -0000 1.13.2.10 +++ lams_tool_larsrc/.classpath 25 Nov 2014 10:47:36 -0000 1.13.2.11 @@ -18,13 +18,13 @@ - + - + Index: lams_tool_leader/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_leader/.classpath,v diff -u -r1.1.2.7 -r1.1.2.8 --- lams_tool_leader/.classpath 18 Nov 2014 16:11:42 -0000 1.1.2.7 +++ lams_tool_leader/.classpath 25 Nov 2014 10:47:31 -0000 1.1.2.8 @@ -19,7 +19,7 @@ - + Index: lams_tool_mindmap/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/.classpath,v diff -u -r1.4.2.7 -r1.4.2.8 --- lams_tool_mindmap/.classpath 18 Nov 2014 16:11:48 -0000 1.4.2.7 +++ lams_tool_mindmap/.classpath 25 Nov 2014 10:47:40 -0000 1.4.2.8 @@ -18,7 +18,7 @@ - + Index: lams_tool_nb/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/.classpath,v diff -u -r1.12.2.6 -r1.12.2.7 --- lams_tool_nb/.classpath 18 Nov 2014 16:11:53 -0000 1.12.2.6 +++ lams_tool_nb/.classpath 25 Nov 2014 10:47:22 -0000 1.12.2.7 @@ -18,6 +18,6 @@ - + Index: lams_tool_notebook/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/.classpath,v diff -u -r1.12.2.7 -r1.12.2.8 --- lams_tool_notebook/.classpath 18 Nov 2014 16:12:12 -0000 1.12.2.7 +++ lams_tool_notebook/.classpath 25 Nov 2014 10:47:30 -0000 1.12.2.8 @@ -19,7 +19,7 @@ - + Index: lams_tool_pixlr/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_pixlr/.classpath,v diff -u -r1.4.2.7 -r1.4.2.8 --- lams_tool_pixlr/.classpath 18 Nov 2014 16:11:48 -0000 1.4.2.7 +++ lams_tool_pixlr/.classpath 25 Nov 2014 10:47:06 -0000 1.4.2.8 @@ -19,7 +19,7 @@ - + Index: lams_tool_sbmt/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_sbmt/.classpath,v diff -u -r1.23.2.10 -r1.23.2.11 --- lams_tool_sbmt/.classpath 18 Nov 2014 16:11:42 -0000 1.23.2.10 +++ lams_tool_sbmt/.classpath 25 Nov 2014 10:47:35 -0000 1.23.2.11 @@ -18,14 +18,14 @@ - + - + Index: lams_tool_scratchie/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scratchie/.classpath,v diff -u -r1.6.2.10 -r1.6.2.11 --- lams_tool_scratchie/.classpath 18 Nov 2014 16:11:57 -0000 1.6.2.10 +++ lams_tool_scratchie/.classpath 25 Nov 2014 10:47:15 -0000 1.6.2.11 @@ -11,14 +11,14 @@ - + - + Index: lams_tool_scribe/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/.classpath,v diff -u -r1.6.2.7 -r1.6.2.8 --- lams_tool_scribe/.classpath 18 Nov 2014 16:11:53 -0000 1.6.2.7 +++ lams_tool_scribe/.classpath 25 Nov 2014 10:47:21 -0000 1.6.2.8 @@ -19,7 +19,7 @@ - + Index: lams_tool_spreadsheet/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_spreadsheet/.classpath,v diff -u -r1.8.2.9 -r1.8.2.10 --- lams_tool_spreadsheet/.classpath 18 Nov 2014 16:12:14 -0000 1.8.2.9 +++ lams_tool_spreadsheet/.classpath 25 Nov 2014 10:47:39 -0000 1.8.2.10 @@ -18,13 +18,13 @@ - + - + Index: lams_tool_survey/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/.classpath,v diff -u -r1.9.2.10 -r1.9.2.11 --- lams_tool_survey/.classpath 18 Nov 2014 16:12:10 -0000 1.9.2.10 +++ lams_tool_survey/.classpath 25 Nov 2014 10:47:12 -0000 1.9.2.11 @@ -18,13 +18,13 @@ - + - + Index: lams_tool_task/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_task/.classpath,v diff -u -r1.8.2.9 -r1.8.2.10 --- lams_tool_task/.classpath 18 Nov 2014 16:11:56 -0000 1.8.2.9 +++ lams_tool_task/.classpath 25 Nov 2014 10:47:20 -0000 1.8.2.10 @@ -21,13 +21,13 @@ - + - + Index: lams_tool_videorecorder/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_videorecorder/.classpath,v diff -u -r1.5.2.7 -r1.5.2.8 --- lams_tool_videorecorder/.classpath 18 Nov 2014 16:12:04 -0000 1.5.2.7 +++ lams_tool_videorecorder/.classpath 25 Nov 2014 10:47:32 -0000 1.5.2.8 @@ -20,7 +20,7 @@ - + Index: lams_tool_vote/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/.classpath,v diff -u -r1.10.2.8 -r1.10.2.9 --- lams_tool_vote/.classpath 18 Nov 2014 16:11:38 -0000 1.10.2.8 +++ lams_tool_vote/.classpath 25 Nov 2014 10:47:03 -0000 1.10.2.9 @@ -18,7 +18,7 @@ - + Index: lams_tool_wiki/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wiki/.classpath,v diff -u -r1.9.2.12 -r1.9.2.13 --- lams_tool_wiki/.classpath 18 Nov 2014 16:12:05 -0000 1.9.2.12 +++ lams_tool_wiki/.classpath 25 Nov 2014 10:47:09 -0000 1.9.2.13 @@ -12,7 +12,7 @@ - + Index: lams_tool_wookie/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_wookie/.classpath,v diff -u -r1.3.2.7 -r1.3.2.8 --- lams_tool_wookie/.classpath 18 Nov 2014 16:11:52 -0000 1.3.2.7 +++ lams_tool_wookie/.classpath 25 Nov 2014 10:46:33 -0000 1.3.2.8 @@ -19,7 +19,7 @@ - +