DaanHoogland commented on code in PR #6348:
URL: https://github.com/apache/cloudstack/pull/6348#discussion_r863511815
##########
agent/src/main/java/com/cloud/agent/AgentShell.java:
##########
@@ -539,10 +527,6 @@ public void start() {
s_logger.debug("[ignored] AgentShell was interrupted.");
}
- } catch (final ConfigurationException e) {
- s_logger.error("Unable to start agent: " + e.getMessage());
- System.out.println("Unable to start agent: " + e.getMessage());
- System.exit(ExitStatus.Configuration.value());
} catch (final Exception e) {
s_logger.error("Unable to start agent: ", e);
Review Comment:
maybe get rid of the `System.out.println(..)` below as well?
##########
agent/src/main/java/com/cloud/agent/AgentShell.java:
##########
@@ -437,25 +436,14 @@ private void launchAgentFromClassInfo(String
resourceClassNames) throws Configur
Class<?> impl;
try {
impl = Class.forName(name);
- final Constructor<?> constructor =
impl.getDeclaredConstructor();
+ Constructor<?> constructor = impl.getDeclaredConstructor();
constructor.setAccessible(true);
ServerResource resource =
(ServerResource)constructor.newInstance();
launchNewAgent(resource);
- } catch (final ClassNotFoundException e) {
- throw new ConfigurationException("Resource class not found: "
+ name + " due to: " + e.toString());
- } catch (final SecurityException e) {
- throw new ConfigurationException("Security exception when
loading resource: " + name + " due to: " + e.toString());
- } catch (final NoSuchMethodException e) {
- throw new ConfigurationException("Method not found exception
when loading resource: " + name + " due to: " + e.toString());
- } catch (final IllegalArgumentException e) {
- throw new ConfigurationException("Illegal argument exception
when loading resource: " + name + " due to: " + e.toString());
- } catch (final InstantiationException e) {
- throw new ConfigurationException("Instantiation exception when
loading resource: " + name + " due to: " + e.toString());
- } catch (final IllegalAccessException e) {
- throw new ConfigurationException("Illegal access exception
when loading resource: " + name + " due to: " + e.toString());
- } catch (final InvocationTargetException e) {
- throw new ConfigurationException("Invocation target exception
when loading resource: " + name + " due to: " + e.toString());
- }
+ } catch (final Exception e) {
Review Comment:
Can we not do a pokemon catch, but a catch of specific `Exception`'s, please?
i.e.
```suggestion
} catch (final ClassNotFoundException | SecurityException |
NoSuchMethodException | IllegalArgumentException | InstantiationException |
IllegalAccessException | InvocationTargetException e) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]