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

MessageConstructionInterceptor causes StackOverflowError #139

Closed
hoeckxer opened this Issue Oct 19, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@hoeckxer

hoeckxer commented Oct 19, 2016

Version: 2.6.1

When running a simple test case, I get an error java.lang.StackOverflowError at com.consol.citrus.validation.interceptor.MessageConstructionInterceptors.interceptMessageConstruction(MessageConstructionInterceptors.java:42). It looks like this is caused by the fact that the MessageConstructionInterceptors implements the same interface that it is autowiring into itself (being MessageConstructionInterceptor).

This message appears after we've upgraded Spring boot from 1.3.1 to 1.4.1, which in turn causes a new Spring framework version (4.3.3 vs 4.2.4 previously) to be used. I suspect there is something in Spring which doesn't figure out that the class shouldn't autowire itself.

I noticed in the master branch that the interface-implementation of MessageConstructionInterceptor has been removed, which I believe effectively fixes this issue. However, it doesn't seem like this issue is put into the bugfix branch. Is it possible to release this fix under a 2.6.2 version? At the moment the test no longer runs unfortunately.

@christophd

This comment has been minimized.

Member

christophd commented Oct 20, 2016

The behavior has changed from Spring 4.2.x to 4.3.x We have fixed that in 2.7 master as you have already mentioned. I think doing the Spring upgrade in Citrus 2.6.x bugfix branch is not applicable as it would break other projects that need to stay with Spring 4.2.x for some reason. This is a bigger step that is not applicable for bugfix branch.

Citrus 2.7 release is planned for next month. Nightly 2.7-SNAPSHOT is available, so you can use this version right now. The 2.7-SNAPSHOT is released on consol.labs snapshot repository (http://labs.consol.de/maven/snapshots-repository/) so you may add this to your Maven POM as snapshot repository.

@hoeckxer

This comment has been minimized.

hoeckxer commented Oct 20, 2016

Thanks for the response, it was as I suspected then. I can imagine that the upgrade to spring 4.3 breaks more things under 2.6. We can stick to the snapshot-version for now; is there any specific date for the planned 2.7 release date?

@christophd christophd added the READY label Nov 3, 2016

@christophd christophd added this to the v2.7 milestone Nov 3, 2016

@christophd christophd added Type: Bug IN PROGRESS and removed READY labels Nov 3, 2016

@christophd christophd self-assigned this Nov 3, 2016

@joh64sei

This comment has been minimized.

joh64sei commented Nov 30, 2016

This might be a bug in Spring Framework 4.3.5 and prior. I spoke to Jürgen Höller from Pivotal and described this issue that also happened to me. He told me that this is definitely not the originally intended behaviour. Maybe it's a good idea to create a ticket in Github for Spring Framework 4.3.x which is used by Spring Boot 1.4.x.

My observations:

The following bean MessageConstructionInterceptors is initialized in the Spring configuration class CitrusSpringConfig.

/* ... */

public class MessageConstructionInterceptors implements MessageConstructionInterceptor {

    @Autowired(required = false)
    private List<MessageConstructionInterceptor> messageConstructionInterceptors = new ArrayList<MessageConstructionInterceptor>();

    @Override
    public Message interceptMessageConstruction(Message message, String messageType, TestContext context) {
        Message interceptedMessage = message;

        for (MessageConstructionInterceptor interceptor : messageConstructionInterceptors) {
            if (interceptor instanceof DataDictionary &&
                    !((DataDictionary) interceptor).isGlobalScope()) {
                // skip explicit data dictionary to avoid duplicate dictionary usage.
                continue;
            }

            interceptedMessage = interceptor.interceptMessageConstruction(interceptedMessage, messageType, context);
        }

        return interceptedMessage;
    }

/* ... */
}

A list of MessageConstructionInterceptor beans is injected to it which is allowed to be empty. The bean itself also implements the interface MessageConstructionInterceptor. If there are no other beans of interface MessageConstructionInterceptor the bean itself is injected into the list but only in this case. Otherwise the list doesn't contain itself. This self-injection is the cause of the problem. Because of that the method interceptMessageConstruction() runs in an endless loop which leads to a StackOverflowError. With Spring 4.2.x and prior the list was empty. So, there was no problem.

@hoeckxer

This comment has been minimized.

hoeckxer commented Dec 5, 2016

Is there any news on the release date for 2.7? It appears that the milestone didn't make the release date of 30 november, so I'd be curious to know when it is expected to be released?

@christophd christophd closed this Jan 12, 2017

@christophd christophd removed the IN PROGRESS label Jan 12, 2017

@christophd christophd removed their assignment Jan 12, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment