GUACAMOLE-1218: Use diamond operator and multi-catch where possible.

This commit is contained in:
Michael Jumper
2020-11-29 16:15:06 -08:00
parent 66d28b8424
commit 95c4bb427f
4 changed files with 10 additions and 27 deletions

View File

@@ -147,22 +147,12 @@ public class CryptoService {
} }
// Rethrow all decryption failures identically // Rethrow all decryption failures identically
catch (InvalidAlgorithmParameterException e) { catch (InvalidAlgorithmParameterException
throw new GuacamoleServerException(e); | NoSuchAlgorithmException
} | NoSuchPaddingException
catch (NoSuchAlgorithmException e) { | InvalidKeyException
throw new GuacamoleServerException(e); | IllegalBlockSizeException
} | BadPaddingException e) {
catch (NoSuchPaddingException e) {
throw new GuacamoleServerException(e);
}
catch (InvalidKeyException e) {
throw new GuacamoleServerException(e);
}
catch (IllegalBlockSizeException e) {
throw new GuacamoleServerException(e);
}
catch (BadPaddingException e) {
throw new GuacamoleServerException(e); throw new GuacamoleServerException(e);
} }
@@ -200,13 +190,7 @@ public class CryptoService {
} }
// Rethrow all signature failures identically // Rethrow all signature failures identically
catch (NoSuchAlgorithmException e) { catch (NoSuchAlgorithmException | InvalidKeyException | IllegalStateException e) {
throw new GuacamoleServerException(e);
}
catch (InvalidKeyException e) {
throw new GuacamoleServerException(e);
}
catch (IllegalStateException e) {
throw new GuacamoleServerException(e); throw new GuacamoleServerException(e);
} }

View File

@@ -78,7 +78,7 @@ public class RequestValidationService {
} }
// Build matchers for each trusted network // Build matchers for each trusted network
Collection<IpAddressMatcher> matchers = new ArrayList<IpAddressMatcher>(trustedNetworks.size()); Collection<IpAddressMatcher> matchers = new ArrayList<>(trustedNetworks.size());
for (String network : trustedNetworks) for (String network : trustedNetworks)
matchers.add(new IpAddressMatcher(network)); matchers.add(new IpAddressMatcher(network));

View File

@@ -342,7 +342,7 @@ public class UserData {
* connection. * connection.
*/ */
public void setConnections(Map<String, Connection> connections) { public void setConnections(Map<String, Connection> connections) {
this.connections = new ConcurrentHashMap<String, Connection>(connections); this.connections = new ConcurrentHashMap<>(connections);
} }
/** /**

View File

@@ -46,8 +46,7 @@ public class UserDataDenylist {
* string produced by encoding the binary signature using DatatypeConverter. * string produced by encoding the binary signature using DatatypeConverter.
* A byte[] cannot be used directly. * A byte[] cannot be used directly.
*/ */
private final ConcurrentMap<String, UserData> denylist = private final ConcurrentMap<String, UserData> denylist = new ConcurrentHashMap<>();
new ConcurrentHashMap<String, UserData>();
/** /**
* Removes all expired UserData objects from the denylist. This will * Removes all expired UserData objects from the denylist. This will