You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/11/23 08:06:42 UTC

[GitHub] [shardingsphere] duzhanfei opened a new issue #8303: java.lang.NullPointerException: Cannot invoke method hashCode() on null object

duzhanfei opened a new issue #8303:
URL: https://github.com/apache/shardingsphere/issues/8303


   ### Which version of ShardingSphere did you use?
   5.0.0
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   shardingProxy 
   
   The problem occued in my project when i  invoke  interface  for updating .
   and the sharding key is not null. the result is  ok  when i change the proxy version to 4.1.1  
   
   part of  proxy config:
   
       pbcst_qry_info:
         actualDataNodes: ms_ds.pbcst_qry_info_${0..15}
         tableStrategy:
           standard:
             shardingColumn: ecif_cust_no
             shardingAlgorithmName: pbcst_qry_info_inline
         databaseStrategy:
           standard:
             shardingColumn: ecif_cust_no
             shardingAlgorithmName: database_inline
         keyGenerateStrategy:
           column: ecif_cust_no
           keyGeneratorName: snowflake
   
   
      pbcst_qry_info_inline:
         type: INLINE
         props:
           algorithm-expression: pbcst_qry_info_${Math.abs(ecif_cust_no.hashCode() % 16)} 
   
   log:
   [INFO ] 16:01:20.936 [ShardingSphere-Command-12] ShardingSphere-SQL - Logic SQL: SELECT @@session.transaction_read_only
   [INFO ] 16:01:20.937 [ShardingSphere-Command-12] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(limit=Optional.empty, lock=Optional.empty)
   [INFO ] 16:01:20.937 [ShardingSphere-Command-12] ShardingSphere-SQL - Actual SQL: replica_ds_0 ::: SELECT @@session.transaction_read_only
   [ERROR] 16:01:27.249 [ShardingSphere-Command-13] o.a.s.p.f.c.CommandExecutorTask - Exception occur:
   java.lang.NullPointerException: Cannot invoke method hashCode() on null object
           at org.codehaus.groovy.runtime.NullObject.hashCode(NullObject.java:174)
           at org.codehaus.groovy.runtime.NullObject$hashCode.call(Unknown Source)
           at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
           at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:34)
           at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
           at org.codehaus.groovy.runtime.NullObject$hashCode.call(Unknown Source)
           at Script23$_run_closure1.doCall(Script23.groovy:1)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
           at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
           at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
           at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
           at groovy.lang.Closure.call(Closure.java:420)
           at groovy.lang.Closure.call(Closure.java:414)
           at org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm.doSharding(InlineShardingAlgorithm.java:69)
           at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:67)
           at org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy.doSharding(StandardShardingStrategy.java:56)
           at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeTables(ShardingStandardRoutingEngine.java:214)
           at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route0(ShardingStandardRoutingEngine.java:194)
           at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditionsWithCondition(ShardingStandardRoutingEngine.java:114)
           at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.routeByShardingConditions(ShardingStandardRoutingEngine.java:107)
           at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.getDataNodes(ShardingStandardRoutingEngine.java:84)
           at org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingStandardRoutingEngine.route(ShardingStandardRoutingEngine.java:69)
           at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:70)
           at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:55)
           at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:59)
           at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:57)
           at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:52)
           at org.apache.shardingsphere.proxy.backend.communication.jdbc.JDBCDatabaseCommunicationEngine.execute(JDBCDatabaseCommunicationEngine.java:77)
           at org.apache.shardingsphere.proxy.backend.text.query.QueryBackendHandler.execute(QueryBackendHandler.java:61)
           at org.apache.shardingsphere.proxy.frontend.mysql.command.query.text.query.MySQLComQueryPacketExecutor.execute(MySQLComQueryPacketExecutor.java:62)
           at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:100)
           at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:76)
           at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
           at java.lang.Thread.run(Unknown Source)
   
   
   
   
   
   
   
   
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] duzhanfei removed a comment on issue #8303: java.lang.NullPointerException: Cannot invoke method hashCode() on null object

Posted by GitBox <gi...@apache.org>.
duzhanfei removed a comment on issue #8303:
URL: https://github.com/apache/shardingsphere/issues/8303#issuecomment-732193216


   And  inline expression  could  judge null before call hashcode method ?   I  don't understand what you said.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] duzhanfei commented on issue #8303: java.lang.NullPointerException: Cannot invoke method hashCode() on null object

Posted by GitBox <gi...@apache.org>.
duzhanfei commented on issue #8303:
URL: https://github.com/apache/shardingsphere/issues/8303#issuecomment-732193216


   And  inline expression  could  judge null before call hashcode method ?   I  don't understand what you said.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu closed issue #8303: java.lang.NullPointerException: Cannot invoke method hashCode() on null object

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #8303:
URL: https://github.com/apache/shardingsphere/issues/8303


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu commented on issue #8303: java.lang.NullPointerException: Cannot invoke method hashCode() on null object

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #8303:
URL: https://github.com/apache/shardingsphere/issues/8303#issuecomment-732069764


   The inline expression is write by yourself, please make sure it is correct. 
   For example: Avoid use null value or judge null before use hashcode


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] duzhanfei commented on issue #8303: java.lang.NullPointerException: Cannot invoke method hashCode() on null object

Posted by GitBox <gi...@apache.org>.
duzhanfei commented on issue #8303:
URL: https://github.com/apache/shardingsphere/issues/8303#issuecomment-732657583


   the config  of   config-replica-query.yaml  
   
   schemaName: replica_query_db
   
   dataSourceCommon:
     connectionTimeoutMilliseconds: 30000
     idleTimeoutMilliseconds: 60000
     maxLifetimeMilliseconds: 1800000
     maxPoolSize: 50
     minPoolSize: 1
     maintenanceIntervalMilliseconds: 30000
   
   dataSources:
     primary_ds:
       url: jdbc:mysql://127.5.2.31:3306/crm_customer_db_master0?serverTimezone=UTC&useSSL=false
       username: root
       password: root
     replica_ds_0:
       url: jdbc:mysql://127.5.2.32:3306/crm_customer_db_master0_slave0?serverTimezone=UTC&useSSL=false
       username: root
       password: root
     replica_ds_1:
       url: jdbc:mysql://127.5.2.33:3306/crm_customer_db_master0_slave1?serverTimezone=UTC&useSSL=false
       username: root
       password: root
     ds_default:
       url: jdbc:mysql://127.5.2.34:3306/cdsp_crm_db?serverTimezone=UTC&useSSL=false
       username: root
       password: root
   
   rules:
   - !SHARDING
     tables:
       pbcst_qry_info:
         actualDataNodes: ms_ds.pbcst_qry_info_${0..15}
         tableStrategy:
           standard:
             shardingColumn: ecif_cust_no
             shardingAlgorithmName: pbcst_qry_info_inline
         databaseStrategy:
           standard:
             shardingColumn: ecif_cust_no
             shardingAlgorithmName: database_inline
         keyGenerateStrategy:
           column: ecif_cust_no
           keyGeneratorName: snowflake
   		
     defaultDatabaseStrategy:
       standard:
         shardingColumn: ecif_cust_no
         shardingAlgorithmName: ds_default
     defaultTableStrategy:
       none:
   
     shardingAlgorithms:
       database_default_inline:
         type: INLINE
         props:
           algorithm-expression: ms_ds
       database_inline:
         type: INLINE
         props:
           algorithm-expression: ms_ds
       pbcst_qry_info_inline:
         type: INLINE
         props:
           algorithm-expression: pbcst_qry_info_${Math.abs(ecif_cust_no.hashCode() % 16)}
   		
     keyGenerators:
       snowflake:
         type: SNOWFLAKE
         props:
           worker-id: 123
   		
   - !REPLICA_QUERY
     dataSources:
       ms_ds:
         name: ms_ds
         primaryDataSourceName: primary_ds
         replicaDataSourceNames:
           - replica_ds_0
           - replica_ds_1


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] duzhanfei commented on issue #8303: java.lang.NullPointerException: Cannot invoke method hashCode() on null object

Posted by GitBox <gi...@apache.org>.
duzhanfei commented on issue #8303:
URL: https://github.com/apache/shardingsphere/issues/8303#issuecomment-732112462


   Thank you for your reply  very much   ,the  sharding  column is not null ,I wonder what went wrong.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu edited a comment on issue #8303: java.lang.NullPointerException: Cannot invoke method hashCode() on null object

Posted by GitBox <gi...@apache.org>.
terrymanu edited a comment on issue #8303:
URL: https://github.com/apache/shardingsphere/issues/8303#issuecomment-732069764


   The inline expression is write by yourself, please make sure it is correct. 
   For example: Avoid use null value or judge null before call hashcode method


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org