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

Encryption rules do not support uppercase fields #3309

Closed
yanyzy opened this issue Oct 17, 2019 · 4 comments · Fixed by #3781
Closed

Encryption rules do not support uppercase fields #3309

yanyzy opened this issue Oct 17, 2019 · 4 comments · Fixed by #3781

Comments

@yanyzy
Copy link
Contributor

yanyzy commented Oct 17, 2019

Bug Report

Which version of ShardingSphere did you use?

4.0.0-RC3-SNAPSHOT

Which project did you use? Sharding-JDBC or Sharding-Proxy?

Sharding-JDBC

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

Sql:

 <insert id="saveSysUser" parameterType="com.mlt.demo.entity.SysUser">
		insert into SYS_USER (ID,
		 NAME,
		 AGE)
		values (#{id,jdbcType=VARCHAR},
                #{name,jdbcType=VARCHAR},
                #{age,jdbcType=VARCHAR}
		)
	</insert>

Config:

spring:
  shardingsphere:
    datasource:
    ···
    
    encrypt:
      encryptors:
        encryptor_aes:
          type: aes
          props:
            aes.key.value: aes-dg
        encryptor_md5:
          type: md5
      tables:
        SYS_USER:
          columns:
            AGE:
              plainColumn: AGE
              cipherColumn: AGE_CIPHER
              encryptor: encryptor_aes

error:

	at java.util.ArrayList.elementData(ArrayList.java:422)
	at java.util.ArrayList.get(ArrayList.java:435)
	at org.apache.shardingsphere.core.preprocessor.segment.insert.InsertValueContext.getValue(InsertValueContext.java:86)
	at org.apache.shardingsphere.core.rewrite.feature.encrypt.parameter.impl.EncryptInsertValueParameterRewriter.encryptInsertValues(EncryptInsertValueParameterRewriter.java:75)
	at org.apache.shardingsphere.core.rewrite.feature.encrypt.parameter.impl.EncryptInsertValueParameterRewriter.rewrite(EncryptInsertValueParameterRewriter.java:63)
	at org.apache.shardingsphere.core.rewrite.feature.encrypt.context.EncryptSQLRewriteContextDecorator.decorate(EncryptSQLRewriteContextDecorator.java:43)
	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.EncryptPreparedStatement.getSQLUnit(EncryptPreparedStatement.java:157)
	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.EncryptPreparedStatement.execute(EncryptPreparedStatement.java:127)
	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)
	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
	... 52 more
@yanyzy
Copy link
Contributor Author

yanyzy commented Oct 17, 2019

Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: java.lang.ArrayIndexOutOfBoundsException: -1
### The error may involve com.mlt.demo.mapper.SysUserMapper.saveSysUser-Inline
### The error occurred while setting parameters
### SQL: insert into SYS_USER (ID,    NAME,    AGE)   values (?,                 ?,                 ?   )
### Cause: java.lang.ArrayIndexOutOfBoundsException: -1
	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
	... 46 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.elementData(ArrayList.java:422)
	at java.util.ArrayList.get(ArrayList.java:435)
	at org.apache.shardingsphere.core.preprocessor.segment.insert.InsertValueContext.getValue(InsertValueContext.java:86)
	at org.apache.shardingsphere.core.rewrite.feature.encrypt.parameter.impl.EncryptInsertValueParameterRewriter.encryptInsertValues(EncryptInsertValueParameterRewriter.java:75)
	at org.apache.shardingsphere.core.rewrite.feature.encrypt.parameter.impl.EncryptInsertValueParameterRewriter.rewrite(EncryptInsertValueParameterRewriter.java:63)
	at org.apache.shardingsphere.core.rewrite.feature.encrypt.context.EncryptSQLRewriteContextDecorator.decorate(EncryptSQLRewriteContextDecorator.java:43)
	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.EncryptPreparedStatement.getSQLUnit(EncryptPreparedStatement.java:157)
	at org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.EncryptPreparedStatement.execute(EncryptPreparedStatement.java:127)
	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)
	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
	... 52 more

@HongJinFeng
Copy link
Contributor

Please assign me to fix this bug.(I have the same problem when i use encrypt jdbc but i had fixed it and now the code is running in product environment) @terrymanu

@yanyzy yanyzy assigned HongJinFeng and unassigned yanyzy Dec 18, 2019
@yanyzy
Copy link
Contributor Author

yanyzy commented Dec 18, 2019

@HongJinFeng
Looking forward to your pull request!

@HongJinFeng
Copy link
Contributor

Thanks, It may on weaekend because still need to work on weekday.

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