Skip to main content

[tyrus~code:f5b246e0] findbugs fixes

  • From:
  • To:
  • Subject: [tyrus~code:f5b246e0] findbugs fixes
  • Date: Wed, 7 Aug 2013 08:41:59 +0000

Project:    tyrus
Repository: code
Revision:   f5b246e0c2b6ab8da65c8de72fb363503dbebbe7
Author:     jerseyrobot
Date:       2013-08-06 08:26:54 UTC
Link:       

Log Message:
------------
findbugs fixes



Revisions:
----------
f5b246e0c2b6ab8da65c8de72fb363503dbebbe7


Modified Paths:
---------------
client/src/main/java/org/glassfish/tyrus/client/ClientManager.java
containers/grizzly/src/main/java/org/glassfish/tyrus/container/grizzly/GrizzlyClientSocket.java
core/src/main/java/org/glassfish/tyrus/core/RemoteEndpointWrapper.java
core/src/main/java/org/glassfish/tyrus/core/SessionImpl.java
core/src/main/java/org/glassfish/tyrus/core/TyrusExtension.java
core/src/main/java/org/glassfish/tyrus/core/Utils.java
protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/DataFrame.java
protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/HandShake.java
protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/uri/Match.java
protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/uri/MatchComparator.java
tests/servlet/httpsession/src/main/java/org/glassfish/tyrus/tests/servlet/httpsession/InvalidateHttpSessionEndpoint.java


Diffs:
------
--- a/client/src/main/java/org/glassfish/tyrus/client/ClientManager.java
+++ b/client/src/main/java/org/glassfish/tyrus/client/ClientManager.java
@@ -140,6 +140,7 @@ public class ClientManager extends BaseContainer 
implements WebSocketContainer {
             engineProviderClazz = 
ReflectionHelper.classForNameWithException(engineProviderClassname);
         } catch (ClassNotFoundException e) {
             collector.addException(e);
+            throw new 
RuntimeException(collector.composeComprehensiveException());
         }
         LOGGER.config(String.format("Provider class loaded: %s", 
engineProviderClassname));
         this.engine = (TyrusContainer) 
