Skip to content
Snippets Groups Projects
Commit b12b1521 authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

pmd fixes, disabled one custom rule and made Configuration not abstract

parent d625386d
Branches
Tags
No related merge requests found
......@@ -100,7 +100,9 @@
<exclude name="SimplifyStartsWith" />
</rule>
<rule ref="rulesets/chw/basic.xml" />
<rule ref="rulesets/chw/basic.xml">
<exclude name="NonHeaderCommentSize"/>
</rule>
<!-- <rule ref="rulesets/chw/basic.xml/NonHeaderCommentSize"> -->
<!-- <properties> -->
......
......@@ -26,7 +26,7 @@ import teetime.framework.exceptionHandling.TerminatingExceptionListenerFactory;
* @since 2.0
*
*/
public abstract class Configuration extends AbstractCompositeStage {
public class Configuration extends AbstractCompositeStage {
private final AbstractExceptionListenerFactory<?> factory;
private final ConfigurationContext context;
......@@ -35,11 +35,11 @@ public abstract class Configuration extends AbstractCompositeStage {
private boolean executed;
private AbstractStage startStage;
protected Configuration() {
public Configuration() {
this(new TerminatingExceptionListenerFactory());
}
protected Configuration(final AbstractExceptionListenerFactory<?> factory) {
public Configuration(final AbstractExceptionListenerFactory<?> factory) {
this.factory = factory;
this.context = new ConfigurationContext(this);
}
......@@ -52,15 +52,15 @@ public abstract class Configuration extends AbstractCompositeStage {
this.initialized = executed;
}
public boolean isExecuted() {
boolean isExecuted() {
return executed;
}
public void setExecuted(final boolean executed) {
void setExecuted(final boolean executed) {
this.executed = executed;
}
public AbstractExceptionListenerFactory<?> getFactory() {
AbstractExceptionListenerFactory<?> getFactory() {
return factory;
}
......@@ -70,12 +70,12 @@ public abstract class Configuration extends AbstractCompositeStage {
* @param pipe
* A custom pipe instance
*/
protected void registerCustomPipe(final AbstractPipe<?> pipe) {
public void registerCustomPipe(final AbstractPipe<?> pipe) {
startStage = pipe.getSourcePort().getOwningStage(); // memorize an arbitrary stage as starting point for traversing
}
@Override
protected <T> void connectPorts(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) {
public <T> void connectPorts(final OutputPort<? extends T> sourcePort, final InputPort<T> targetPort, final int capacity) {
startStage = sourcePort.getOwningStage(); // memorize an arbitrary stage as starting point for traversing
super.connectPorts(sourcePort, targetPort, capacity);
}
......
......@@ -87,7 +87,7 @@ public final class Execution<T extends Configuration> {
// // portConnectionValidator.validate(stage);
// }
final ValidatingSignal validatingSignal = new ValidatingSignal();
final ValidatingSignal validatingSignal = new ValidatingSignal(); // NOPMD we need a new instance every iteration
stage.onSignal(validatingSignal, null);
if (validatingSignal.getInvalidPortConnections().size() > 0) {
throw new AnalysisNotValidException(validatingSignal.getInvalidPortConnections());
......@@ -99,7 +99,7 @@ public final class Execution<T extends Configuration> {
* This initializes the analysis and needs to be run right before starting it.
*
*/
private final void init() {
private void init() {
configurationContext.initializeServices();
}
......
......@@ -31,7 +31,7 @@ public class IntraStageCollector implements ITraverserVisitor {
public VisitorBehavior visit(final AbstractStage stage) {
if (stage.equals(startStage) || stage.getOwningThread() == null /* before execution */
|| stage.getOwningThread() == startStage.getOwningThread() /* while execution */) {
return VisitorBehavior.CONTINUE;
return VisitorBehavior.CONTINUE; // NOPMD two return stmts make the code clearer to understand
}
return VisitorBehavior.STOP;
}
......
......@@ -52,6 +52,7 @@ final class RunnableConsumerStage extends AbstractRunnableStage {
for (InputPort<?> inputPort : stage.getInputPorts()) {
if (inputPort.isClosed()) {
// stage.removeDynamicPort(inputPort);
break;
} else {
return;
}
......@@ -62,7 +63,7 @@ final class RunnableConsumerStage extends AbstractRunnableStage {
@Override
protected void afterStageExecution() {
final ISignal signal = new TerminatingSignal();
final ISignal signal = new TerminatingSignal(); // NOPMD DU caused by loop
for (InputPort<?> inputPort : stage.getInputPorts()) {
stage.onSignal(signal, inputPort);
}
......
......@@ -31,8 +31,10 @@ public class TeeTimeThread extends Thread {
}
@Override
public synchronized void start() {
public void start() {
synchronized (this) {
runnable.stage.getOwningContext().getThreadService().getRunnableCounter().inc();
super.start();
}
}
}
......@@ -15,7 +15,6 @@
*/
package teetime.framework;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
......@@ -35,7 +34,7 @@ import teetime.util.framework.concurrent.SignalingCounter;
*
* @since 2.0
*/
class ThreadService extends AbstractService<ThreadService> {
class ThreadService extends AbstractService<ThreadService> { // NOPMD
private static final Logger LOGGER = LoggerFactory.getLogger(ThreadService.class);
......@@ -172,25 +171,25 @@ class ThreadService extends AbstractService<ThreadService> {
thread.interrupt();
}
List<Exception> exceptions = collectExceptions();
if (!exceptions.isEmpty()) {
// List<Exception> exceptions = collectExceptions();
// if (!exceptions.isEmpty()) {
// throw new ExecutionException(exceptions);
// }
}
}
// TODO impl throw exception
private List<Exception> collectExceptions() {
// Collection<ThreadThrowableContainer> exceptions = new ConcurrentLinkedQueue<ThreadThrowableContainer>();
List<Exception> exceptions = new ArrayList<Exception>();
// for (Stage stage : threadableStages.keySet()) {
// List<Exception> stageExceptions = stage.exceptionListener.getExceptions();
// exceptions.addAll(stageExceptions);
// TODO impl throw exception... see line 175
// private List<Exception> collectExceptions() {
// // Collection<ThreadThrowableContainer> exceptions = new ConcurrentLinkedQueue<ThreadThrowableContainer>();
// List<Exception> exceptions = new ArrayList<Exception>();
//
// // for (Stage stage : threadableStages.keySet()) {
// // List<Exception> stageExceptions = stage.exceptionListener.getExceptions();
// // exceptions.addAll(stageExceptions);
// // }
//
// return exceptions;
// }
return exceptions;
}
Set<AbstractStage> getThreadableStages() {
return threadableStages;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment