提交 088a8227 编写于 作者: L lancea

8004374: CachedRowSetSwriter.writeData reports wrong number of conflicts in SyncProviderException

Reviewed-by: naoto
上级 0ac57f25
...@@ -264,7 +264,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { ...@@ -264,7 +264,7 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
* <code>false</code> otherwise * <code>false</code> otherwise
*/ */
public boolean writeData(RowSetInternal caller) throws SQLException { public boolean writeData(RowSetInternal caller) throws SQLException {
boolean conflict = false; long conflicts = 0;
boolean showDel = false; boolean showDel = false;
PreparedStatement pstmtIns = null; PreparedStatement pstmtIns = null;
iChangedValsInDbAndCRS = 0; iChangedValsInDbAndCRS = 0;
...@@ -337,8 +337,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { ...@@ -337,8 +337,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
while (crs.next()) { while (crs.next()) {
if (crs.rowDeleted()) { if (crs.rowDeleted()) {
// The row has been deleted. // The row has been deleted.
if (conflict = (deleteOriginalRow(crs, this.crsResolve)) == true) { if (deleteOriginalRow(crs, this.crsResolve)) {
status.add(rows, SyncResolver.DELETE_ROW_CONFLICT); status.add(rows, SyncResolver.DELETE_ROW_CONFLICT);
conflicts++;
} else { } else {
// delete happened without any occurrence of conflicts // delete happened without any occurrence of conflicts
// so update status accordingly // so update status accordingly
...@@ -349,8 +350,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { ...@@ -349,8 +350,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
// The row has been inserted. // The row has been inserted.
pstmtIns = con.prepareStatement(insertCmd); pstmtIns = con.prepareStatement(insertCmd);
if ( (conflict = insertNewRow(crs, pstmtIns, this.crsResolve)) == true) { if (insertNewRow(crs, pstmtIns, this.crsResolve)) {
status.add(rows, SyncResolver.INSERT_ROW_CONFLICT); status.add(rows, SyncResolver.INSERT_ROW_CONFLICT);
conflicts++;
} else { } else {
// insert happened without any occurrence of conflicts // insert happened without any occurrence of conflicts
// so update status accordingly // so update status accordingly
...@@ -358,8 +360,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { ...@@ -358,8 +360,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
} }
} else if (crs.rowUpdated()) { } else if (crs.rowUpdated()) {
// The row has been updated. // The row has been updated.
if ( conflict = (updateOriginalRow(crs)) == true) { if (updateOriginalRow(crs)) {
status.add(rows, SyncResolver.UPDATE_ROW_CONFLICT); status.add(rows, SyncResolver.UPDATE_ROW_CONFLICT);
conflicts++;
} else { } else {
// update happened without any occurrence of conflicts // update happened without any occurrence of conflicts
// so update status accordingly // so update status accordingly
...@@ -395,21 +398,12 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable { ...@@ -395,21 +398,12 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
// reset // reset
crs.setShowDeleted(showDel); crs.setShowDeleted(showDel);
boolean boolConf = false;
for (int j=1;j<status.size();j++){
// ignore status for index = 0 which is set to null
if(! ((status.get(j)).equals(SyncResolver.NO_ROW_CONFLICT))) {
// there is at least one conflict which needs to be resolved
boolConf = true;
break;
}
}
crs.beforeFirst(); crs.beforeFirst();
this.crsResolve.beforeFirst(); this.crsResolve.beforeFirst();
if(boolConf) { if(conflicts != 0) {
SyncProviderException spe = new SyncProviderException(status.size() - 1+resBundle.handleGetObject("crswriter.conflictsno").toString()); SyncProviderException spe = new SyncProviderException(conflicts + " " +
resBundle.handleGetObject("crswriter.conflictsno").toString());
//SyncResolver syncRes = spe.getSyncResolver(); //SyncResolver syncRes = spe.getSyncResolver();
SyncResolverImpl syncResImpl = (SyncResolverImpl) spe.getSyncResolver(); SyncResolverImpl syncResImpl = (SyncResolverImpl) spe.getSyncResolver();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册