ReflectionHelper.getInstance(engineProviderClazz, collector);
@@ -283,8 +284,8 @@ public class ClientManager extends BaseContainer 
implements WebSocketContainer {
         if (clientSocket != null) {
             try {
                 // TODO - configurable timeout?
-                responseLatch.await(10, TimeUnit.SECONDS);
-                if (responseLatch.getCount() == 0) {
+                final boolean countedDown = responseLatch.await(10, 
TimeUnit.SECONDS);
+                if (countedDown) {
                     final Object exception = 
config.getUserProperties().get("org.glassfish.tyrus.client.exception");
                     if (exception != null) {
                         throw new DeploymentException("Handshake error.", 
(Throwable) exception);
--- 
a/containers/grizzly/src/main/java/org/glassfish/tyrus/container/grizzly/GrizzlyClientSocket.java
+++ 
b/containers/grizzly/src/main/java/org/glassfish/tyrus/container/grizzly/GrizzlyClientSocket.java
@@ -545,7 +545,7 @@ public class GrizzlyClientSocket implements WebSocket, 
TyrusClientSocket {
     }
 
     /**
-     * Add proxies to suplied list. Proxies will be obtained via supplied 
{@link ProxySelector} instance.
+     * Add proxies to supplied list. Proxies will be obtained via supplied 
{@link ProxySelector} instance.
      *
      * @param proxySelector proxy selector.
      * @param uri           original request {@link URI}.
@@ -562,6 +562,8 @@ public class GrizzlyClientSocket implements WebSocket, 
TyrusClientSocket {
                 case SOCKS:
                     LOGGER.log(Level.INFO, String.format("Socks proxy is not 
supported, please file new issue at https://java.net/jira/browse/TYRUS. Proxy ;
'%s' will be ignored.", p));
                     break;
+                default:
+                    break;
             }
         }
     }
--- a/core/src/main/java/org/glassfish/tyrus/core/RemoteEndpointWrapper.java
+++ b/core/src/main/java/org/glassfish/tyrus/core/RemoteEndpointWrapper.java
@@ -210,7 +210,9 @@ public abstract class RemoteEndpointWrapper implements 
RemoteEndpoint {
                                 break;
                         }
 
-                        result.get();
+                        if(result != null) {
+                            result.get();
+                        }
                     } catch (Throwable thw) {
                         sr = new SendResult(thw);
                         fsr.setFailure(thw);
--- a/core/src/main/java/org/glassfish/tyrus/core/SessionImpl.java
+++ b/core/src/main/java/org/glassfish/tyrus/core/SessionImpl.java
@@ -41,6 +41,7 @@ package org.glassfish.tyrus.core;
 
 
 import java.io.IOException;
+import java.io.Serializable;
 import java.net.URI;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
@@ -492,7 +493,7 @@ public class SessionImpl implements Session {
         return result;
     }
 
-    private class MessageHandlerComparator implements 
Comparator<MessageHandler> {
+    private static class MessageHandlerComparator implements 
Comparator<MessageHandler>, Serializable {
 
         @Override
         public int compare(MessageHandler o1, MessageHandler o2) {
--- a/core/src/main/java/org/glassfish/tyrus/core/TyrusExtension.java
+++ b/core/src/main/java/org/glassfish/tyrus/core/TyrusExtension.java
@@ -304,6 +304,8 @@ public class TyrusExtension implements Extension {
                             case ';':
                                 next = ParserState.PARAM_NAME;
                                 break;
+                            default:
+                                break;
                         }
 
                         break;--- 
a/core/src/main/java/org/glassfish/tyrus/core/Utils.java
+++ b/core/src/main/java/org/glassfish/tyrus/core/Utils.java
@@ -111,6 +111,9 @@ public class Utils {
 
                     // error - ignore for now.
                     break;
+                default:
+                    // should not happen
+                    break;
             }
         }
 --- 
a/protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/DataFrame.java
+++ 
b/protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/DataFrame.java
@@ -40,6 +40,8 @@
 
 package org.glassfish.tyrus.websockets;
 
+import java.util.Arrays;
+
 /**
  * In memory representation of a websocket frame.
  *
@@ -88,7 +90,7 @@ public class DataFrame {
     }
 
     public void setPayload(byte[] bytes) {
-        this.bytes = bytes;
+        this.bytes = Arrays.copyOf(bytes, bytes.length);
     }
 
     public byte[] getBytes() {--- 
a/protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/HandShake.java
+++ 
b/protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/HandShake.java
@@ -560,6 +560,8 @@ public abstract class HandShake {
                             case ';':
                                 next = ParserState.PARAM_NAME;
                                 break;
+                            default:
+                                break;
                         }
 
                         break;--- 
a/protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/uri/Match.java
+++ 
b/protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/uri/Match.java
@@ -162,14 +162,14 @@ public class Match {
     }
 
     private String paramsToString() {
-        String s = "";
+        StringBuilder sb = new StringBuilder();
         for (String nextName : this.parameterNames) {
-            s = s + nextName + "=" + this.getParameterValue(nextName);
+            
sb.append(nextName).append("=").append(this.getParameterValue(nextName));
             if (this.parameterNames.indexOf(nextName) != 
this.parameterNames.size() - 1) {
-                s = s + ",";
+                sb.append(",");
             }
         }
-        return s;
+        return sb.toString();
     }
 
     /**--- 
a/protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/uri/MatchComparator.java
+++ 
b/protocol/websocket/src/main/java/org/glassfish/tyrus/websockets/uri/MatchComparator.java
@@ -39,6 +39,7 @@
  */
 package org.glassfish.tyrus.websockets.uri;
 
+import java.io.Serializable;
 import java.util.Comparator;
 import java.util.List;
 
@@ -47,8 +48,8 @@ import java.util.List;
  *
  * @author dannycoward
  */
-class MatchComparator implements Comparator<Match> {
-    private final boolean noisy = false;
+class MatchComparator implements Comparator<Match>, Serializable {
+    private final static boolean noisy = false;
 
     private void debug(String message) {
         if (noisy) System.out.println(message);--- 
a/tests/servlet/httpsession/src/main/java/org/glassfish/tyrus/tests/servlet/httpsession/InvalidateHttpSessionEndpoint.java
+++ 
b/tests/servlet/httpsession/src/main/java/org/glassfish/tyrus/tests/servlet/httpsession/InvalidateHttpSessionEndpoint.java
@@ -58,7 +58,7 @@ import javax.servlet.http.HttpSession;
 @ServerEndpoint(value = "/invalidateHttpSession", configurator = 
InvalidateHttpSessionEndpoint.Configurator.class)
 public class InvalidateHttpSessionEndpoint {
 
-    protected static HandshakeRequest request;
+    private static HandshakeRequest request;
     private static CloseReason closeReason = null;
 
     public static class Configurator extends 
ServerEndpointConfig.Configurator {





[tyrus~code:f5b246e0] findbugs fixes

jerseyrobot 08/07/2013
 
 
Close
loading
Please Confirm
Close