Wei Liu's assignment2 for SOEN6591
Slides: https://docs.google.com/presentation/d/1KbaMDtO5d2aPycI-R6cXKcLZzzbE_Qo1SElT3GO2nN8/edit?usp=sharing
Application | Version | Java files | catch clause | basic instances | advanced instances |
---|---|---|---|---|---|
Apache CloudStack | 4.9.0 | 4646 | 8,970,528 | 174,610 | 0 |
/result_destructive_wrapper.txt (https://github.com/liuwei-tianshu/WeiLiu-a2_SOEN-6591/blob/main/result_destructive_wrapper.txt)
Most of calling method in catch clause is like this:
catch (Exception e) {
unassignAsa1000vFromNetwork(network);
ExceptionUtil.rethrowRuntime(e);
ExceptionUtil.rethrow(e,InsufficientAddressCapacityException.class);
ExceptionUtil.rethrow(e,ResourceUnavailableException.class);
throw new IllegalStateException(e);
}
However, the function ExceptionUtil is like this:
@SuppressWarnings("unchecked")
public static <T extends Throwable> void rethrow(Throwable t, Class<T> clz) throws T {
if (clz.isAssignableFrom(t.getClass()))
throw (T)t;
}
public static <T extends Throwable> void rethrowRuntime(Throwable t) {
rethrow(t, RuntimeException.class);
rethrow(t, Error.class);
}
According to the definition of Destructive Wrapping, it is not instance of anti-pattern.
First line in the outputfile /result_destructive_wrapper.txt:
<system>cloudstack-4.9</system><callsite>.AgentShell.launchAgentFromClassInfo</callsite><line>368</line>
where, AgentShell is the class name while launchAgentFromClassInfo is the method name, 368 is the line of anti-pattern.
check the Line 368 on Java file AgentShell.java to verify the destructive wrapping :https://github.com/apache/cloudstack/blob/master/agent/src/main/java/com/cloud/agent/AgentShell.java