Skip to content
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

bugfix:fix type casting problem when using redis as registry #2179

Merged
merged 14 commits into from
Jan 22, 2020

Conversation

guojingyinan219
Copy link
Contributor

…s/2160

Ⅰ. Describe what this PR did

fix the problem of spring redis register auto injection error ,the issues address:
#2160

Ⅱ. Does this pull request fix one issue?

fixes #2160

Ⅲ. Why don't you add test cases (unit test/integration test)?

unit test

Ⅳ. Describe how to verify it

spring-redis register auto injection

Ⅴ. Special notes for reviews

@codecov-io
Copy link

codecov-io commented Jan 14, 2020

Codecov Report

Merging #2179 into develop will increase coverage by 0.1%.
The diff coverage is 53.06%.

Impacted file tree graph

@@             Coverage Diff              @@
##             develop    #2179     +/-   ##
============================================
+ Coverage      53.03%   53.14%   +0.1%     
- Complexity      2511     2513      +2     
============================================
  Files            484      485      +1     
  Lines          15384    15360     -24     
  Branches        1777     1771      -6     
============================================
+ Hits            8159     8163      +4     
+ Misses          6437     6410     -27     
+ Partials         788      787      -1
Impacted Files Coverage Δ Complexity Δ
.../rm/datasource/undo/mysql/MySQLUndoLogManager.java 82.35% <ø> (ø) 7 <0> (ø) ⬇️
...ava/io/seata/core/constants/ConfigurationKeys.java 0% <ø> (ø) 0 <0> (ø) ⬇️
.../seata/rm/datasource/undo/UndoExecutorFactory.java 75% <ø> (+2.77%) 3 <0> (-1) ⬇️
...a/io/seata/discovery/registry/RegistryFactory.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...rc/main/java/io/seata/core/rpc/ChannelManager.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...o/seata/rm/datasource/AbstractConnectionProxy.java 11.7% <0%> (ø) 5 <0> (ø) ⬇️
...e/src/main/java/io/seata/core/rpc/ChannelUtil.java 0% <0%> (ø) 0 <0> (?)
...ery/registry/consul/ConsulRegistryServiceImpl.java 1.01% <0%> (+0.02%) 1 <0> (ø) ⬇️
...re/src/main/java/io/seata/core/rpc/RpcContext.java 44.44% <0%> (+6.79%) 21 <0> (ø) ⬇️
...ata/rm/datasource/undo/AbstractUndoLogManager.java 59.37% <0%> (ø) 17 <0> (ø) ⬇️
... and 22 more

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seata1.0redis自动注入失败一共有两个问题,
1:不支持密码
2:转换异常
做如下修改
@component
@ConfigurationProperties(prefix = REGISTRY_REDIS_PREFIX)
public class RegistryRedisProperties {
private String serverAddr = "localhost:6379";
private String db = "0";
private String password = "";

public String getServerAddr() {
	return serverAddr;
}

public RegistryRedisProperties setServerAddr(String serverAddr) {
	this.serverAddr = serverAddr;
	return this;
}

public String getPassword() {
	return password;
}

public RegistryRedisProperties setPassword(String password) {
	this.password = password;
	return this;
}

public String getDb() {
	return db;
}

public RegistryRedisProperties setDb(String db) {
	this.db = db;
	return this;
}

}
/**
* getRedisDbFileKey()获取的是key,不是value,无法强转,导致 unable not cast
*/
int db = seataConfig.getInt(seataConfig.getConfig(getRedisDbFileKey()));

@zjinlei zjinlei added the first-time contributor first-time contributor label Jan 14, 2020
@xingfudeshi xingfudeshi self-requested a review January 14, 2020 02:21
@xingfudeshi xingfudeshi changed the title #fix 修复spring-redis 注册器 自动注入报错问题 https://github.com/seata/seata/issue… bugfix:fix type casting problem when using redis as registry Jan 14, 2020
@guojingyinan219
Copy link
Contributor Author

@renyuanxin111 类型已经修复,fix #2160

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't actually verified this pr, but I think the problem is that we need int type but reflection returns Object. Can you add unit tests about this pr?

@guojingyinan219
Copy link
Contributor Author

@slievrly I don't know how to write this unit test. I package seata-spring-boot-starter and run in my program with debug, it's ok

@guojingyinan219
Copy link
Contributor Author

image
if look like you describe, serverAddr can not read and return Object ,but is ok

@zjinlei zjinlei added this to the 1.1.0 milestone Jan 15, 2020
Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but test coverage is reduced a lot.

Copy link
Member

@xingfudeshi xingfudeshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Contributor

@zjinlei zjinlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zjinlei zjinlei merged commit 456a7cd into apache:develop Jan 22, 2020
booogu pushed a commit to booogu/seata that referenced this pull request Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-time contributor first-time contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

seata-spring-boot-starter 注册时,选用redis注册报错
5 participants