Repository: incubator-guacamole-client
Updated Branches:
  refs/heads/master b0eef60e1 -> fafcbf0dd


GUACAMOLE-5: Throw clean "resource not found" if the active connection of a 
tunnel cannot be determined.

Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/a5af6c00
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/a5af6c00
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/a5af6c00

Branch: refs/heads/master
Commit: a5af6c00d249ffc7d5c50414541545e53cad3f4c
Parents: b0eef60
Author: Michael Jumper <[email protected]>
Authored: Mon Jul 25 14:10:54 2016 -0700
Committer: Michael Jumper <[email protected]>
Committed: Mon Jul 25 14:34:54 2016 -0700

----------------------------------------------------------------------
 .../org/apache/guacamole/rest/tunnel/TunnelResource.java    | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/a5af6c00/guacamole/src/main/java/org/apache/guacamole/rest/tunnel/TunnelResource.java
----------------------------------------------------------------------
diff --git 
a/guacamole/src/main/java/org/apache/guacamole/rest/tunnel/TunnelResource.java 
b/guacamole/src/main/java/org/apache/guacamole/rest/tunnel/TunnelResource.java
index 6583a07..b498527 100644
--- 
a/guacamole/src/main/java/org/apache/guacamole/rest/tunnel/TunnelResource.java
+++ 
b/guacamole/src/main/java/org/apache/guacamole/rest/tunnel/TunnelResource.java
@@ -30,6 +30,7 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.GuacamoleResourceNotFoundException;
 import org.apache.guacamole.net.auth.ActiveConnection;
 import org.apache.guacamole.net.auth.UserContext;
 import org.apache.guacamole.rest.activeconnection.APIActiveConnection;
@@ -96,10 +97,14 @@ public class TunnelResource {
         // Pull the UserContext from the tunnel
         UserContext userContext = tunnel.getUserContext();
 
+        // Fail if the active connection cannot be found
+        ActiveConnection activeConnection = tunnel.getActiveConnection();
+        if (activeConnection == null)
+            throw new GuacamoleResourceNotFoundException("No readable active 
connection for tunnel.");
+
         // Return the associated ActiveConnection as a resource
         return activeConnectionResourceFactory.create(userContext,
-                userContext.getActiveConnectionDirectory(),
-                tunnel.getActiveConnection());
+                userContext.getActiveConnectionDirectory(), activeConnection);
 
     }
 

Reply via email to