diff --git a/client/src/main/java/org/red5/client/net/remoting/DSRemotingClient.java b/client/src/main/java/org/red5/client/net/remoting/DSRemotingClient.java
index 0299f904401b2a8ca14505b7d32bcdf4723a3e3f..32f339ba602728375297dac48c5f740542dd0a26 100644
--- a/client/src/main/java/org/red5/client/net/remoting/DSRemotingClient.java
+++ b/client/src/main/java/org/red5/client/net/remoting/DSRemotingClient.java
@@ -146,6 +146,7 @@ public class DSRemotingClient extends RemotingClient {
      * @param in
      *            Byte buffer with response data
      */
+    @SuppressWarnings("null")
     @Override
     protected void processHeaders(IoBuffer in) {
         log.debug("RemotingClient processHeaders - buffer limit: {}", (in != null ? in.limit() : 0));
@@ -204,6 +205,7 @@ public class DSRemotingClient extends RemotingClient {
      *            Result data to decode
      * @return Object deserialized from byte buffer data
      */
+    @SuppressWarnings("null")
     private Object decodeResult(IoBuffer data) {
         log.debug("decodeResult - data limit: {}", (data != null ? data.limit() : 0));
         processHeaders(data);
@@ -268,6 +270,7 @@ public class DSRemotingClient extends RemotingClient {
      *            Parameters passed to method
      * @return the result of the method call
      */
+    @SuppressWarnings("null")
     @Override
     public Object invokeMethod(String method, Object[] params) {
         log.debug("invokeMethod url: {}", (url + appendToUrl));
diff --git a/client/src/main/java/org/red5/client/net/rtmpe/RTMPEIoFilter.java b/client/src/main/java/org/red5/client/net/rtmpe/RTMPEIoFilter.java
index d3664029793b86a2dd6eb3460d6aa1ba155fd564..a526135f69c68aa8f109aa55d8e47b6ccc425bf1 100644
--- a/client/src/main/java/org/red5/client/net/rtmpe/RTMPEIoFilter.java
+++ b/client/src/main/java/org/red5/client/net/rtmpe/RTMPEIoFilter.java
@@ -75,36 +75,41 @@ public class RTMPEIoFilter extends IoFilterAdapter {
                     // set handshake to match client requested type
                     byte connectionType = dst[0];
                     log.trace("Incoming S0 connection type: {}", connectionType);
-                    if (handshake.getHandshakeType() != connectionType) {
-                        log.debug("Server requested handshake type: {} client requested: {}", connectionType, handshake.getHandshakeType());
-                    }
-                    // XXX do we go ahead with what the server requested?
-                    handshake.setHandshakeType(connectionType);
-                    // wrap the buffer for decoding
-                    IoBuffer decBuffer = IoBuffer.wrap(dst);
-                    // skip the connection type; should be 1536 after
-                    decBuffer.get();
-                    //log.debug("S1 - buffer: {}", Hex.encodeHexString(dst));
-                    // keep remaining bytes in a thread local for use by S2 decoding
-                    IoBuffer c2 = handshake.decodeServerResponse1(decBuffer);
-                    if (c2 != null) {
-                        // clean up
-                        decBuffer.clear();
-                        // set state to indicate we're waiting for S2
-                        conn.setStateCode(RTMP.STATE_HANDSHAKE);
-                        //log.trace("C2 byte order: {}", c2.order());
-                        session.write(c2);
-                        // if we got S0S1+S2 continue processing
-                        if (buffer.getBufferSize() >= Constants.HANDSHAKE_SIZE) {
-                            log.debug("decodeHandshakeS2");
-                            if (handshake.decodeServerResponse2(buffer.getBuffer(Constants.HANDSHAKE_SIZE))) {
-                                log.debug("S2 decoding successful");
-                            } else {
-                                log.warn("Handshake failed on S2 processing");
+                    if (handshake != null) {
+                        if (handshake.getHandshakeType() != connectionType) {
+                            log.debug("Server requested handshake type: {} client requested: {}", connectionType, handshake.getHandshakeType());
+                        }
+                        // XXX do we go ahead with what the server requested?
+                        handshake.setHandshakeType(connectionType);
+                        // wrap the buffer for decoding
+                        IoBuffer decBuffer = IoBuffer.wrap(dst);
+                        // skip the connection type; should be 1536 after
+                        decBuffer.get();
+                        //log.debug("S1 - buffer: {}", Hex.encodeHexString(dst));
+                        // keep remaining bytes in a thread local for use by S2 decoding
+                        IoBuffer c2 = handshake.decodeServerResponse1(decBuffer);
+                        if (c2 != null) {
+                            // clean up
+                            decBuffer.clear();
+                            // set state to indicate we're waiting for S2
+                            conn.setStateCode(RTMP.STATE_HANDSHAKE);
+                            //log.trace("C2 byte order: {}", c2.order());
+                            session.write(c2);
+                            // if we got S0S1+S2 continue processing
+                            if (buffer.getBufferSize() >= Constants.HANDSHAKE_SIZE) {
+                                log.debug("decodeHandshakeS2");
+                                if (handshake.decodeServerResponse2(buffer.getBuffer(Constants.HANDSHAKE_SIZE))) {
+                                    log.debug("S2 decoding successful");
+                                } else {
+                                    log.warn("Handshake failed on S2 processing");
+                                }
+                                completeConnection(session, conn, handshake);
                             }
-                            completeConnection(session, conn, handshake);
+                        } else {
+                            conn.close();
                         }
                     } else {
+                        log.warn("Handshake is missing from the session");
                         conn.close();
                     }
                 }
@@ -115,13 +120,18 @@ public class RTMPEIoFilter extends IoFilterAdapter {
                 log.trace("Incoming S2 size: {}", s2Size);
                 if (s2Size >= Constants.HANDSHAKE_SIZE) {
                     log.debug("decodeHandshakeS2");
-                    if (handshake.decodeServerResponse2(buffer.getBuffer(Constants.HANDSHAKE_SIZE))) {
-                        log.debug("S2 decoding successful");
+                    if (handshake != null) {
+                        if (handshake.decodeServerResponse2(buffer.getBuffer(Constants.HANDSHAKE_SIZE))) {
+                            log.debug("S2 decoding successful");
+                        } else {
+                            log.warn("Handshake failed on S2 processing");
+                        }
+                        // complete the connection regardless of the S2 success or failure
+                        completeConnection(session, conn, handshake);
                     } else {
-                        log.warn("Handshake failed on S2 processing");
+                        log.warn("Handshake is missing from the session");
+                        conn.close();
                     }
-                    // complete the connection regardless of the S2 success or failure
-                    completeConnection(session, conn, handshake);
                 } else {
                     // don't fall through to connected process if we didn't have enough for the handshake
                     break;
diff --git a/client/src/main/java/org/red5/client/net/rtmps/RTMPTSClientConnector.java b/client/src/main/java/org/red5/client/net/rtmps/RTMPTSClientConnector.java
index 6c6385a431ae2358355f0e3a3499fa001e948553..dd678ed1cbabfef5e3ec3db0b99ed49c1bb8bcf3 100644
--- a/client/src/main/java/org/red5/client/net/rtmps/RTMPTSClientConnector.java
+++ b/client/src/main/java/org/red5/client/net/rtmps/RTMPTSClientConnector.java
@@ -58,7 +58,7 @@ public class RTMPTSClientConnector extends RTMPTClientConnector {
             while (!conn.isClosing() && !stopRequested) {
                 IoBuffer toSend = conn.getPendingMessages(SEND_TARGET_SIZE);
                 int limit = toSend != null ? toSend.limit() : 0;
-                if (limit > 0) {
+                if (limit > 0 && toSend != null) {
                     post = makePost("send");
                     post.setEntity(new InputStreamEntity(toSend.asInputStream(), limit));
                     post.addHeader("Content-Type", CONTENT_TYPE);
diff --git a/client/src/main/java/org/red5/client/net/rtmpt/RTMPTClientConnector.java b/client/src/main/java/org/red5/client/net/rtmpt/RTMPTClientConnector.java
index c17a6a1b97bf1e5a08b767c1599dc9f69c8ffcc3..f9903d6f1da7ee48d43b2de07e1b08ae7b280f68 100644
--- a/client/src/main/java/org/red5/client/net/rtmpt/RTMPTClientConnector.java
+++ b/client/src/main/java/org/red5/client/net/rtmpt/RTMPTClientConnector.java
@@ -87,7 +87,7 @@ public class RTMPTClientConnector extends Thread {
             while (!conn.isClosing() && !stopRequested) {
                 IoBuffer toSend = conn.getPendingMessages(SEND_TARGET_SIZE);
                 int limit = toSend != null ? toSend.limit() : 0;
-                if (limit > 0) {
+                if (limit > 0 && toSend != null) {
                     post = makePost("send");
                     post.setEntity(new InputStreamEntity(toSend.asInputStream(), limit));
                     post.addHeader("Content-Type", CONTENT_TYPE);
diff --git a/common/src/main/java/org/red5/server/Client.java b/common/src/main/java/org/red5/server/Client.java
index 8a92192cbbec0e0d58867d773c709f5ae5e81b7e..b79b2415806c3c61ace15ce1331992780bb62cc4 100644
--- a/common/src/main/java/org/red5/server/Client.java
+++ b/common/src/main/java/org/red5/server/Client.java
@@ -362,7 +362,7 @@ public class Client extends AttributeStore implements IClient {
             instance = new Client(id, (Long) cd.get("creationTime"), null);
             instance.setAttribute(PERMISSIONS, cd.get(PERMISSIONS));
         }
-        if (cd.containsKey("attributes")) {
+        if (instance != null && cd.containsKey("attributes")) {
             AttributeStore attrs = (AttributeStore) cd.get("attributes");
             instance.setAttributes(attrs);
         }
diff --git a/common/src/main/java/org/red5/server/ContextLoader.java b/common/src/main/java/org/red5/server/ContextLoader.java
index 7e50158a3554c2d005264c72306c0906be510924..9093caabbec3e874969bceb45c2589680111bb91 100644
--- a/common/src/main/java/org/red5/server/ContextLoader.java
+++ b/common/src/main/java/org/red5/server/ContextLoader.java
@@ -100,6 +100,7 @@ public class ContextLoader implements ApplicationContextAware, InitializingBean,
     /**
      * Loads context settings from ResourceBundle (.properties file)
      */
+    @SuppressWarnings("null")
     public void init() throws IOException {
         // Load properties bundle
         Properties props = new Properties();
@@ -147,6 +148,7 @@ public class ContextLoader implements ApplicationContextAware, InitializingBean,
      * @param config
      *            Filename
      */
+    @SuppressWarnings("null")
     public void loadContext(String name, String config) {
         log.debug("Load context - name: {} config: {}", name, config);
         // check the existence of the config file
@@ -200,6 +202,7 @@ public class ContextLoader implements ApplicationContextAware, InitializingBean,
      * @param name
      *            Context name
      */
+    @SuppressWarnings("null")
     public void unloadContext(String name) {
         log.debug("Un-load context - name: {}", name);
         ApplicationContext context = contextMap.remove(name);
@@ -332,6 +335,7 @@ public class ContextLoader implements ApplicationContextAware, InitializingBean,
      * @throws BeansException
      *             Top level exception for app context (that is, in fact, beans factory)
      */
+    @SuppressWarnings("null")
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         this.applicationContext = applicationContext;
     }
diff --git a/common/src/main/java/org/red5/server/LoaderBase.java b/common/src/main/java/org/red5/server/LoaderBase.java
index f5cfda60a8a952ff74beb790a42bf3e583f29082..815eb7083878ab26046f2efb077c6d3529d2458d 100644
--- a/common/src/main/java/org/red5/server/LoaderBase.java
+++ b/common/src/main/java/org/red5/server/LoaderBase.java
@@ -146,6 +146,7 @@ public abstract class LoaderBase implements ApplicationContextAware {
      * @throws BeansException
      *             Abstract superclass for all exceptions thrown in the beans package and subpackages
      */
+    @SuppressWarnings("null")
     public void setApplicationContext(ApplicationContext context) throws BeansException {
         log.debug("Set application context: {}", context);
         applicationContext = context;
diff --git a/common/src/main/java/org/red5/server/Server.java b/common/src/main/java/org/red5/server/Server.java
index 66eb559c09e1a2b8d83acd99887dd32eb747f608..80d00b812ad210bdeafa47b9b46a9143dfbdbbb6 100644
--- a/common/src/main/java/org/red5/server/Server.java
+++ b/common/src/main/java/org/red5/server/Server.java
@@ -81,6 +81,7 @@ public class Server implements IServer, ApplicationContextAware, InitializingBea
      * @param applicationContext
      *            Application context
      */
+    @SuppressWarnings("null")
     public void setApplicationContext(ApplicationContext applicationContext) {
         log.debug("Setting application context");
         this.applicationContext = applicationContext;
@@ -268,6 +269,7 @@ public class Server implements IServer, ApplicationContextAware, InitializingBea
      *
      * @return String representation of server
      */
+    @SuppressWarnings("null")
     @Override
     public String toString() {
         return new ToStringCreator(this).append(mapping).toString();
diff --git a/common/src/main/java/org/red5/server/net/remoting/RemotingClient.java b/common/src/main/java/org/red5/server/net/remoting/RemotingClient.java
index ad6ab1686443ced16216103d182921b2553eb994..d291a70dc9ce487f465f6bcefb879192e27bf303 100644
--- a/common/src/main/java/org/red5/server/net/remoting/RemotingClient.java
+++ b/common/src/main/java/org/red5/server/net/remoting/RemotingClient.java
@@ -177,6 +177,7 @@ public class RemotingClient implements IRemotingClient {
      * @param in
      *            Byte buffer with response data
      */
+    @SuppressWarnings("null")
     protected void processHeaders(IoBuffer in) {
         log.debug("RemotingClient processHeaders - buffer limit: {}", (in != null ? in.limit() : 0));
         int version = in.getUnsignedShort(); // skip
@@ -227,6 +228,7 @@ public class RemotingClient implements IRemotingClient {
      *            Result data to decode
      * @return Object deserialized from byte buffer data
      */
+    @SuppressWarnings("null")
     private Object decodeResult(IoBuffer data) {
         log.debug("decodeResult - data limit: {}", (data != null ? data.limit() : 0));
         processHeaders(data);
@@ -300,6 +302,7 @@ public class RemotingClient implements IRemotingClient {
      *            Parameters passed to method
      * @return the result of the method call
      */
+    @SuppressWarnings("null")
     public Object invokeMethod(String method, Object[] params) {
         log.debug("invokeMethod url: {}", (url + appendToUrl));
         IoBuffer resultBuffer = null;
diff --git a/common/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java b/common/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java
index ae1ec49595e141c33a15b9e388b7fd6f88d82198..e63c818179db2bc231c93d137e0e15713556d4ee 100755
--- a/common/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java
+++ b/common/src/main/java/org/red5/server/net/rtmp/RTMPConnection.java
@@ -1566,6 +1566,7 @@ public abstract class RTMPConnection extends BaseConnection implements IStreamCa
                         return (int) (System.currentTimeMillis() - startTime);
                     }
 
+                    @SuppressWarnings("null")
                     public void onFailure(Throwable t) {
                         log.debug("ReceivedMessageTask failure: {}", t);
                         if (log.isWarnEnabled()) {
diff --git a/common/src/main/java/org/red5/server/net/rtmp/ReceivedMessageTask.java b/common/src/main/java/org/red5/server/net/rtmp/ReceivedMessageTask.java
index 7c9f5429e3b834940af39ebb1ac86f599bbedcf8..bf611d8c81e96b0fd2a2e4e939abc77190c3ce65 100644
--- a/common/src/main/java/org/red5/server/net/rtmp/ReceivedMessageTask.java
+++ b/common/src/main/java/org/red5/server/net/rtmp/ReceivedMessageTask.java
@@ -77,7 +77,7 @@ public final class ReceivedMessageTask implements Callable<Packet> {
      * @param deadlockGuardTask
      *            deadlock guard task
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "null" })
     public void runDeadlockFuture(Runnable deadlockGuardTask) {
         if (deadlockFuture == null) {
             ThreadPoolTaskScheduler deadlockGuard = conn.getDeadlockGuardScheduler();
diff --git a/common/src/main/java/org/red5/server/scope/Scope.java b/common/src/main/java/org/red5/server/scope/Scope.java
index 891e6bfec58c7f90a2a071bb7593db8780572310..4be4d50ad67c4a88269ff2894632874c473f522d 100644
--- a/common/src/main/java/org/red5/server/scope/Scope.java
+++ b/common/src/main/java/org/red5/server/scope/Scope.java
@@ -718,6 +718,7 @@ public class Scope extends BasicScope implements IScope, IScopeStatistics, Scope
      *            Resource path
      * @return Resource
      */
+    @SuppressWarnings("null")
     public Resource getResource(String path) {
         if (hasContext()) {
             return context.getResource(path);
@@ -734,6 +735,7 @@ public class Scope extends BasicScope implements IScope, IScopeStatistics, Scope
      * @throws IOException
      *             I/O exception
      */
+    @SuppressWarnings("null")
     public Resource[] getResources(String path) throws IOException {
         if (hasContext()) {
             return context.getResources(path);
diff --git a/common/src/main/java/org/red5/server/so/ClientSharedObject.java b/common/src/main/java/org/red5/server/so/ClientSharedObject.java
index 5a3cb66bed6645bdf9fd7d5978334718a0ee244c..c158c7162feee0457fa36cfa5713c93ae450bbf2 100644
--- a/common/src/main/java/org/red5/server/so/ClientSharedObject.java
+++ b/common/src/main/java/org/red5/server/so/ClientSharedObject.java
@@ -269,6 +269,7 @@ public class ClientSharedObject extends SharedObject implements IClientSharedObj
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("null")
     @Override
     public boolean setAttributes(Map<String, Object> values) {
         int successes = 0;
diff --git a/common/src/main/java/org/red5/server/stream/ClientBroadcastStream.java b/common/src/main/java/org/red5/server/stream/ClientBroadcastStream.java
index 0cd5f4921cecfddc220dd9c540e1bfd59e6ca05f..9f2bed669dd74961c01823c5aa92f5b82c18025a 100644
--- a/common/src/main/java/org/red5/server/stream/ClientBroadcastStream.java
+++ b/common/src/main/java/org/red5/server/stream/ClientBroadcastStream.java
@@ -257,6 +257,7 @@ public class ClientBroadcastStream extends AbstractClientStream implements IClie
      * @param event
      *            Event to dispatch
      */
+    @SuppressWarnings("null")
     public void dispatchEvent(IEvent event) {
         if (event instanceof IRTMPEvent && !closed.get()) {
             switch (event.getType()) {
diff --git a/common/src/main/java/org/red5/server/stream/RecordingListener.java b/common/src/main/java/org/red5/server/stream/RecordingListener.java
index 828483ed8657d4764f7ff460b5a66ee8aea2dd6b..6ae53bb39b9326cdb9632cac392a9f8240570b64 100644
--- a/common/src/main/java/org/red5/server/stream/RecordingListener.java
+++ b/common/src/main/java/org/red5/server/stream/RecordingListener.java
@@ -95,6 +95,7 @@ public class RecordingListener implements IRecordingListener {
      *            name
      * @return file
      */
+    @SuppressWarnings("null")
     public static File getRecordFile(IScope scope, String name) {
         // get stream filename generator
         IStreamFilenameGenerator generator = (IStreamFilenameGenerator) ScopeUtils.getScopeService(scope, IStreamFilenameGenerator.class, DefaultStreamFilenameGenerator.class);
diff --git a/common/src/main/java/org/red5/server/stream/StreamService.java b/common/src/main/java/org/red5/server/stream/StreamService.java
index a345d016903841bc972959261e9411027f37e6a1..e9023b1e15f1e33f6a6694a816818465f37812d5 100644
--- a/common/src/main/java/org/red5/server/stream/StreamService.java
+++ b/common/src/main/java/org/red5/server/stream/StreamService.java
@@ -652,6 +652,7 @@ public class StreamService implements IStreamService {
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("null")
     public void publish(String name, String mode) {
         IConnection conn = Red5.getConnectionLocal();
         Map<String, String> params = null;
diff --git a/common/src/main/java/org/red5/server/util/ScopeUtils.java b/common/src/main/java/org/red5/server/util/ScopeUtils.java
index 4413537b2d814e4156d11c755ae3371eef1680f2..dd4ad8893177c6d18d593070e6970a2ef3011f3e 100644
--- a/common/src/main/java/org/red5/server/util/ScopeUtils.java
+++ b/common/src/main/java/org/red5/server/util/ScopeUtils.java
@@ -269,6 +269,7 @@ public class ScopeUtils {
      *            Class of service
      * @return Service object
      */
+    @SuppressWarnings("null")
     protected static Object getScopeService(IScope scope, String name, Class<?> defaultClass) {
         if (scope != null) {
             final IContext context = scope.getContext();
diff --git a/io/src/main/java/org/red5/cache/impl/CacheImpl.java b/io/src/main/java/org/red5/cache/impl/CacheImpl.java
index e06b50a69588fb58af3cd95dc62c68563f6c1e9e..9f64d336df418a4f33b97eddaf83d5483a3fc6c0 100644
--- a/io/src/main/java/org/red5/cache/impl/CacheImpl.java
+++ b/io/src/main/java/org/red5/cache/impl/CacheImpl.java
@@ -67,6 +67,7 @@ public class CacheImpl implements ICacheStore, ApplicationContextAware {
     private static ApplicationContext applicationContext = null;
 
     /** {@inheritDoc} */
+    @SuppressWarnings("null")
     @Override
     public void setApplicationContext(ApplicationContext context) throws BeansException {
         CacheImpl.applicationContext = context;
diff --git a/io/src/main/java/org/red5/cache/impl/EhCacheImpl.java b/io/src/main/java/org/red5/cache/impl/EhCacheImpl.java
index cb1cf46c94e0c7659c7e59f2d1cd4dead9d80ffa..71fc7ac8a85775bddf442082e3b6e791e69f27f9 100644
--- a/io/src/main/java/org/red5/cache/impl/EhCacheImpl.java
+++ b/io/src/main/java/org/red5/cache/impl/EhCacheImpl.java
@@ -59,6 +59,7 @@ public class EhCacheImpl implements ICacheStore, ApplicationContextAware {
     private CacheManager cm;
 
     /** {@inheritDoc} */
+    @SuppressWarnings("null")
     @Override
     public void setApplicationContext(ApplicationContext context) throws BeansException {
         EhCacheImpl.applicationContext = context;
diff --git a/io/src/main/java/org/red5/cache/impl/NoCacheImpl.java b/io/src/main/java/org/red5/cache/impl/NoCacheImpl.java
index 210be14daf794425d6276eab15ebadb5dfbaa20a..4d72d64db58e2b68eeb7a3e119bd5d82c2f4df70 100644
--- a/io/src/main/java/org/red5/cache/impl/NoCacheImpl.java
+++ b/io/src/main/java/org/red5/cache/impl/NoCacheImpl.java
@@ -52,6 +52,7 @@ public class NoCacheImpl implements ICacheStore, ApplicationContextAware {
     private static ApplicationContext applicationContext = null;
 
     /** {@inheritDoc} */
+    @SuppressWarnings("null")
     @Override
     public void setApplicationContext(ApplicationContext context) throws BeansException {
         NoCacheImpl.applicationContext = context;
diff --git a/io/src/main/java/org/red5/codec/AV1Video.java b/io/src/main/java/org/red5/codec/AV1Video.java
index a12cd29bea59d217a4c55b5c8c6c7acece65b909..e3c155033c08ae30c7a3bd412c0f2e7bf23dd758 100644
--- a/io/src/main/java/org/red5/codec/AV1Video.java
+++ b/io/src/main/java/org/red5/codec/AV1Video.java
@@ -8,7 +8,6 @@
 package org.red5.codec;
 
 import org.apache.mina.core.buffer.IoBuffer;
-import org.red5.io.utils.LEB128;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -32,6 +31,7 @@ public class AV1Video extends AbstractVideo {
     public static final byte[] AV1_FRAME_PREFIX = new byte[] { 0x2a, 0x01 };
 
     // buffer holding OBU's
+    @SuppressWarnings("unused")
     private IoBuffer obuBuffer;
 
     public AV1Video() {
diff --git a/io/src/main/java/org/red5/compatibility/flex/messaging/io/ArrayCollection.java b/io/src/main/java/org/red5/compatibility/flex/messaging/io/ArrayCollection.java
index 1e82886f70093a593c56e7398e7436d1fc6346c5..24cdb7187b3c1d5b64c2288700e3020f293939fd 100644
--- a/io/src/main/java/org/red5/compatibility/flex/messaging/io/ArrayCollection.java
+++ b/io/src/main/java/org/red5/compatibility/flex/messaging/io/ArrayCollection.java
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
  * @param <T>
  *            type of collection elements
  */
-public class ArrayCollection<T> implements Collection<T>, List<T>, IExternalizable {
+public class ArrayCollection<T> implements List<T>, IExternalizable {
 
     private static final Logger log = LoggerFactory.getLogger(ArrayCollection.class);
 
diff --git a/io/src/main/java/org/red5/io/amf3/Input.java b/io/src/main/java/org/red5/io/amf3/Input.java
index 2e1bd6918c598e178ae171613c35d63a882db308..d2c569c535252cbfca344dc0ee8e492c95e53760 100644
--- a/io/src/main/java/org/red5/io/amf3/Input.java
+++ b/io/src/main/java/org/red5/io/amf3/Input.java
@@ -586,7 +586,7 @@ public class Input extends org.red5.io.amf.Input {
         return super.readMap();
     }
 
-    @SuppressWarnings({ "unchecked", "rawtypes", "serial" })
+    @SuppressWarnings({ "unchecked", "rawtypes", "null", "serial" })
     @Override
     public Object readObject() {
         log.trace("readObject - amf3_mode: {}", amf3_mode);
diff --git a/io/src/main/java/org/red5/io/flv/impl/FLVReader.java b/io/src/main/java/org/red5/io/flv/impl/FLVReader.java
index 25cb1d613391600f1766d641c82af9933c9bd698..2ac6c097c3e36a320db81e008a995f51ad5ab04b 100644
--- a/io/src/main/java/org/red5/io/flv/impl/FLVReader.java
+++ b/io/src/main/java/org/red5/io/flv/impl/FLVReader.java
@@ -171,6 +171,7 @@ public class FLVReader implements IoConstants, ITagReader, IKeyFrameDataAnalyzer
      * @throws IOException
      *             on error
      */
+    @SuppressWarnings("null")
     public FLVReader(FileChannel channel) throws IOException {
         if (null == channel) {
             log.warn("Reader was passed a null channel");
diff --git a/io/src/main/java/org/red5/io/flv/meta/MetaService.java b/io/src/main/java/org/red5/io/flv/meta/MetaService.java
index 9b9b6a31d3e9dacf6509872b8c961a5ad41279aa..8a39d1b1b1ce115f1b28a228d373506791d03e0d 100644
--- a/io/src/main/java/org/red5/io/flv/meta/MetaService.java
+++ b/io/src/main/java/org/red5/io/flv/meta/MetaService.java
@@ -59,6 +59,7 @@ public class MetaService implements IMetaService {
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("null")
     @Override
     public void write(IMetaData<?, ?> meta) throws IOException {
         // Get cue points, FLV reader and writer
diff --git a/io/src/main/java/org/red5/io/m4a/impl/M4AReader.java b/io/src/main/java/org/red5/io/m4a/impl/M4AReader.java
index cff5628ec30b696443ebdde750fa6e062d27e83f..24fa8df1c5bffb8505b6d809163bbc3c7fee3d56 100644
--- a/io/src/main/java/org/red5/io/m4a/impl/M4AReader.java
+++ b/io/src/main/java/org/red5/io/m4a/impl/M4AReader.java
@@ -150,6 +150,7 @@ public class M4AReader implements IoConstants, ITagReader {
      * @throws IOException
      *             on IO error
      */
+    @SuppressWarnings("null")
     public M4AReader(File f) throws IOException {
         if (null == f) {
             log.warn("Reader was passed a null file");
diff --git a/io/src/main/java/org/red5/io/mp3/impl/MP3Reader.java b/io/src/main/java/org/red5/io/mp3/impl/MP3Reader.java
index 5dea6f6c8b488ac85d17efb3cfb75aeb68fb6bb9..0484d55e241494d34d1f6eb5e2a54a3094306074 100644
--- a/io/src/main/java/org/red5/io/mp3/impl/MP3Reader.java
+++ b/io/src/main/java/org/red5/io/mp3/impl/MP3Reader.java
@@ -21,7 +21,6 @@ import java.util.Map;
 import java.util.concurrent.Semaphore;
 
 import org.apache.mina.core.buffer.IoBuffer;
-import org.apache.tika.io.IOUtils;
 import org.apache.tika.metadata.Metadata;
 import org.apache.tika.parser.mp3.AudioFrame;
 import org.apache.tika.parser.mp3.Mp3Parser;
diff --git a/io/src/main/java/org/red5/io/mp3/impl/MP3Stream.java b/io/src/main/java/org/red5/io/mp3/impl/MP3Stream.java
index ab87e35d3de46be841b50aae82448357e7790934..05b53e0da1606f1e33c9b247e43d7b79aa3538b7 100644
--- a/io/src/main/java/org/red5/io/mp3/impl/MP3Stream.java
+++ b/io/src/main/java/org/red5/io/mp3/impl/MP3Stream.java
@@ -248,6 +248,7 @@ public class MP3Stream extends PushbackInputStream {
      *            the code for the bit rate
      * @return the bit rate in bits per second
      */
+    @SuppressWarnings("null")
     private static int calculateBitRate(int mpegVer, int layer, int code) {
         int[] arr = null;
         if (mpegVer == AudioFrame.MPEG_V1) {
diff --git a/io/src/main/java/org/red5/io/mp4/impl/MP4Reader.java b/io/src/main/java/org/red5/io/mp4/impl/MP4Reader.java
index a89922c2165b7efaa2826c5fdc3f03c393fb2a7d..074226dc0fadb02513b1082ecf64f41d6781bb25 100644
--- a/io/src/main/java/org/red5/io/mp4/impl/MP4Reader.java
+++ b/io/src/main/java/org/red5/io/mp4/impl/MP4Reader.java
@@ -249,6 +249,7 @@ public class MP4Reader implements IoConstants, ITagReader, IKeyFrameDataAnalyzer
      * @throws IOException
      *             on IO exception
      */
+    @SuppressWarnings("null")
     public MP4Reader(File f) throws IOException {
         if (null == f) {
             log.warn("Reader was passed a null file");
diff --git a/io/src/main/java/org/red5/io/utils/DOM2Writer.java b/io/src/main/java/org/red5/io/utils/DOM2Writer.java
index 2bba0bd36b872ef9852cb630fe4868f2066bd1b7..babd18e84122d9d2c13d24c932dd4b3b81788fc3 100644
--- a/io/src/main/java/org/red5/io/utils/DOM2Writer.java
+++ b/io/src/main/java/org/red5/io/utils/DOM2Writer.java
@@ -49,6 +49,7 @@ public class DOM2Writer {
      * @param out
      *            Writer object
      */
+    @SuppressWarnings("null")
     private static void print(Node node, PrintWriter out) {
         if (node == null) {
             return;
diff --git a/server/src/main/java/org/red5/net/websocket/server/DefaultServerEndpointConfigurator.java b/server/src/main/java/org/red5/net/websocket/server/DefaultServerEndpointConfigurator.java
index db0d7d91db64575aec393f7afd5d367e965c5720..5b7ca6cdfa1e36bf75b904b88c24f5c1426de227 100644
--- a/server/src/main/java/org/red5/net/websocket/server/DefaultServerEndpointConfigurator.java
+++ b/server/src/main/java/org/red5/net/websocket/server/DefaultServerEndpointConfigurator.java
@@ -161,7 +161,9 @@ public class DefaultServerEndpointConfigurator extends ServerEndpointConfig.Conf
                         }
                     }
                     log.debug("Parent scope: {} room scope: {}", parentScope, roomScope);
-                    parentScope = roomScope;
+                    if (roomScope != null) {
+                        parentScope = roomScope;
+                    }
                 }
                 // create and add the websocket scope for the new room scope
                 manager.makeScope(roomScope);
diff --git a/server/src/main/java/org/red5/server/Context.java b/server/src/main/java/org/red5/server/Context.java
index 29b22f3c979c0f6a66c5af1c9be1b7de58001d8c..9ce109826e2a87ea16c3c400e8db45bdc0b74da9 100644
--- a/server/src/main/java/org/red5/server/Context.java
+++ b/server/src/main/java/org/red5/server/Context.java
@@ -213,7 +213,7 @@ public class Context implements IContext, ApplicationContextAware, ContextMXBean
      * @param context
      *            App context
      */
-    @SuppressWarnings("resource")
+    @SuppressWarnings({ "resource", "null" })
     public void setApplicationContext(ApplicationContext context) {
         this.applicationContext = context;
         String deploymentType = System.getProperty("red5.deployment.type");
@@ -291,15 +291,11 @@ public class Context implements IContext, ApplicationContextAware, ContextMXBean
      * @throws NoSuchBeanDefinitionException
      *             When bean with given name doesn't exist
      */
+    @SuppressWarnings("null")
     public Object lookupService(String serviceName) {
         serviceName = getMappingStrategy().mapServiceName(serviceName);
         try {
-            Object bean = applicationContext.getBean(serviceName);
-            if (bean != null) {
-                return bean;
-            } else {
-                throw new ServiceNotFoundException(serviceName);
-            }
+            return applicationContext.getBean(serviceName);
         } catch (NoSuchBeanDefinitionException err) {
             throw new ServiceNotFoundException(serviceName);
         }
@@ -315,15 +311,21 @@ public class Context implements IContext, ApplicationContextAware, ContextMXBean
      *             If there's no handler for given context path
      */
     public IScopeHandler lookupScopeHandler(String contextPath) {
+        IScopeHandler scopeHandler = null;
         // Get target scope handler name
         String scopeHandlerName = getMappingStrategy().mapScopeHandlerName(contextPath);
+        // Check if scope handler name is null
+        if (scopeHandlerName == null) {
+            throw new ScopeHandlerNotFoundException(contextPath);
+        }
         // Get bean from bean factory
         Object bean = applicationContext.getBean(scopeHandlerName);
-        if (bean != null && bean instanceof IScopeHandler) {
-            return (IScopeHandler) bean;
+        if (bean instanceof IScopeHandler) {
+            scopeHandler = (IScopeHandler) bean;
         } else {
             throw new ScopeHandlerNotFoundException(scopeHandlerName);
         }
+        return scopeHandler;
     }
 
     /**
@@ -346,6 +348,7 @@ public class Context implements IContext, ApplicationContextAware, ContextMXBean
      *
      * @see org.springframework.core.io.Resource
      */
+    @SuppressWarnings("null")
     public Resource[] getResources(String pattern) throws IOException {
         return applicationContext.getResources(contextPath + pattern);
     }
@@ -359,6 +362,7 @@ public class Context implements IContext, ApplicationContextAware, ContextMXBean
      *
      * @see org.springframework.core.io.Resource
      */
+    @SuppressWarnings("null")
     public Resource getResource(String path) {
         return applicationContext.getResource(contextPath + path);
     }
@@ -382,6 +386,7 @@ public class Context implements IContext, ApplicationContextAware, ContextMXBean
     /**
      * {@inheritDoc}
      */
+    @SuppressWarnings("null")
     public boolean hasBean(String beanId) {
         return applicationContext.containsBean(beanId);
     }
@@ -395,6 +400,7 @@ public class Context implements IContext, ApplicationContextAware, ContextMXBean
      *
      * @see org.springframework.beans.factory.BeanFactory
      */
+    @SuppressWarnings("null")
     public Object getBean(String beanId) {
         // for war applications the "application" beans are not stored in the
         // sub-contexts, so look in the application context first and the core
@@ -420,6 +426,7 @@ public class Context implements IContext, ApplicationContextAware, ContextMXBean
      *
      * @see org.springframework.beans.factory.BeanFactory
      */
+    @SuppressWarnings("null")
     public Object getCoreService(String beanId) {
         return coreContext.getBean(beanId);
     }
diff --git a/server/src/main/java/org/red5/server/adapter/StatefulScopeWrappingAdapter.java b/server/src/main/java/org/red5/server/adapter/StatefulScopeWrappingAdapter.java
index 53b5ffa209422c83d22374434256c1237f66af97..1e651998e21ac064f75bbb27ecf054b7c293db60 100644
--- a/server/src/main/java/org/red5/server/adapter/StatefulScopeWrappingAdapter.java
+++ b/server/src/main/java/org/red5/server/adapter/StatefulScopeWrappingAdapter.java
@@ -314,6 +314,7 @@ public class StatefulScopeWrappingAdapter extends AbstractScopeAdapter implement
      * @throws IOException
      *             I/O exception
      */
+    @SuppressWarnings("null")
     public Resource[] getResources(String pattern) throws IOException {
         return scope.getResources(pattern);
     }
@@ -325,6 +326,7 @@ public class StatefulScopeWrappingAdapter extends AbstractScopeAdapter implement
      *            Resource name
      * @return Resource with given name
      */
+    @SuppressWarnings("null")
     public Resource getResource(String path) {
         return scope.getResource(path);
     }
diff --git a/server/src/main/java/org/red5/server/net/proxy/DebugProxyHandler.java b/server/src/main/java/org/red5/server/net/proxy/DebugProxyHandler.java
index 7d7975fc3fccf51ee9564a560a23b02a618dfda0..81e905afcfc3c3597d747a1a52f159fe42c3fef6 100644
--- a/server/src/main/java/org/red5/server/net/proxy/DebugProxyHandler.java
+++ b/server/src/main/java/org/red5/server/net/proxy/DebugProxyHandler.java
@@ -41,6 +41,7 @@ public class DebugProxyHandler extends IoHandlerAdapter implements ResourceLoade
     private String dumpTo = "./dumps/";
 
     /** {@inheritDoc} */
+    @SuppressWarnings("null")
     public void setResourceLoader(ResourceLoader loader) {
         this.loader = loader;
     }
diff --git a/server/src/main/java/org/red5/server/net/rtmp/RTMPConnManager.java b/server/src/main/java/org/red5/server/net/rtmp/RTMPConnManager.java
index a40926549a0c8bd235cd604160ac402babd2172a..0ec2eb487edd82211d3c84aa6eca166b2e05458d 100644
--- a/server/src/main/java/org/red5/server/net/rtmp/RTMPConnManager.java
+++ b/server/src/main/java/org/red5/server/net/rtmp/RTMPConnManager.java
@@ -214,6 +214,7 @@ public class RTMPConnManager implements IConnectionManager<BaseConnection>, Appl
         this.debug = debug;
     }
 
+    @SuppressWarnings("null")
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         RTMPConnManager.applicationContext = applicationContext;
     }
diff --git a/server/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaCodecFactory.java b/server/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaCodecFactory.java
index b044551a3e2e284b71139e794b64dc2e0cdf32c2..e84e575a20c24190ebd3a93d928756bca0e7a995 100644
--- a/server/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaCodecFactory.java
+++ b/server/src/main/java/org/red5/server/net/rtmp/codec/RTMPMinaCodecFactory.java
@@ -48,6 +48,7 @@ public class RTMPMinaCodecFactory implements ProtocolCodecFactory, ApplicationCo
         return encoder;
     }
 
+    @SuppressWarnings("null")
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         appCtx = applicationContext;
diff --git a/server/src/main/java/org/red5/server/net/rtmpe/RTMPEIoFilter.java b/server/src/main/java/org/red5/server/net/rtmpe/RTMPEIoFilter.java
index e3518a159c394f1ed07f70e2e7b60f290a168018..24e6efa0c6fa100d0310010eb856bbfacd9927a1 100644
--- a/server/src/main/java/org/red5/server/net/rtmpe/RTMPEIoFilter.java
+++ b/server/src/main/java/org/red5/server/net/rtmpe/RTMPEIoFilter.java
@@ -78,20 +78,25 @@ public class RTMPEIoFilter extends IoFilterAdapter {
                         byte[] dst = buffer.getBuffer(Constants.HANDSHAKE_SIZE + 1);
                         // set handshake to match client requested type
                         byte connectionType = dst[0];
-                        handshake.setHandshakeType(connectionType);
-                        log.trace("Incoming C0 connection type: {}", connectionType);
-                        IoBuffer decBuffer = IoBuffer.wrap(dst);
-                        // skip the connection type
-                        decBuffer.get();
-                        // decode it
-                        IoBuffer s1 = handshake.decodeClientRequest1(decBuffer);
-                        if (s1 != null) {
-                            // set state to indicate we're waiting for C2
-                            ((RTMPConnection) conn).setStateCode(RTMP.STATE_HANDSHAKE);
-                            //log.trace("S1 byte order: {}", s1.order());
-                            session.write(s1);
+                        if (handshake != null) {
+                            handshake.setHandshakeType(connectionType);
+                            log.trace("Incoming C0 connection type: {}", connectionType);
+                            IoBuffer decBuffer = IoBuffer.wrap(dst);
+                            // skip the connection type
+                            decBuffer.get();
+                            // decode it
+                            IoBuffer s1 = handshake.decodeClientRequest1(decBuffer);
+                            if (s1 != null) {
+                                // set state to indicate we're waiting for C2
+                                ((RTMPConnection) conn).setStateCode(RTMP.STATE_HANDSHAKE);
+                                //log.trace("S1 byte order: {}", s1.order());
+                                session.write(s1);
+                            } else {
+                                log.warn("Client was rejected due to invalid handshake");
+                                conn.close();
+                            }
                         } else {
-                            log.warn("Client was rejected due to invalid handshake");
+                            log.warn("Handshake is null");
                             conn.close();
                         }
                     }
@@ -105,22 +110,27 @@ public class RTMPEIoFilter extends IoFilterAdapter {
                         log.debug("decodeHandshakeC2");
                         // create array for decode containing C2
                         byte[] dst = buffer.getBuffer(Constants.HANDSHAKE_SIZE);
-                        if (handshake.decodeClientRequest2(IoBuffer.wrap(dst))) {
-                            log.debug("Connected");
-                            // set state to indicate we're connected
-                            ((RTMPConnection) conn).setStateCode(RTMP.STATE_CONNECTED);
-                            // remove handshake from session now that we are connected
-                            session.removeAttribute(RTMPConnection.RTMP_HANDSHAKE);
-                            // set encryption flag
-                            if (handshake.useEncryption()) {
-                                log.debug("Using encrypted communications, adding ciphers to the session");
-                                ((RTMPConnection) conn).setEncrypted(true);
-                                session.setAttribute(RTMPConnection.RTMPE_CIPHER_IN, handshake.getCipherIn());
-                                session.setAttribute(RTMPConnection.RTMPE_CIPHER_OUT, handshake.getCipherOut());
+                        if (handshake != null) {
+                            if (handshake.decodeClientRequest2(IoBuffer.wrap(dst))) {
+                                log.debug("Connected");
+                                // set state to indicate we're connected
+                                ((RTMPConnection) conn).setStateCode(RTMP.STATE_CONNECTED);
+                                // remove handshake from session now that we are connected
+                                session.removeAttribute(RTMPConnection.RTMP_HANDSHAKE);
+                                // set encryption flag
+                                if (handshake.useEncryption()) {
+                                    log.debug("Using encrypted communications, adding ciphers to the session");
+                                    ((RTMPConnection) conn).setEncrypted(true);
+                                    session.setAttribute(RTMPConnection.RTMPE_CIPHER_IN, handshake.getCipherIn());
+                                    session.setAttribute(RTMPConnection.RTMPE_CIPHER_OUT, handshake.getCipherOut());
+                                }
+                                // leave the remaining bytes in the buffer for the next step to handle / decrypt / decode
+                            } else {
+                                log.warn("Client was rejected due to invalid handshake");
+                                conn.close();
                             }
-                            // leave the remaining bytes in the buffer for the next step to handle / decrypt / decode
                         } else {
-                            log.warn("Client was rejected due to invalid handshake");
+                            log.warn("Handshake is null");
                             conn.close();
                         }
                     } else {
diff --git a/server/src/main/java/org/red5/server/net/rtmps/RTMPSIoFilter.java b/server/src/main/java/org/red5/server/net/rtmps/RTMPSIoFilter.java
index ad041a8991e21ab8e5e6045ce8a37b5cf9765211..6985c8b49f02d9ae25d3703b82f50202dcb30baa 100644
--- a/server/src/main/java/org/red5/server/net/rtmps/RTMPSIoFilter.java
+++ b/server/src/main/java/org/red5/server/net/rtmps/RTMPSIoFilter.java
@@ -75,21 +75,26 @@ public class RTMPSIoFilter extends RTMPEIoFilter {
                                 // indicates that the FP sent "POST" for a non-native rtmps connection
                                 break;
                             }
-                            handshake.setHandshakeType(connectionType);
-                            log.trace("Incoming C0 connection type: {}", connectionType);
-                            IoBuffer decBuffer = IoBuffer.wrap(dst);
-                            // skip the connection type
-                            decBuffer.get();
-                            //log.debug("C1 - buffer: {}", Hex.encodeHexString(dst));
-                            // decode it
-                            IoBuffer s1 = handshake.decodeClientRequest1(decBuffer);
-                            if (s1 != null) {
-                                // set state to indicate we're waiting for C2
-                                ((RTMPConnection) conn).setStateCode(RTMP.STATE_HANDSHAKE);
-                                //log.trace("S1 byte order: {}", s1.order());
-                                session.write(s1);
+                            if (handshake != null) {
+                                handshake.setHandshakeType(connectionType);
+                                log.trace("Incoming C0 connection type: {}", connectionType);
+                                IoBuffer decBuffer = IoBuffer.wrap(dst);
+                                // skip the connection type
+                                decBuffer.get();
+                                //log.debug("C1 - buffer: {}", Hex.encodeHexString(dst));
+                                // decode it
+                                IoBuffer s1 = handshake.decodeClientRequest1(decBuffer);
+                                if (s1 != null) {
+                                    // set state to indicate we're waiting for C2
+                                    ((RTMPConnection) conn).setStateCode(RTMP.STATE_HANDSHAKE);
+                                    //log.trace("S1 byte order: {}", s1.order());
+                                    session.write(s1);
+                                } else {
+                                    log.warn("Client was rejected due to invalid handshake");
+                                    conn.close();
+                                }
                             } else {
-                                log.warn("Client was rejected due to invalid handshake");
+                                log.warn("Handshake is null");
                                 conn.close();
                             }
                         }
@@ -101,21 +106,26 @@ public class RTMPSIoFilter extends RTMPEIoFilter {
                         log.trace("Incoming C2 size: {}", c2Size);
                         if (c2Size >= Constants.HANDSHAKE_SIZE) {
                             log.debug("decodeHandshakeC2");
-                            // create array for decode containing C2
-                            byte[] dst = buffer.getBuffer(Constants.HANDSHAKE_SIZE);
-                            if (handshake.decodeClientRequest2(IoBuffer.wrap(dst))) {
-                                log.debug("Connected, removing handshake data and adding rtmp protocol filter");
-                                // set state to indicate we're connected
-                                ((RTMPConnection) conn).setStateCode(RTMP.STATE_CONNECTED);
-                                // remove handshake from session now that we are connected
-                                session.removeAttribute(RTMPConnection.RTMP_HANDSHAKE);
-                                // add protocol filter as the last one in the chain
-                                log.debug("Adding RTMP protocol filter");
-                                session.getFilterChain().addAfter("rtmpsFilter", "protocolFilter", new ProtocolCodecFilter(new RTMPMinaCodecFactory()));
-                                // check for remaining stored bytes left over from C0C1 and prepend to the dst array
-                                // leave the remaining bytes in the buffer for the next step to handle / decrypt / decode
+                            if (handshake != null) {
+                                // create array for decode containing C2
+                                byte[] dst = buffer.getBuffer(Constants.HANDSHAKE_SIZE);
+                                if (handshake.decodeClientRequest2(IoBuffer.wrap(dst))) {
+                                    log.debug("Connected, removing handshake data and adding rtmp protocol filter");
+                                    // set state to indicate we're connected
+                                    ((RTMPConnection) conn).setStateCode(RTMP.STATE_CONNECTED);
+                                    // remove handshake from session now that we are connected
+                                    session.removeAttribute(RTMPConnection.RTMP_HANDSHAKE);
+                                    // add protocol filter as the last one in the chain
+                                    log.debug("Adding RTMP protocol filter");
+                                    session.getFilterChain().addAfter("rtmpsFilter", "protocolFilter", new ProtocolCodecFilter(new RTMPMinaCodecFactory()));
+                                    // check for remaining stored bytes left over from C0C1 and prepend to the dst array
+                                    // leave the remaining bytes in the buffer for the next step to handle / decrypt / decode
+                                } else {
+                                    log.warn("Client was rejected due to invalid handshake");
+                                    conn.close();
+                                }
                             } else {
-                                log.warn("Client was rejected due to invalid handshake");
+                                log.warn("Handshake is null");
                                 conn.close();
                             }
                         }
diff --git a/server/src/main/java/org/red5/server/net/rtmpt/RTMPTServlet.java b/server/src/main/java/org/red5/server/net/rtmpt/RTMPTServlet.java
index bb3280709e424dfd7c3c7a855f87f8095fef92dd..f46eddb99a049e2621f94666566012eebaccd079 100644
--- a/server/src/main/java/org/red5/server/net/rtmpt/RTMPTServlet.java
+++ b/server/src/main/java/org/red5/server/net/rtmpt/RTMPTServlet.java
@@ -518,6 +518,7 @@ public class RTMPTServlet extends HttpServlet {
      * @throws IOException
      *             I/O exception
      */
+    @SuppressWarnings("null")
     @Override
     protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
         if (applicationContext == null) {
@@ -531,7 +532,7 @@ public class RTMPTServlet extends HttpServlet {
             if (manager == null) {
                 log.warn("Class instance connection manager was null, looking up in application context");
                 manager = (RTMPConnManager) applicationContext.getBean("rtmpConnManager");
-                if (manager == null) {
+                if (!(manager instanceof RTMPConnManager)) {
                     log.warn("Connection manager was null in context, getting class instance");
                     manager = ((RTMPConnManager) RTMPConnManager.getInstance());
                     if (manager == null) {
diff --git a/server/src/main/java/org/red5/server/persistence/FilePersistence.java b/server/src/main/java/org/red5/server/persistence/FilePersistence.java
index c983308f9d66c2da1f8dd59e92a22cf60acc1037..30718cce47380c56df56ce982552ac29b9f07f29 100644
--- a/server/src/main/java/org/red5/server/persistence/FilePersistence.java
+++ b/server/src/main/java/org/red5/server/persistence/FilePersistence.java
@@ -170,6 +170,7 @@ public class FilePersistence extends RamPersistence {
      * @param path
      *            New path
      */
+    @SuppressWarnings("null")
     public void setPath(String path) {
         log.debug("Set path: {}", path);
         Resource rootFile = resources.getResource(path);
@@ -334,7 +335,7 @@ public class FilePersistence extends RamPersistence {
      *            Object to attach to
      * @return Persistable object
      */
-    @SuppressWarnings("deprecation")
+    @SuppressWarnings({ "deprecation", "null" })
     private IPersistable doLoad(String name, IPersistable object) {
         log.debug("doLoad - name: {} object: {}", name, object);
         IPersistable result = object;
@@ -486,6 +487,7 @@ public class FilePersistence extends RamPersistence {
      *
      *         otherwise
      */
+    @SuppressWarnings("null")
     protected boolean saveObject(IPersistable object) {
         log.debug("saveObject - object: {}", object);
         boolean result = true;
@@ -594,6 +596,7 @@ public class FilePersistence extends RamPersistence {
      * @param base
      *            Base directory
      */
+    @SuppressWarnings("null")
     protected void checkRemoveEmptyDirectories(String base) {
         if (checkForEmptyDirectories) {
             String dir;
diff --git a/server/src/main/java/org/red5/server/plugin/PluginLauncher.java b/server/src/main/java/org/red5/server/plugin/PluginLauncher.java
index be41f84abf672420a3e02ef03435abbdf201834d..9f548ad3a81cb46a7b1c8f8eeddf406067adf386 100644
--- a/server/src/main/java/org/red5/server/plugin/PluginLauncher.java
+++ b/server/src/main/java/org/red5/server/plugin/PluginLauncher.java
@@ -126,6 +126,7 @@ public class PluginLauncher implements ApplicationContextAware, InitializingBean
 
     }
 
+    @SuppressWarnings("null")
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         log.trace("Setting application context");
         this.applicationContext = applicationContext;
diff --git a/server/src/main/java/org/red5/server/scope/WebScope.java b/server/src/main/java/org/red5/server/scope/WebScope.java
index 1f0cdf32b7e6affada99b83c64243dd9c538be79..5b7388e4e6296b63b4accf8506e1d7992fffac9c 100644
--- a/server/src/main/java/org/red5/server/scope/WebScope.java
+++ b/server/src/main/java/org/red5/server/scope/WebScope.java
@@ -155,6 +155,7 @@ public class WebScope extends Scope implements ServletContextAware, WebScopeMXBe
      * @param servletContext
      *            Servlet context
      */
+    @SuppressWarnings("null")
     public void setServletContext(ServletContext servletContext) {
         this.servletContext = servletContext;
     }
diff --git a/server/src/main/java/org/red5/server/service/ShutdownServer.java b/server/src/main/java/org/red5/server/service/ShutdownServer.java
index 3a72cc807de65ab2151f4185d4b1512dde2df1b2..66bfd4d23786dca53f663df3b9b35bf6bd4de0d8 100644
--- a/server/src/main/java/org/red5/server/service/ShutdownServer.java
+++ b/server/src/main/java/org/red5/server/service/ShutdownServer.java
@@ -104,9 +104,7 @@ public class ShutdownServer implements ApplicationContextAware, InitializingBean
             // check for an embedded jee server
             jeeServer = applicationContext.getBean(LoaderBase.class);
             // lookup the jee container
-            if (jeeServer == null) {
-                log.info("JEE server was not found");
-            } else {
+            if (jeeServer != null) {
                 log.info("JEE server was found: {}", jeeServer.toString());
             }
         } catch (Exception e) {
@@ -278,6 +276,7 @@ public class ShutdownServer implements ApplicationContextAware, InitializingBean
         this.shutdownTokenFileName = shutdownTokenFileName;
     }
 
+    @SuppressWarnings("null")
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         this.applicationContext = applicationContext;
diff --git a/server/src/main/java/org/red5/server/stream/ProviderService.java b/server/src/main/java/org/red5/server/stream/ProviderService.java
index 284be3670465a57775932de10f8cf6439a812c50..29c50d64fa7cb30c17192c19ac4b04537983349b 100644
--- a/server/src/main/java/org/red5/server/stream/ProviderService.java
+++ b/server/src/main/java/org/red5/server/stream/ProviderService.java
@@ -177,6 +177,7 @@ public class ProviderService implements IProviderService {
         return scope.getBasicScope(ScopeType.BROADCAST, name) == null;
     }
 
+    @SuppressWarnings("null")
     private File getStreamFile(IScope scope, String name) {
         if (log.isDebugEnabled()) {
             log.debug("getStreamFile - name: {}", name);
diff --git a/server/src/main/java/org/red5/server/tomcat/TomcatLoader.java b/server/src/main/java/org/red5/server/tomcat/TomcatLoader.java
index cfaf47b74df711605fc88ae21487c1b18e16fe47..fb76908cf25b20e22da8edb10c102060bd425493 100644
--- a/server/src/main/java/org/red5/server/tomcat/TomcatLoader.java
+++ b/server/src/main/java/org/red5/server/tomcat/TomcatLoader.java
@@ -269,6 +269,7 @@ public class TomcatLoader extends LoaderBase implements InitializingBean, Dispos
     /**
      * Initialization.
      */
+    @SuppressWarnings("null")
     public void start() throws ServletException {
         log.info("Loading Tomcat");
         //get a reference to the current threads classloader
@@ -534,6 +535,7 @@ public class TomcatLoader extends LoaderBase implements InitializingBean, Dispos
      * @return true on success
      * @throws ServletException
      */
+    @SuppressWarnings("null")
     public boolean startWebApplication(String applicationName) throws ServletException {
         log.info("Starting Tomcat - Web application");
         boolean result = false;
diff --git a/server/src/main/java/org/red5/server/tomcat/TomcatVHostLoader.java b/server/src/main/java/org/red5/server/tomcat/TomcatVHostLoader.java
index 375a68e44d651afc0316235c89b6fae30891caf7..a02449b9f948c30bf75da138a3f6862a6fde5aee 100644
--- a/server/src/main/java/org/red5/server/tomcat/TomcatVHostLoader.java
+++ b/server/src/main/java/org/red5/server/tomcat/TomcatVHostLoader.java
@@ -79,6 +79,7 @@ public class TomcatVHostLoader extends TomcatLoader implements TomcatVHostLoader
      *
      * @throws ServletException
      */
+    @SuppressWarnings("null")
     @Override
     public void start() throws ServletException {
         log.info("Loading tomcat virtual host");
@@ -251,6 +252,7 @@ public class TomcatVHostLoader extends TomcatLoader implements TomcatVHostLoader
      * @return true on success
      * @throws ServletException
      */
+    @SuppressWarnings("null")
     public boolean startWebApplication(String applicationName) throws ServletException {
         boolean result = false;
         log.info("Starting Tomcat virtual host - Web application");
diff --git a/server/src/main/java/org/red5/server/tomcat/WarDeployer.java b/server/src/main/java/org/red5/server/tomcat/WarDeployer.java
index 173eea51aeb027c48410130b04b86886d325a5e2..94d5a183cfa53ce6fec60a21b35b164d849f348a 100644
--- a/server/src/main/java/org/red5/server/tomcat/WarDeployer.java
+++ b/server/src/main/java/org/red5/server/tomcat/WarDeployer.java
@@ -98,9 +98,7 @@ public final class WarDeployer implements ApplicationContextAware, InitializingB
             // check for an embedded jee server
             LoaderBase jeeServer = applicationContext.getBean(LoaderBase.class);
             // lookup the jee container
-            if (jeeServer == null) {
-                log.info("JEE server was not found");
-            } else {
+            if (jeeServer != null) {
                 log.info("JEE server was found: {}", jeeServer.toString());
             }
         } catch (Exception e) {
@@ -185,6 +183,7 @@ public final class WarDeployer implements ApplicationContextAware, InitializingB
         scheduler.shutdownNow();
     }
 
+    @SuppressWarnings("null")
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         this.applicationContext = applicationContext;
diff --git a/server/src/main/java/org/red5/server/util/LocalNetworkUtil.java b/server/src/main/java/org/red5/server/util/LocalNetworkUtil.java
index 9e4222ed7a09169889f8e3b618b2f9f9d4191c8c..92fc5aa7183236ecf6ed302f53545ae6469e52bb 100644
--- a/server/src/main/java/org/red5/server/util/LocalNetworkUtil.java
+++ b/server/src/main/java/org/red5/server/util/LocalNetworkUtil.java
@@ -30,6 +30,7 @@ public class LocalNetworkUtil {
      * ============================================
      * 127.0.0.1                       siteLocal: false isLoopback: true isIPV6: false
      */
+    @SuppressWarnings("null")
     public static String getCurrentEnvironmentLoopbackIp() {
         Enumeration<NetworkInterface> netInterfaces = null;
         try {
diff --git a/server/src/main/java/org/red5/server/war/WarLoaderServlet.java b/server/src/main/java/org/red5/server/war/WarLoaderServlet.java
index ecc5f540c2b2822ba02e30f6e5a087795c75d8a3..bf1ce01b349a2657dd151e1cd179c797f95dbf20 100644
--- a/server/src/main/java/org/red5/server/war/WarLoaderServlet.java
+++ b/server/src/main/java/org/red5/server/war/WarLoaderServlet.java
@@ -76,6 +76,7 @@ public class WarLoaderServlet extends ContextLoaderListener {
      * Main entry point for the Red5 Server as a war
      */
     // Notification that the web application is ready to process requests
+    @SuppressWarnings("null")
     @Override
     public void contextInitialized(ServletContextEvent sce) {
         if (null != servletContext) {
@@ -124,6 +125,7 @@ public class WarLoaderServlet extends ContextLoaderListener {
     /*
      * Registers a subcontext with red5
      */
+    @SuppressWarnings("null")
     public void registerSubContext(String webAppKey) {
         // get the sub contexts - servlet context
         ServletContext ctx = servletContext.getContext(webAppKey);
@@ -161,6 +163,7 @@ public class WarLoaderServlet extends ContextLoaderListener {
     /**
      * Clearing the in-memory configuration parameters, we will receive notification that the servlet context is about to be shut down
      */
+    @SuppressWarnings("null")
     @Override
     public void contextDestroyed(ServletContextEvent sce) {
         synchronized (servletContext) {
diff --git a/server/src/main/java/org/red5/spring/ExtendedPropertyPlaceholderConfigurer.java b/server/src/main/java/org/red5/spring/ExtendedPropertyPlaceholderConfigurer.java
index c20589c0754bbe78a09a7715e08e5071038832e3..0da3121206e2c3193e83e731b7659026be066e28 100644
--- a/server/src/main/java/org/red5/spring/ExtendedPropertyPlaceholderConfigurer.java
+++ b/server/src/main/java/org/red5/spring/ExtendedPropertyPlaceholderConfigurer.java
@@ -42,6 +42,7 @@ public class ExtendedPropertyPlaceholderConfigurer extends PropertyPlaceholderCo
 
     private Properties mergedProperties;
 
+    @SuppressWarnings("null")
     @Override
     protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException {
 
@@ -70,6 +71,7 @@ public class ExtendedPropertyPlaceholderConfigurer extends PropertyPlaceholderCo
      * @throws IOException
      *             on IO exception
      */
+    @SuppressWarnings("null")
     public void setWildcardLocations(String[] locations) throws IOException {
 
         List<Resource> resources = new ArrayList<Resource>();
@@ -132,6 +134,7 @@ public class ExtendedPropertyPlaceholderConfigurer extends PropertyPlaceholderCo
 
         private static final long serialVersionUID = -6365943736917478749L;
 
+        @SuppressWarnings("null")
         public int compare(Resource resource1, Resource resource2) {
             if (resource1 != null) {
                 if (resource2 != null) {
diff --git a/server/src/main/java/org/red5/spring/Red5ApplicationContext.java b/server/src/main/java/org/red5/spring/Red5ApplicationContext.java
index e78e7dd179b300936288fa01c2d7245fb4d8ba14..fced945676b27b481bc968893acda21ad576e05b 100644
--- a/server/src/main/java/org/red5/spring/Red5ApplicationContext.java
+++ b/server/src/main/java/org/red5/spring/Red5ApplicationContext.java
@@ -37,11 +37,13 @@ public class Red5ApplicationContext extends FileSystemXmlApplicationContext impl
         }
     }
 
+    @SuppressWarnings("null")
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         log.info("setApplicationContext: {}", applicationContext);
         this.applicationContext = applicationContext;
     }
 
+    @SuppressWarnings("null")
     @Override
     public void setParent(ApplicationContext parent) {
         super.setParent(parent);
diff --git a/server/src/test/java/org/red5/net/websocket/WebSocketServerTest.java b/server/src/test/java/org/red5/net/websocket/WebSocketServerTest.java
index cde0dc9d555842edad1539b18a30b9b40784bbbb..2db64d70c54cf497eec6199a7f6ff20e668f28e1 100644
--- a/server/src/test/java/org/red5/net/websocket/WebSocketServerTest.java
+++ b/server/src/test/java/org/red5/net/websocket/WebSocketServerTest.java
@@ -43,7 +43,6 @@ import org.apache.mina.filter.codec.ProtocolEncoderOutput;
 import org.apache.tomcat.websocket.WsRemoteEndpointImplBase;
 import org.apache.tomcat.websocket.WsSession;
 import org.apache.tomcat.websocket.WsWebSocketContainer;
-import org.junit.Test;
 import org.red5.server.adapter.MultiThreadedApplicationAdapter;
 import org.red5.server.api.scope.IScope;
 import org.red5.server.plugin.PluginRegistry;
diff --git a/server/src/test/java/org/red5/server/scope/ScopeTest.java b/server/src/test/java/org/red5/server/scope/ScopeTest.java
index 7c403b01b8461c056d051ef56f0eda213690d815..9c0b0098442bc5794fd3f129a98d4b8e185b55c3 100644
--- a/server/src/test/java/org/red5/server/scope/ScopeTest.java
+++ b/server/src/test/java/org/red5/server/scope/ScopeTest.java
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
 
+@SuppressWarnings("null")
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 @ContextConfiguration("file:src/test/resources/org/red5/server/scope/ScopeTest.xml")
 public class ScopeTest extends AbstractJUnit4SpringContextTests {
@@ -254,13 +255,13 @@ public class ScopeTest extends AbstractJUnit4SpringContextTests {
         log.info("testScopeCreationTypes-end");
     }
 
+    @SuppressWarnings("unused")
     private class Worker implements Callable<Integer> {
 
         protected final int id;
 
         protected IScope scope;
 
-        @SuppressWarnings("unused")
         protected int loops, updates, failures;
 
         public Worker(IScope appScope, int loops) {
diff --git a/server/src/test/java/org/red5/server/service/ReflectionUtilsTest.java b/server/src/test/java/org/red5/server/service/ReflectionUtilsTest.java
index 5f66ee3a6791622ca249d5985963371adcca4e6f..3c87be9abc605ccc1f56a40e8d4f9d867db2c2ae 100644
--- a/server/src/test/java/org/red5/server/service/ReflectionUtilsTest.java
+++ b/server/src/test/java/org/red5/server/service/ReflectionUtilsTest.java
@@ -1,9 +1,7 @@
 package org.red5.server.service;
 
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
diff --git a/server/src/test/java/org/red5/server/so/SharedObjectTest.java b/server/src/test/java/org/red5/server/so/SharedObjectTest.java
index 36c5e2781b396ad3a76d7745ff1455655a0030dc..955028d2841cdd6d15905e646fd983262e62b32a 100644
--- a/server/src/test/java/org/red5/server/so/SharedObjectTest.java
+++ b/server/src/test/java/org/red5/server/so/SharedObjectTest.java
@@ -50,6 +50,7 @@ import com.google.gson.Gson;
  *
  * @author Paul Gregoire (mondain@gmail.com)
  */
+@SuppressWarnings("null")
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 @ContextConfiguration(locations = { "SharedObjectTest.xml" })
 public class SharedObjectTest extends AbstractJUnit4SpringContextTests {
@@ -318,6 +319,7 @@ public class SharedObjectTest extends AbstractJUnit4SpringContextTests {
         log.info("testMissingHandler-end");
     }
 
+    @SuppressWarnings("unused")
     @Test
     public void testAttributeBlasting() throws Throwable {
         log.info("testAttributeBlasting");
@@ -338,7 +340,6 @@ public class SharedObjectTest extends AbstractJUnit4SpringContextTests {
         // fires off threads
         long start = System.nanoTime();
         // invokeAll() blocks until all tasks have run...
-        @SuppressWarnings("unused")
         List<Future<Integer>> futures = executorService.invokeAll(workers);
         log.info("Runtime: {}ms", TimeUnit.MILLISECONDS.convert(System.nanoTime() - start, TimeUnit.NANOSECONDS));
         workers.forEach(worker -> {
@@ -415,6 +416,7 @@ public class SharedObjectTest extends AbstractJUnit4SpringContextTests {
     }
 
     //@Test
+    @SuppressWarnings("unused")
     public void testAttributeBlastingJSON() throws Throwable {
         log.info("testAttributeBlastingJSON");
         SOApplication app = (SOApplication) applicationContext.getBean("web.handler");
@@ -434,7 +436,6 @@ public class SharedObjectTest extends AbstractJUnit4SpringContextTests {
         // fires off threads
         long start = System.nanoTime();
         // invokeAll() blocks until all tasks have run...
-        @SuppressWarnings("unused")
         List<Future<Integer>> futures = executorService.invokeAll(workers);
         log.info("Runtime: {}ms", TimeUnit.MILLISECONDS.convert(System.nanoTime() - start, TimeUnit.NANOSECONDS));
         workers.forEach(worker -> {
diff --git a/server/src/test/java/org/red5/server/stream/provider/FileProviderTest.java b/server/src/test/java/org/red5/server/stream/provider/FileProviderTest.java
index 3fd8978a1e782151703ea8815d14f5b5f5bf5e08..8cf4ed1e14c351e8a92674e1fe79503228d8fd51 100644
--- a/server/src/test/java/org/red5/server/stream/provider/FileProviderTest.java
+++ b/server/src/test/java/org/red5/server/stream/provider/FileProviderTest.java
@@ -27,6 +27,7 @@ public class FileProviderTest extends AbstractJUnit4SpringContextTests {
         System.setProperty("red5.deployment.type", "junit");
     }
 
+    @SuppressWarnings("null")
     @Test
     public void test() throws IOException {
         // get dummy scope