Skip to content

SpringManagedTransaction#close broken backward-compatibility between 1.3.x and 2.0.x #427

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

Closed
SElab2019 opened this issue Dec 2, 2019 · 3 comments · Fixed by #430
Closed
Assignees
Labels
Milestone

Comments

@SElab2019
Copy link

When I try to upgrade mybatis-spring from 1.3.2 to the version after 2.0.0. The upgrade breaks my existing code when I extend SpringManagedTransaction and override method Close with SQLException. e.g.

public class Demo extends SpringManagedTransaction{
	private Connection connection;

	public Demo(DataSource dataSource) {
		super(dataSource);
	}

	@Override
	public void close() throws SQLException {
		try {
			if(connection != null){
				if(!TransactionSynchronizationManager.isSynchronizationActive()){
					if(connection.isReadOnly()){
						connection.setReadOnly(false);
					}
				}else if(!TransactionSynchronizationManager.isActualTransactionActive()){
					if(connection.isReadOnly()){
						connection.setReadOnly(false);
					}
				}
			}
		} catch (Exception e) {
			LOGGER.error("ha reset read only error:" + e.getMessage(), e);
		}
			
		super.close();
	}
}

The code should pass. However, it throws an error:

close() in Demo cannot override close() in org.mybatis.spring.transaction.SpringManagedTransaction
 overridden method does not throw java.sql.SQLException
@kazuki43zoo kazuki43zoo added this to the 2.0.4 milestone Dec 2, 2019
@kazuki43zoo kazuki43zoo added the bug label Dec 2, 2019
@kazuki43zoo kazuki43zoo self-assigned this Dec 2, 2019
@kazuki43zoo
Copy link
Member

@SElab2019 Thanks for your report!

This issue is bug(This issue was included by 5ca5f2d). We will revert it at 2.0.4.

@kazuki43zoo kazuki43zoo changed the title Updating from 1.3.2 to 2.0.3 breaks SpringManagedTransaction#close broken backward-compatibility between 1.3.x and 2.0.x Dec 2, 2019
kazuki43zoo added a commit that referenced this issue Dec 2, 2019
Revert "Remove unnecessary throws clause"
@kazuki43zoo
Copy link
Member

@SElab2019

I've fixed and deployed the 2.0.4-SNAPSHOT version on OSS sonatype repository. Please try it if you have a time. Thanks.

@SElab2019
Copy link
Author

SElab2019 commented Dec 2, 2019

@kazuki43zoo

I've fixed and deployed the 2.0.4-SNAPSHOT version on OSS sonatype repository. Please try it if you have a time. Thanks.

You are welcome. Thanks for confirming and quick fixing. It could solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants