New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INT-3485 Remove final Modifier AbstractEndpoint.stop(Runnable callback) #1241
Conversation
Thanks for your contribution! However, I should have been a little clearer in the JIRA description; we'd prefer to use this technique...
allowing the subclass to override the |
Thanks Gary, makes much more sense. Please see updated, and a simple test for arguments sake: package org.springframework.integration.endpoint;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
/**
* @author Kris Jacyna
*/
public class CustomPollingConsumerEndpointTests {
private CustomEndpoint endpoint;
@Before
public void init() throws Exception {
endpoint = new CustomEndpoint();
endpoint.setBeanFactory(mock(BeanFactory.class));
endpoint.afterPropertiesSet();
}
@Test
public void customDoStop() {
assertEquals(0, endpoint.getCount());
endpoint.stop(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000L);
} catch (final Exception e) {}
}
});
assertEquals(1, endpoint.getCount());
}
private static class CustomEndpoint extends AbstractEndpoint {
private final AtomicInteger count = new AtomicInteger(0);
public int getCount() {
return this.count.get();
}
@Override
protected void doStop(final Runnable callback) {
this.count.incrementAndGet();
super.doStop(callback);
}
@Override
protected void doStart() {
// start
}
@Override
protected void doStop() {
// stop
}
}
} |
* @param callback the Runnable to invoke | ||
*/ | ||
protected void doStop(Runnable callback) { | ||
this.stop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KaPr , thank you for contribution!
Here you should really invoke that abstract doStop()
, not stop()
with one more lock
acquiring.
Further:
- The test-case on the matter is required.
- Add your name to author list
- Update
copyright
- Minor: do not use
this.
for methods - no blank lines in the method JavaDocs
For the future: please, correctly format your first commit message:
- headline <= 50 symbols
- JIRA link over a blank line after header
- Some minor description
I think |
…dded unit test for custom doStop(runnable)
Thanks Artem for the feedback, I have updated as follows:
I didn't remove Thanks |
Is there anyway to get more info from the travis build? |
No; they blow away the VM; if we get a reliable failure, we add --debug to the build. However, don't worry about that failure - it's probably a timing issue (happens from time to time). I'll re-kick the build on Travis. Thanks again!! |
LGTM Looking forward for more contribution! |
Merged via: d2da161 |
Thanks guys |
JIRA: https://jira.spring.io/browse/INT-3485
I have signed and agree to the terms of the SpringSource Individual Contributor License Agreement.