Skip to content
Snippets Groups Projects
Unverified Commit 1e08c033 authored by jimin's avatar jimin Committed by GitHub
Browse files

bugfix: fix Collections NPE (#3233)

parent 8895e70c
No related branches found
No related tags found
No related merge requests found
......@@ -466,9 +466,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
......
......@@ -15,12 +15,6 @@
*/
package io.seata.rm.datasource.mock;
import com.alibaba.druid.util.jdbc.ResultSetBase;
import com.google.common.collect.Lists;
import io.seata.rm.datasource.sql.struct.ColumnMeta;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.ResultSetMetaData;
......@@ -29,6 +23,13 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.alibaba.druid.util.jdbc.ResultSetBase;
import com.google.common.collect.Lists;
import io.seata.rm.datasource.sql.struct.ColumnMeta;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author will
*/
......@@ -108,7 +109,16 @@ public class MockResultSet extends ResultSetBase {
@Override
public int findColumn(String columnLabel) throws SQLException {
return columnLabels.indexOf(columnLabel) + 1;
if (columnLabels.indexOf(columnLabel) != -1) {
return columnLabels.indexOf(columnLabel) + 1;
}
if (columnLabels.indexOf(columnLabel.toLowerCase()) != -1) {
return columnLabels.indexOf(columnLabel.toLowerCase()) + 1;
}
if (columnLabels.indexOf(columnLabel.toUpperCase()) != -1) {
return columnLabels.indexOf(columnLabel.toUpperCase()) + 1;
}
return -1;
}
@Override
......
......@@ -17,6 +17,8 @@ package io.seata.server.session;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import io.seata.common.exception.ShouldNeverHappenException;
......@@ -131,10 +133,12 @@ public class SessionHolder {
((Reloadable) ROOT_SESSION_MANAGER).reload();
}
// There is a remove operation in the following code, it will affect the file mode, so new ArrayList
List<GlobalSession> allSessions = new ArrayList<>(ROOT_SESSION_MANAGER.allSessions());
Collection<GlobalSession> allSessions = ROOT_SESSION_MANAGER.allSessions();
if (CollectionUtils.isNotEmpty(allSessions)) {
allSessions.forEach(globalSession -> {
List<GlobalSession> removeGlobalSessions = new ArrayList<>();
Iterator<GlobalSession> iterator = allSessions.iterator();
while (iterator.hasNext()) {
GlobalSession globalSession = iterator.next();
GlobalStatus globalStatus = globalSession.getStatus();
switch (globalStatus) {
case UnKnown:
......@@ -145,7 +149,7 @@ public class SessionHolder {
case TimeoutRollbacked:
case TimeoutRollbackFailed:
case Finished:
removeInErrorState(globalSession);
removeGlobalSessions.add(globalSession);
break;
case AsyncCommitting:
if (storeMode == StoreMode.FILE) {
......@@ -177,7 +181,10 @@ public class SessionHolder {
break;
}
}
});
}
for (GlobalSession globalSession : removeGlobalSessions) {
removeInErrorState(globalSession);
}
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment