contextshuffling opened a new issue #3163: Test can fail if HashMap iterates in 
a different order
URL: https://github.com/apache/incubator-shardingsphere/issues/3163
 
 
   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub 
issues](https://github.com/apache/incubator-shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response **more than 7 days** and we cannot reproduce it on current 
information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   dev branch: 4.0.0-RC3-SNAPSHOT
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   sharding-jdbc
   ### Expected behavior
   Test cases inside `EncryptPreparedStatementTest` and 
`EncryptStatementTest.java ` should pass regardless of the HashMap iteration 
orders.
   ### Actual behavior
   Tests can fail if the order changes
   ### Reason analyze (If you can)
   Currently, test cases inside `EncryptPreparedStatementTest` and 
`EncryptStatementTest.java ` are using `dataSourceMap`, a HashMap, defined in 
`AbstractSQLTest`.  The testing helper function `assertResultSet` has a line 
like following
   ```
    try (Connection conn = 
getDatabaseTypeMap().values().iterator().next().values().iterator().next().getConnection();
   ...)
   ```
   It is basically getting the first item in the map so it depends on the 
iterative order of HashMap. However, HashMap does not guarantee any specific 
order of entries. Therefore, the assertions in those test cases will fail if 
the order is different.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   Slightly modifies the order of `DB_NAMES` in `AbstractSQLTest` will cause 
the test to fail.
   
   
   ### Example codes for reproduce this issue (such as a github link).
   ```
   private static final List<String> DB_NAMES = Arrays.asList( 
"jdbc_0","encrypt", "jdbc_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:
[email protected]


With regards,
Apache Git Services

Reply via email to