mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
Merge pull request #34 from glyptodon/fix-static-defects
GUAC-969: Fix defects from recent static analysis.
This commit is contained in:
@@ -40,7 +40,7 @@ public class FilteredGuacamoleReaderTest {
|
|||||||
/**
|
/**
|
||||||
* Filter which allows through "yes" instructions but drops all others.
|
* Filter which allows through "yes" instructions but drops all others.
|
||||||
*/
|
*/
|
||||||
private class TestFilter implements GuacamoleFilter {
|
private static class TestFilter implements GuacamoleFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GuacamoleInstruction filter(GuacamoleInstruction instruction) throws GuacamoleException {
|
public GuacamoleInstruction filter(GuacamoleInstruction instruction) throws GuacamoleException {
|
||||||
|
@@ -40,7 +40,7 @@ public class FilteredGuacamoleWriterTest {
|
|||||||
/**
|
/**
|
||||||
* Filter which allows through "yes" instructions but drops all others.
|
* Filter which allows through "yes" instructions but drops all others.
|
||||||
*/
|
*/
|
||||||
private class TestFilter implements GuacamoleFilter {
|
private static class TestFilter implements GuacamoleFilter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GuacamoleInstruction filter(GuacamoleInstruction instruction) throws GuacamoleException {
|
public GuacamoleInstruction filter(GuacamoleInstruction instruction) throws GuacamoleException {
|
||||||
|
@@ -239,6 +239,12 @@ public class LocalEnvironment implements Environment {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Warn if directory contents are not available
|
||||||
|
if (files == null) {
|
||||||
|
logger.error("Unable to read contents of \"{}\".", protocol_directory.getAbsolutePath());
|
||||||
|
files = new File[0];
|
||||||
|
}
|
||||||
|
|
||||||
// Load each protocol from each file
|
// Load each protocol from each file
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
|
|
||||||
|
@@ -140,8 +140,13 @@ public class DocumentHandler extends DefaultHandler {
|
|||||||
public void characters(char[] ch, int start, int length)
|
public void characters(char[] ch, int start, int length)
|
||||||
throws SAXException {
|
throws SAXException {
|
||||||
|
|
||||||
|
// Get current state
|
||||||
|
DocumentHandlerState current = getCurrentState();
|
||||||
|
if (current == null)
|
||||||
|
throw new SAXException("Character data not allowed outside XML document.");
|
||||||
|
|
||||||
// Append received chunk to text content
|
// Append received chunk to text content
|
||||||
getCurrentState().getTextContent().append(ch, start, length);
|
current.getTextContent().append(ch, start, length);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -105,7 +105,7 @@ public class GuacamoleClassLoader extends ClassLoader {
|
|||||||
|
|
||||||
// Get list of URLs for all .jar's in the lib directory
|
// Get list of URLs for all .jar's in the lib directory
|
||||||
Collection<URL> jarURLs = new ArrayList<URL>();
|
Collection<URL> jarURLs = new ArrayList<URL>();
|
||||||
for (File file : libDirectory.listFiles(new FilenameFilter() {
|
File[] files = libDirectory.listFiles(new FilenameFilter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
@@ -115,13 +115,17 @@ public class GuacamoleClassLoader extends ClassLoader {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})) {
|
});
|
||||||
|
|
||||||
|
// Verify directory was successfully read
|
||||||
|
if (files == null)
|
||||||
|
throw new GuacamoleException("Unable to read contents of directory " + libDirectory);
|
||||||
|
|
||||||
|
// Add the URL for each .jar to the jar URL list
|
||||||
|
for (File file : files) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Add URL for the .jar to the jar URL list
|
|
||||||
jarURLs.add(file.toURI().toURL());
|
jarURLs.add(file.toURI().toURL());
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (MalformedURLException e) {
|
catch (MalformedURLException e) {
|
||||||
throw new GuacamoleException(e);
|
throw new GuacamoleException(e);
|
||||||
|
@@ -37,7 +37,6 @@ import javax.ws.rs.QueryParam;
|
|||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import org.glyptodon.guacamole.GuacamoleClientException;
|
import org.glyptodon.guacamole.GuacamoleClientException;
|
||||||
import org.glyptodon.guacamole.GuacamoleException;
|
import org.glyptodon.guacamole.GuacamoleException;
|
||||||
import org.glyptodon.guacamole.GuacamoleResourceNotFoundException;
|
|
||||||
import org.glyptodon.guacamole.net.auth.Connection;
|
import org.glyptodon.guacamole.net.auth.Connection;
|
||||||
import org.glyptodon.guacamole.net.auth.ConnectionGroup;
|
import org.glyptodon.guacamole.net.auth.ConnectionGroup;
|
||||||
import org.glyptodon.guacamole.net.auth.ConnectionRecord;
|
import org.glyptodon.guacamole.net.auth.ConnectionRecord;
|
||||||
@@ -130,11 +129,6 @@ public class ConnectionRESTService {
|
|||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
UserContext userContext = authenticationService.getUserContext(authToken);
|
||||||
|
|
||||||
// Get the connection directory
|
|
||||||
ConnectionGroup rootGroup = userContext.getRootConnectionGroup();
|
|
||||||
Directory<String, Connection> connectionDirectory =
|
|
||||||
rootGroup.getConnectionDirectory();
|
|
||||||
|
|
||||||
// Retrieve the requested connection
|
// Retrieve the requested connection
|
||||||
Connection connection = retrievalService.retrieveConnection(userContext, connectionID);
|
Connection connection = retrievalService.retrieveConnection(userContext, connectionID);
|
||||||
|
|
||||||
@@ -171,11 +165,6 @@ public class ConnectionRESTService {
|
|||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
UserContext userContext = authenticationService.getUserContext(authToken);
|
||||||
|
|
||||||
// Get the connection directory
|
|
||||||
ConnectionGroup rootGroup = userContext.getRootConnectionGroup();
|
|
||||||
Directory<String, Connection> connectionDirectory =
|
|
||||||
rootGroup.getConnectionDirectory();
|
|
||||||
|
|
||||||
// Retrieve the requested connection's history
|
// Retrieve the requested connection's history
|
||||||
Connection connection = retrievalService.retrieveConnection(userContext, connectionID);
|
Connection connection = retrievalService.retrieveConnection(userContext, connectionID);
|
||||||
return connection.getHistory();
|
return connection.getHistory();
|
||||||
|
@@ -111,7 +111,6 @@ public class ConnectionGroupRESTService {
|
|||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
User self = userContext.self();
|
User self = userContext.self();
|
||||||
ConnectionGroup rootGroup = userContext.getRootConnectionGroup();
|
|
||||||
|
|
||||||
// Retrieve specified connection group
|
// Retrieve specified connection group
|
||||||
ConnectionGroup connectionGroup;
|
ConnectionGroup connectionGroup;
|
||||||
|
Reference in New Issue
Block a user