mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +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.
|
||||
*/
|
||||
private class TestFilter implements GuacamoleFilter {
|
||||
private static class TestFilter implements GuacamoleFilter {
|
||||
|
||||
@Override
|
||||
public GuacamoleInstruction filter(GuacamoleInstruction instruction) throws GuacamoleException {
|
||||
|
@@ -40,7 +40,7 @@ public class FilteredGuacamoleWriterTest {
|
||||
/**
|
||||
* Filter which allows through "yes" instructions but drops all others.
|
||||
*/
|
||||
private class TestFilter implements GuacamoleFilter {
|
||||
private static class TestFilter implements GuacamoleFilter {
|
||||
|
||||
@Override
|
||||
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
|
||||
for (File file : files) {
|
||||
|
||||
|
@@ -140,8 +140,13 @@ public class DocumentHandler extends DefaultHandler {
|
||||
public void characters(char[] ch, int start, int length)
|
||||
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
|
||||
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
|
||||
Collection<URL> jarURLs = new ArrayList<URL>();
|
||||
for (File file : libDirectory.listFiles(new FilenameFilter() {
|
||||
File[] files = libDirectory.listFiles(new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
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 {
|
||||
|
||||
// Add URL for the .jar to the jar URL list
|
||||
jarURLs.add(file.toURI().toURL());
|
||||
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
throw new GuacamoleException(e);
|
||||
|
@@ -37,7 +37,6 @@ import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import org.glyptodon.guacamole.GuacamoleClientException;
|
||||
import org.glyptodon.guacamole.GuacamoleException;
|
||||
import org.glyptodon.guacamole.GuacamoleResourceNotFoundException;
|
||||
import org.glyptodon.guacamole.net.auth.Connection;
|
||||
import org.glyptodon.guacamole.net.auth.ConnectionGroup;
|
||||
import org.glyptodon.guacamole.net.auth.ConnectionRecord;
|
||||
@@ -130,11 +129,6 @@ public class ConnectionRESTService {
|
||||
|
||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
||||
|
||||
// Get the connection directory
|
||||
ConnectionGroup rootGroup = userContext.getRootConnectionGroup();
|
||||
Directory<String, Connection> connectionDirectory =
|
||||
rootGroup.getConnectionDirectory();
|
||||
|
||||
// Retrieve the requested connection
|
||||
Connection connection = retrievalService.retrieveConnection(userContext, connectionID);
|
||||
|
||||
@@ -171,11 +165,6 @@ public class ConnectionRESTService {
|
||||
|
||||
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
|
||||
Connection connection = retrievalService.retrieveConnection(userContext, connectionID);
|
||||
return connection.getHistory();
|
||||
|
@@ -111,7 +111,6 @@ public class ConnectionGroupRESTService {
|
||||
throws GuacamoleException {
|
||||
|
||||
User self = userContext.self();
|
||||
ConnectionGroup rootGroup = userContext.getRootConnectionGroup();
|
||||
|
||||
// Retrieve specified connection group
|
||||
ConnectionGroup connectionGroup;
|
||||
|
Reference in New Issue
Block a user