Author: markt Date: Fri Aug 16 15:39:41 2013 New Revision: 1514752 URL: http://svn.apache.org/r1514752 Log: Remove most uses of Java 7 from implementation code
Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/ContainerProvider.java tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/DefaultClientEndpointConfig.java tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/server/DefaultServerEndpointConfig.java tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/server/ServerEndpointConfig.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/BackgroundProcessManager.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/Util.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsSession.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsWebSocketContainer.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerBase.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerPartialBase.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/DefaultServerEndpointConfigurator.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/UpgradeUtil.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/UriTemplate.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsHandshakeRequest.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsSci.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsServerContainer.java tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsWriteTimeout.java Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/ContainerProvider.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/ContainerProvider.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/ContainerProvider.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/ContainerProvider.java Fri Aug 16 15:39:41 2013 @@ -49,8 +49,11 @@ public abstract class ContainerProvider (Class<WebSocketContainer>) Class.forName( DEFAULT_PROVIDER_CLASS_NAME); result = clazz.newInstance(); - } catch (ClassNotFoundException | InstantiationException | - IllegalAccessException e) { + } catch (ClassNotFoundException e) { + // No options left. Just return null. + } catch (InstantiationException e) { + // No options left. Just return null. + } catch (IllegalAccessException e) { // No options left. Just return null. } } Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/DefaultClientEndpointConfig.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/DefaultClientEndpointConfig.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/DefaultClientEndpointConfig.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/DefaultClientEndpointConfig.java Fri Aug 16 15:39:41 2013 @@ -26,7 +26,7 @@ final class DefaultClientEndpointConfig private final List<Extension> extensions; private final List<Class<? extends Encoder>> encoders; private final List<Class<? extends Decoder>> decoders; - private final Map<String,Object> userProperties = new ConcurrentHashMap<>(); + private final Map<String,Object> userProperties = new ConcurrentHashMap<String, Object>(); private final Configurator configurator; Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/server/DefaultServerEndpointConfig.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/server/DefaultServerEndpointConfig.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/server/DefaultServerEndpointConfig.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/server/DefaultServerEndpointConfig.java Fri Aug 16 15:39:41 2013 @@ -36,7 +36,7 @@ final class DefaultServerEndpointConfig private final List<Class<? extends Encoder>> encoders; private final List<Class<? extends Decoder>> decoders; private final Configurator serverEndpointConfigurator; - private final Map<String,Object> userProperties = new ConcurrentHashMap<>(); + private final Map<String,Object> userProperties = new ConcurrentHashMap<String, Object>(); DefaultServerEndpointConfig( Class<?> endpointClass, String path, Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/server/ServerEndpointConfig.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/server/ServerEndpointConfig.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/server/ServerEndpointConfig.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/javax/websocket/server/ServerEndpointConfig.java Fri Aug 16 15:39:41 2013 @@ -175,8 +175,11 @@ public interface ServerEndpointConfig ex (Class<Configurator>) Class.forName( DEFAULT_IMPL_CLASSNAME); result = clazz.newInstance(); - } catch (ClassNotFoundException | InstantiationException | - IllegalAccessException e) { + } catch (ClassNotFoundException e) { + // No options left. Just return null. + } catch (InstantiationException e) { + // No options left. Just return null. + } catch (IllegalAccessException e) { // No options left. Just return null. } } Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java Fri Aug 16 15:39:41 2013 @@ -73,7 +73,7 @@ public class AsyncChannelWrapperSecure i @Override public Future<Integer> read(ByteBuffer dst) { - WrapperFuture<Integer,Void> future = new WrapperFuture<>(); + WrapperFuture<Integer,Void> future = new WrapperFuture<Integer, Void>(); if (!reading.compareAndSet(false, true)) { throw new IllegalStateException(sm.getString( @@ -107,7 +107,7 @@ public class AsyncChannelWrapperSecure i @Override public Future<Integer> write(ByteBuffer src) { - WrapperFuture<Long,Void> inner = new WrapperFuture<>(); + WrapperFuture<Long,Void> inner = new WrapperFuture<Long, Void>(); if (!writing.compareAndSet(false, true)) { throw new IllegalStateException(sm.getString( @@ -153,7 +153,7 @@ public class AsyncChannelWrapperSecure i @Override public Future<Void> handshake() throws SSLException { - WrapperFuture<Void,Void> wFuture = new WrapperFuture<>(); + WrapperFuture<Void,Void> wFuture = new WrapperFuture<Void, Void>(); Thread t = new WebSocketSslHandshakeThread(wFuture); t.start(); @@ -404,8 +404,11 @@ public class AsyncChannelWrapperSecure i } } } - } catch (SSLException | InterruptedException | - ExecutionException e) { + } catch (SSLException e) { + hFuture.fail(e); + } catch (InterruptedException e) { + hFuture.fail(e); + } catch (ExecutionException e) { hFuture.fail(e); } Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/BackgroundProcessManager.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/BackgroundProcessManager.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/BackgroundProcessManager.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/BackgroundProcessManager.java Fri Aug 16 15:39:41 2013 @@ -47,7 +47,7 @@ public class BackgroundProcessManager { return instance; } - private final Set<BackgroundProcess> processes = new HashSet<>(); + private final Set<BackgroundProcess> processes = new HashSet<BackgroundProcess>(); private final Object processesLock = new Object(); private WsBackgroundThread wsBackgroundThread = null; @@ -82,7 +82,7 @@ public class BackgroundProcessManager { private void process() { - Set<BackgroundProcess> currentProcesses = new HashSet<>(); + Set<BackgroundProcess> currentProcesses = new HashSet<BackgroundProcess>(); synchronized (processesLock) { currentProcesses.addAll(processes); } Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/Util.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/Util.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/Util.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/Util.java Fri Aug 16 15:39:41 2013 @@ -58,7 +58,7 @@ public class Util { private static final StringManager sm = StringManager.getManager(Constants.PACKAGE_NAME); private static final Queue<SecureRandom> randoms = - new ConcurrentLinkedQueue<>(); + new ConcurrentLinkedQueue<SecureRandom>(); private Util() { // Hide default constructor @@ -289,7 +289,7 @@ public class Util { Class<? extends Decoder>[] decoderClazzes) throws DeploymentException{ - List<DecoderEntry> result = new ArrayList<>(); + List<DecoderEntry> result = new ArrayList<DecoderEntry>(); for (Class<? extends Decoder> decoderClazz : decoderClazzes) { // Need to instantiate decoder to ensure it is valid and that // deployment can be failed if it is not @@ -297,7 +297,11 @@ public class Util { Decoder instance; try { instance = decoderClazz.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + } catch (InstantiationException e) { + throw new DeploymentException( + sm.getString("pojoMethodMapping.invalidDecoder", + decoderClazz.getName()), e); + } catch (IllegalAccessException e) { throw new DeploymentException( sm.getString("pojoMethodMapping.invalidDecoder", decoderClazz.getName()), e); @@ -318,7 +322,7 @@ public class Util { Class<?> target = Util.getMessageType(listener); // Will never be more than 2 types - Set<MessageHandlerResult> results = new HashSet<>(2); + Set<MessageHandlerResult> results = new HashSet<MessageHandlerResult>(2); // Simple cases - handlers already accepts one of the types expected by // the frame handling code @@ -409,7 +413,10 @@ public class Util { private static Method getOnMessageMethod(MessageHandler listener) { try { return listener.getClass().getMethod("onMessage", Object.class); - } catch (NoSuchMethodException | SecurityException e) { + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException( + sm.getString("util.invalidMessageHandler"), e); + } catch ( SecurityException e) { throw new IllegalArgumentException( sm.getString("util.invalidMessageHandler"), e); } @@ -418,9 +425,9 @@ public class Util { public static class DecoderMatch { private final List<Class<? extends Decoder>> textDecoders = - new ArrayList<>(); + new ArrayList<Class<? extends Decoder>>(); private final List<Class<? extends Decoder>> binaryDecoders = - new ArrayList<>(); + new ArrayList<Class<? extends Decoder>>(); public DecoderMatch(Class<?> target, List<DecoderEntry> decoderEntries) { Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java Fri Aug 16 15:39:41 2013 @@ -61,7 +61,7 @@ public abstract class WsRemoteEndpointIm private final Log log = LogFactory.getLog(WsRemoteEndpointImplBase.class); private boolean messagePartInProgress = false; - private final Queue<MessagePart> messagePartQueue = new ArrayDeque<>(); + private final Queue<MessagePart> messagePartQueue = new ArrayDeque<MessagePart>(); private final Object messagePartLock = new Object(); private boolean dataMessageInProgress = false; @@ -80,7 +80,7 @@ public abstract class WsRemoteEndpointIm private final AtomicBoolean batchingAllowed = new AtomicBoolean(false); private volatile long sendTimeout = -1; private WsSession wsSession; - private List<EncoderEntry> encoderEntries = new ArrayList<>(); + private List<EncoderEntry> encoderEntries = new ArrayList<EncoderEntry>(); public long getSendTimeout() { return sendTimeout; @@ -198,8 +198,11 @@ public abstract class WsRemoteEndpointIm } else { f2sh.get(timeout, TimeUnit.MILLISECONDS); } - } catch (InterruptedException | ExecutionException | - TimeoutException e) { + } catch (InterruptedException e) { + throw new IOException(e); + } catch (ExecutionException e) { + throw new IOException(e); + } catch (TimeoutException e) { throw new IOException(e); } } @@ -216,8 +219,11 @@ public abstract class WsRemoteEndpointIm } else { f2sh.get(timeout, TimeUnit.MILLISECONDS); } - } catch (InterruptedException | ExecutionException | - TimeoutException e) { + } catch (InterruptedException e) { + throw new IOException(e); + } catch (ExecutionException e) { + throw new IOException(e); + } catch (TimeoutException e) { throw new IOException(e); } } @@ -437,7 +443,9 @@ public abstract class WsRemoteEndpointIm Future<Void> f = sendObjectByFuture(obj); try { f.get(); - } catch (InterruptedException | ExecutionException e) { + } catch (InterruptedException e) { + throw new IOException(e); + } catch (ExecutionException e) { throw new IOException(e); } } @@ -465,23 +473,46 @@ public abstract class WsRemoteEndpointIm String msg = ((Encoder.Text) encoder).encode(obj); sendStringByCompletion(msg, completion); } else if (encoder instanceof Encoder.TextStream) { - try (Writer w = getSendWriter()) { + Writer w = null; + try { + w = getSendWriter(); ((Encoder.TextStream) encoder).encode(obj, w); + } finally { + if (w != null) { + try { + w.close(); + } catch (IOException ioe) { + // Ignore + } + } } completion.onResult(new SendResult()); } else if (encoder instanceof Encoder.Binary) { ByteBuffer msg = ((Encoder.Binary) encoder).encode(obj); sendBytesByCompletion(msg, completion); } else if (encoder instanceof Encoder.BinaryStream) { - try (OutputStream os = getSendStream()) { + OutputStream os = null; + try { + os = getSendStream(); ((Encoder.BinaryStream) encoder).encode(obj, os); + } finally { + if (os != null) { + try { + os.close(); + } catch (IOException ioe) { + // Ignore + } + } } completion.onResult(new SendResult()); } else { throw new EncodeException(obj, sm.getString( "wsRemoteEndpoint.noEncoder", obj.getClass())); } - } catch (EncodeException | IOException e) { + } catch (EncodeException e) { + SendResult sr = new SendResult(e); + completion.onResult(sr); + } catch (IOException e) { SendResult sr = new SendResult(e); completion.onResult(sr); } @@ -502,7 +533,11 @@ public abstract class WsRemoteEndpointIm try { instance = encoderClazz.newInstance(); instance.init(endpointConfig); - } catch (InstantiationException | IllegalAccessException e) { + } catch (InstantiationException e) { + throw new DeploymentException( + sm.getString("wsRemoteEndpoint.invalidEncoder", + encoderClazz.getName()), e); + } catch (IllegalAccessException e) { throw new DeploymentException( sm.getString("wsRemoteEndpoint.invalidEncoder", encoderClazz.getName()), e); Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsSession.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsSession.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsSession.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsSession.java Fri Aug 16 15:39:41 2013 @@ -85,7 +85,7 @@ public class WsSession implements Sessio private MessageHandler.Whole<PongMessage> pongMessageHandler = null; private volatile State state = State.OPEN; private final Object stateLock = new Object(); - private final Map<String,Object> userProperties = new ConcurrentHashMap<>(); + private final Map<String,Object> userProperties = new ConcurrentHashMap<String, Object>(); private volatile int maxBinaryMessageBufferSize = Constants.DEFAULT_BUFFER_SIZE; private volatile int maxTextMessageBufferSize = @@ -223,7 +223,7 @@ public class WsSession implements Sessio @Override public Set<MessageHandler> getMessageHandlers() { checkState(); - Set<MessageHandler> result = new HashSet<>(); + Set<MessageHandler> result = new HashSet<MessageHandler>(); if (binaryMessageHandler != null) { result.add(binaryMessageHandler); } Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsWebSocketContainer.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsWebSocketContainer.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsWebSocketContainer.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Fri Aug 16 15:39:41 2013 @@ -129,8 +129,8 @@ public class WsWebSocketContainer private final Log log = LogFactory.getLog(WsWebSocketContainer.class); private final Map<Class<?>, Set<WsSession>> endpointSessionMap = - new HashMap<>(); - private final Map<WsSession,WsSession> sessions = new ConcurrentHashMap<>(); + new HashMap<Class<?>, Set<WsSession>>(); + private final Map<WsSession,WsSession> sessions = new ConcurrentHashMap<WsSession, WsSession>(); private final Object endPointSessionMapLock = new Object(); private long defaultAsyncTimeout = -1; @@ -164,7 +164,10 @@ public class WsWebSocketContainer configuratorClazz)) { try { configurator = configuratorClazz.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + } catch (InstantiationException e) { + throw new DeploymentException(sm.getString( + "wsWebSocketContainer.defaultConfiguratorFail"), e); + } catch (IllegalAccessException e) { throw new DeploymentException(sm.getString( "wsWebSocketContainer.defaultConfiguratorFail"), e); } @@ -186,7 +189,11 @@ public class WsWebSocketContainer Object pojo; try { pojo = annotatedEndpointClass.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + } catch (InstantiationException e) { + throw new DeploymentException(sm.getString( + "wsWebSocketContainer.endpointCreateFail", + annotatedEndpointClass.getName()), e); + } catch (IllegalAccessException e) { throw new DeploymentException(sm.getString( "wsWebSocketContainer.endpointCreateFail", annotatedEndpointClass.getName()), e); @@ -204,7 +211,11 @@ public class WsWebSocketContainer Endpoint endpoint; try { endpoint = clazz.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + } catch (InstantiationException e) { + throw new DeploymentException(sm.getString( + "wsWebSocketContainer.endpointCreateFail", clazz.getName()), + e); + } catch (IllegalAccessException e) { throw new DeploymentException(sm.getString( "wsWebSocketContainer.endpointCreateFail", clazz.getName()), e); @@ -318,8 +329,16 @@ public class WsWebSocketContainer throw new DeploymentException( sm.getString("Sec-WebSocket-Protocol")); } - } catch (ExecutionException | InterruptedException | SSLException | - EOFException e) { + } catch (ExecutionException e) { + throw new DeploymentException( + sm.getString("wsWebSocketContainer.httpRequestFailed"), e); + } catch (InterruptedException e) { + throw new DeploymentException( + sm.getString("wsWebSocketContainer.httpRequestFailed"), e); + } catch (SSLException e) { + throw new DeploymentException( + sm.getString("wsWebSocketContainer.httpRequestFailed"), e); + } catch (EOFException e) { throw new DeploymentException( sm.getString("wsWebSocketContainer.httpRequestFailed"), e); } @@ -359,7 +378,7 @@ public class WsWebSocketContainer } Set<WsSession> wsSessions = endpointSessionMap.get(endpointClazz); if (wsSessions == null) { - wsSessions = new HashSet<>(); + wsSessions = new HashSet<WsSession>(); endpointSessionMap.put(endpointClazz, wsSessions); } wsSessions.add(wsSession); @@ -389,7 +408,7 @@ public class WsWebSocketContainer Set<Session> getOpenSessions(Class<?> endpoint) { - HashSet<Session> result = new HashSet<>(); + HashSet<Session> result = new HashSet<Session>(); synchronized (endPointSessionMapLock) { Set<WsSession> sessions = endpointSessionMap.get(endpoint); if (sessions != null) { @@ -402,10 +421,10 @@ public class WsWebSocketContainer private Map<String,List<String>> createRequestHeaders(String host, int port, List<String> subProtocols, List<Extension> extensions) { - Map<String,List<String>> headers = new HashMap<>(); + Map<String,List<String>> headers = new HashMap<String, List<String>>(); // Host header - List<String> hostValues = new ArrayList<>(1); + List<String> hostValues = new ArrayList<String>(1); if (port == -1) { hostValues.add(host); } else { @@ -415,22 +434,22 @@ public class WsWebSocketContainer headers.put(Constants.HOST_HEADER_NAME, hostValues); // Upgrade header - List<String> upgradeValues = new ArrayList<>(1); + List<String> upgradeValues = new ArrayList<String>(1); upgradeValues.add(Constants.UPGRADE_HEADER_VALUE); headers.put(Constants.UPGRADE_HEADER_NAME, upgradeValues); // Connection header - List<String> connectionValues = new ArrayList<>(1); + List<String> connectionValues = new ArrayList<String>(1); connectionValues.add(Constants.CONNECTION_HEADER_VALUE); headers.put(Constants.CONNECTION_HEADER_NAME, connectionValues); // WebSocket version header - List<String> wsVersionValues = new ArrayList<>(1); + List<String> wsVersionValues = new ArrayList<String>(1); wsVersionValues.add(Constants.WS_VERSION_HEADER_VALUE); headers.put(Constants.WS_VERSION_HEADER_NAME, wsVersionValues); // WebSocket key - List<String> wsKeyValues = new ArrayList<>(1); + List<String> wsKeyValues = new ArrayList<String>(1); wsKeyValues.add(generateWsKeyValue()); headers.put(Constants.WS_KEY_HEADER_NAME, wsKeyValues); @@ -450,7 +469,7 @@ public class WsWebSocketContainer private List<String> generateExtensionHeaders(List<Extension> extensions) { - List<String> result = new ArrayList<>(extensions.size()); + List<String> result = new ArrayList<String>(extensions.size()); for (Extension extension : extensions) { StringBuilder header = new StringBuilder(); header.append(extension.getName()); @@ -536,7 +555,7 @@ public class WsWebSocketContainer AsyncChannelWrapper channel) throws InterruptedException, ExecutionException, DeploymentException, EOFException { - Map<String,List<String>> headers = new HashMap<>(); + Map<String,List<String>> headers = new HashMap<String, List<String>>(); boolean readStatus = false; boolean readHeaders = false; @@ -598,7 +617,7 @@ public class WsWebSocketContainer List<String> values = headers.get(headerName); if (values == null) { - values = new ArrayList<>(1); + values = new ArrayList<String>(1); headers.put(headerName, values); } values.add(headerValue); @@ -641,8 +660,18 @@ public class WsWebSocketContainer File keyStoreFile = new File(sslTrustStoreValue); KeyStore ks = KeyStore.getInstance("JKS"); - try (InputStream is = new FileInputStream(keyStoreFile)) { + InputStream is = null; + try { + is = new FileInputStream(keyStoreFile); ks.load(is, sslTrustStorePwdValue.toCharArray()); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException ioe) { + // Ignore + } + } } TrustManagerFactory tmf = TrustManagerFactory.getInstance( Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerBase.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerBase.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerBase.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerBase.java Fri Aug 16 15:39:41 2013 @@ -74,8 +74,10 @@ public abstract class PojoMessageHandler } else { remoteEndpoint.sendObject(result); } - } catch (IOException | EncodeException ioe) { + } catch (IOException ioe) { throw new IllegalStateException(ioe); + } catch (EncodeException ee) { + throw new IllegalStateException(ee); } } Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerPartialBase.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerPartialBase.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerPartialBase.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerPartialBase.java Fri Aug 16 15:39:41 2013 @@ -69,7 +69,9 @@ public abstract class PojoMessageHandler Object result; try { result = method.invoke(pojo, parameters); - } catch (IllegalAccessException | InvocationTargetException e) { + } catch (IllegalAccessException e) { + throw new IllegalArgumentException(e); + } catch (InvocationTargetException e) { throw new IllegalArgumentException(e); } processResult(result); Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBase.java Fri Aug 16 15:39:41 2013 @@ -78,7 +78,9 @@ public abstract class PojoMessageHandler Object result; try { result = method.invoke(pojo, parameters); - } catch (IllegalAccessException | InvocationTargetException e) { + } catch (IllegalAccessException e) { + throw new IllegalArgumentException(e); + } catch (InvocationTargetException e) { throw new IllegalArgumentException(e); } processResult(result); Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java Fri Aug 16 15:39:41 2013 @@ -41,7 +41,7 @@ public class PojoMessageHandlerWholeBina private static final StringManager sm = StringManager.getManager(Constants.PACKAGE_NAME); - private final List<Decoder> decoders = new ArrayList<>(); + private final List<Decoder> decoders = new ArrayList<Decoder>(); private final boolean isForInputStream; @@ -71,7 +71,9 @@ public class PojoMessageHandlerWholeBina } } } - } catch (IllegalAccessException | InstantiationException e) { + } catch (IllegalAccessException e) { + throw new IllegalArgumentException(e); + } catch (InstantiationException e) { throw new IllegalArgumentException(e); } this.isForInputStream = isForInputStream; Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java Fri Aug 16 15:39:41 2013 @@ -42,7 +42,7 @@ public class PojoMessageHandlerWholeText private static final StringManager sm = StringManager.getManager(Constants.PACKAGE_NAME); - private final List<Decoder> decoders = new ArrayList<>(); + private final List<Decoder> decoders = new ArrayList<Decoder>(); private final Class<?> primitiveType; public PojoMessageHandlerWholeText(Object pojo, Method method, @@ -80,7 +80,9 @@ public class PojoMessageHandlerWholeText } } } - } catch (IllegalAccessException | InstantiationException e) { + } catch (IllegalAccessException e) { + throw new IllegalArgumentException(e); + } catch (InstantiationException e) { throw new IllegalArgumentException(e); } } Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java Fri Aug 16 15:39:41 2013 @@ -64,7 +64,7 @@ public class PojoMethodMapping { private final PojoPathParam[] onOpenParams; private final PojoPathParam[] onCloseParams; private final PojoPathParam[] onErrorParams; - private final Set<MessageHandlerInfo> onMessage = new HashSet<>(); + private final Set<MessageHandlerInfo> onMessage = new HashSet<MessageHandlerInfo>(); private final String wsPath; @@ -177,7 +177,7 @@ public class PojoMethodMapping { public Set<MessageHandler> getMessageHandlers(Object pojo, Map<String,String> pathParameters, Session session, EndpointConfig config) { - Set<MessageHandler> result = new HashSet<>(); + Set<MessageHandler> result = new HashSet<MessageHandler>(); for (MessageHandlerInfo messageMethod : onMessage) { result.addAll(messageMethod.getMessageHandlers(pojo, pathParameters, session, config)); @@ -288,7 +288,7 @@ public class PojoMethodMapping { private int indexInputStream = -1; private int indexReader = -1; private int indexPrimitive = -1; - private Map<Integer,PojoPathParam> indexPathParams = new HashMap<>(); + private Map<Integer,PojoPathParam> indexPathParams = new HashMap<Integer, PojoPathParam>(); private int indexPayload = -1; private DecoderMatch decoderMatch = null; private long maxMessageSize = -1; @@ -525,7 +525,7 @@ public class PojoMethodMapping { params[entry.getKey().intValue()] = value; } - Set<MessageHandler> results = new HashSet<>(2); + Set<MessageHandler> results = new HashSet<MessageHandler>(2); if (indexBoolean == -1) { // Basic if (indexString != -1 || indexPrimitive != -1) { Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/DefaultServerEndpointConfigurator.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/DefaultServerEndpointConfigurator.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/DefaultServerEndpointConfigurator.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/DefaultServerEndpointConfigurator.java Fri Aug 16 15:39:41 2013 @@ -57,7 +57,7 @@ public class DefaultServerEndpointConfig public List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested) { - List<Extension> result = new ArrayList<>(); + List<Extension> result = new ArrayList<Extension>(); for (Extension request : requested) { if (installed.contains(request)) { result.add(request); Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/UpgradeUtil.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/UpgradeUtil.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/UpgradeUtil.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/UpgradeUtil.java Fri Aug 16 15:39:41 2013 @@ -52,7 +52,7 @@ public class UpgradeUtil { "258EAFA5-E914-47DA-95CA-C5AB0DC85B11".getBytes( StandardCharsets.ISO_8859_1); private static final Queue<MessageDigest> sha1Helpers = - new ConcurrentLinkedQueue<>(); + new ConcurrentLinkedQueue<MessageDigest>(); private UpgradeUtil() { // Utility class. Hide default constructor. @@ -207,7 +207,7 @@ public class UpgradeUtil { */ private static List<String> getTokensFromHeader(HttpServletRequest req, String headerName) { - List<String> result = new ArrayList<>(); + List<String> result = new ArrayList<String>(); Enumeration<String> headers = req.getHeaders(headerName); while (headers.hasMoreElements()) { String header = headers.nextElement(); Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/UriTemplate.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/UriTemplate.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/UriTemplate.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/UriTemplate.java Fri Aug 16 15:39:41 2013 @@ -35,7 +35,7 @@ public class UriTemplate { StringManager.getManager(Constants.PACKAGE_NAME); private final String normalized; - private final Map<String,Segment> segments = new LinkedHashMap<>(); + private final Map<String,Segment> segments = new LinkedHashMap<String, Segment>(); private final boolean hasParameters; @@ -88,7 +88,7 @@ public class UriTemplate { public Map<String,String> match(UriTemplate candidate) { - Map<String,String> result = new HashMap<>(); + Map<String,String> result = new HashMap<String, String>(); // Should not happen but for safety if (candidate.getSegmentCount() != getSegmentCount()) { Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsHandshakeRequest.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsHandshakeRequest.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsHandshakeRequest.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsHandshakeRequest.java Fri Aug 16 15:39:41 2013 @@ -68,7 +68,7 @@ public class WsHandshakeRequest implemen // ParameterMap Map<String,String[]> originalParameters = request.getParameterMap(); Map<String,List<String>> newParameters = - new HashMap<>(originalParameters.size()); + new HashMap<String, List<String>>(originalParameters.size()); for (Entry<String,String[]> entry : originalParameters.entrySet()) { newParameters.put(entry.getKey(), Collections.unmodifiableList( @@ -77,7 +77,7 @@ public class WsHandshakeRequest implemen parameterMap = Collections.unmodifiableMap(newParameters); // Headers - Map<String,List<String>> newHeaders = new HashMap<>(); + Map<String,List<String>> newHeaders = new HashMap<String, List<String>>(); Enumeration<String> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsSci.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsSci.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsSci.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsSci.java Fri Aug 16 15:39:41 2013 @@ -51,9 +51,9 @@ public class WsSci implements ServletCon } // Group the discovered classes by type - Set<ServerApplicationConfig> serverApplicationConfigs = new HashSet<>(); - Set<Class<? extends Endpoint>> scannedEndpointClazzes = new HashSet<>(); - Set<Class<?>> scannedPojoEndpoints = new HashSet<>(); + Set<ServerApplicationConfig> serverApplicationConfigs = new HashSet<ServerApplicationConfig>(); + Set<Class<? extends Endpoint>> scannedEndpointClazzes = new HashSet<Class<? extends Endpoint>>(); + Set<Class<?>> scannedPojoEndpoints = new HashSet<Class<?>>(); try { // wsPackage is "javax.websocket." @@ -84,13 +84,15 @@ public class WsSci implements ServletCon scannedPojoEndpoints.add(clazz); } } - } catch (InstantiationException | IllegalAccessException e) { + } catch (InstantiationException e) { + throw new ServletException(e); + } catch (IllegalAccessException e) { throw new ServletException(e); } // Filter the results - Set<ServerEndpointConfig> filteredEndpointConfigs = new HashSet<>(); - Set<Class<?>> filteredPojoEndpoints = new HashSet<>(); + Set<ServerEndpointConfig> filteredEndpointConfigs = new HashSet<ServerEndpointConfig>(); + Set<Class<?>> filteredPojoEndpoints = new HashSet<Class<?>>(); if (serverApplicationConfigs.isEmpty()) { filteredPojoEndpoints.addAll(scannedPojoEndpoints); Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsServerContainer.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsServerContainer.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsServerContainer.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsServerContainer.java Fri Aug 16 15:39:41 2013 @@ -73,14 +73,14 @@ public class WsServerContainer extends W private final ServletContext servletContext; private final Map<String,ServerEndpointConfig> configExactMatchMap = - new ConcurrentHashMap<>(); + new ConcurrentHashMap<String, ServerEndpointConfig>(); private final ConcurrentHashMap<Integer,SortedSet<TemplatePathMatch>> - configTemplateMatchMap = new ConcurrentHashMap<>(); + configTemplateMatchMap = new ConcurrentHashMap<Integer, SortedSet<TemplatePathMatch>>(); private volatile boolean enforceNoAddAfterHandshake = org.apache.tomcat.websocket.Constants.STRICT_SPEC_COMPLIANCE; private volatile boolean addAllowed = true; private final ConcurrentHashMap<String,Set<WsSession>> authenticatedSessions = - new ConcurrentHashMap<>(); + new ConcurrentHashMap<String, Set<WsSession>>(); WsServerContainer(ServletContext servletContext) { @@ -147,7 +147,7 @@ public class WsServerContainer extends W if (templateMatches == null) { // Ensure that if concurrent threads execute this block they // both end up using the same TreeSet instance - templateMatches = new TreeSet<>( + templateMatches = new TreeSet<TemplatePathMatch>( TemplatePathMatchComparator.getInstance()); configTemplateMatchMap.putIfAbsent(key, templateMatches); templateMatches = configTemplateMatchMap.get(key); @@ -202,7 +202,12 @@ public class WsServerContainer extends W if (!configuratorClazz.equals(Configurator.class)) { try { configurator = annotation.configurator().newInstance(); - } catch (InstantiationException | IllegalAccessException e) { + } catch (InstantiationException e) { + throw new DeploymentException(sm.getString( + "serverContainer.configuratorFail", + annotation.configurator().getName(), + pojo.getClass().getName()), e); + } catch (IllegalAccessException e) { throw new DeploymentException(sm.getString( "serverContainer.configuratorFail", annotation.configurator().getName(), @@ -387,7 +392,10 @@ public class WsServerContainer extends W Encoder instance; try { encoder.newInstance(); - } catch(InstantiationException | IllegalAccessException e) { + } catch(InstantiationException e) { + throw new DeploymentException(sm.getString( + "serverContainer.encoderFail", encoder.getName()), e); + } catch (IllegalAccessException e) { throw new DeploymentException(sm.getString( "serverContainer.encoderFail", encoder.getName()), e); } Modified: tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsWriteTimeout.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsWriteTimeout.java?rev=1514752&r1=1514751&r2=1514752&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsWriteTimeout.java (original) +++ tomcat/tc7.0.x/trunk/modules/websocket/java/org/apache/tomcat/websocket/server/WsWriteTimeout.java Fri Aug 16 15:39:41 2013 @@ -34,7 +34,7 @@ import org.apache.tomcat.websocket.Backg public class WsWriteTimeout implements BackgroundProcess { private final Set<WsRemoteEndpointImplServer> endpoints = - new ConcurrentSkipListSet<>(new EndpointComparator()); + new ConcurrentSkipListSet<WsRemoteEndpointImplServer>(new EndpointComparator()); private final AtomicInteger count = new AtomicInteger(0); private int backgroundProcessCount = 0; private volatile int processPeriod = 1; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org